Release 0.7.0
Refactor core to lean more into reactivity. Note there are multiple breaking
changes in this release - see below for details.
Added
-
Export
DragEventtype for external use in order to avoid consumers having to
redefine this type for custom handlers. -
Explicitly type
Id(forstring | numberids) and export for reuse. -
Add
rectgetter onLayoutfor ease of use. When duplicating aLayout,
can now donew Layout(existingLayout.rect). -
Support for custom transformers to refine
DraggableandDroppable
transform behaviour. Transformers are specified against an individual item and
can be used for things like limiting drag movement to a particular axis:const transformer = { id: "constrain-x-axis", order: 100, callback: (transform) => ({ ...transform, x: 0 }), }; onDragStart(({ draggable }) => { addTransformer("draggables", draggable.id, transformer); }); onDragEnd(({ draggable }) => { removeTransformer("draggables", draggable.id, transformer.id); });
-
Support using function element form for
DragOverlaychildren. This enables
referencing the relatedDraggabledirectly without the need to track
separately. For example:<DragOverlay> {(draggable) => <div>Draggable {draggable.id}</div>} </DragOverlay>
Changed
-
Breaking Change Refactor core to lean more into reactivity.
Notably, make transforms a reactive computation of an array of transformers
rather than a pre-computed set state. For example, make active draggable
transform react to current sensor position rather than have sensor set the
draggable position directly.To support this reactivity, introduce a
sensorMovefunction in place of the
previousdragMovefunction, add functions (addTransformer,
removeTransformer) to manage transfomers on draggables and droppables, and
remove the now redundantdisplacefunction.Transformers are keyed by id and orderable for ease of use and predictability,
and can be accessed via thetransfomersproperty on draggables or
droppables. -
Breaking Change Sensors should now pass their initial coordinates to
sensorStartand updated coordinates to the newsensorMovefunction (which
replaces the removeddragMovefunction). The included pointer sensor has
been updated accordingly. -
Breaking Change Move 'read state' helpers directly into the state object.
This makes a clearer separation between actions that typically modify state vs
accessing the state for readonly purposes. It also feels more intuitive.As part of this, rename the existing state entries that refer to 'ids' to
explicitly reflect this:state.active.draggable->state.active.draggableIdstate.active.droppable->state.active.droppableIdstate.active.sensor->state.active.sensorIdstate.previous.draggable->state.active.draggableIdstate.previous.droppable->state.active.droppableId
Also, remove all redundant helpers in favour of directly using the state:
activeDraggable()->state.active.draggablepreviousDraggable()->state.previous.draggableanyDraggableActive()->state.active.draggableactiveDroppable()->state.active.droppablepreviousDroppable()->state.previous.droppableanyDroppableActive()->state.active.droppableactiveSensor()->state.active.sensor
-
Breaking Change Remove filter argument from
recomputeLayouts. Instead,
the core will determine which nodes to re-evaluate when called (and will also
cache nodes to avoid redundant evaluation of layout when appropriate).
Fixed
-
Breaking change Make Solid JS 1.5 the minimum compatible version of Solid
and update to support its breaking changes to typings, and the newbatch
behaviour. -
Breaking Change Use
DragOverlaylayout in collision detection.
Previously theDraggablelayout was used leading to unexpected behaviour
collision behaviour (such as a larger overlay not triggering aDroppable
even when over it). As part of this theusingDragOverlayproperty of dnd
state is removed in faviour of trackingstate.active.overlaydata. -
Auto-center
DragOverlayover its relatedDraggableon drag start for a
better experience when the overlay is of differing size to the draggable. -
Avoid reacting to irrelevant droppable changes in
onDragEnd. -
Minimise differences in layout calculations. Due to the way transforms are
stripped from layouts, it is possible to end up with small differences in
layout values. This is due to precision issues in JS. Attempt to minimise
occurences by rounding to nearest whole number (pixel).