0.4.2 - 2022-02-06
- Update
rollup-plugin-solid
to 1.2.2 to address Bundlephobia build error (caused by it tripping over the optinal chaining syntax?.
). The plugin now targets a slightly older env in order to compile this syntax away.
0.4.1 - 2022-02-03
-
Fix pointer sensor preventing default event behaviour on attachment. Instead, wait for activation of drag before intercepting relevant events. This avoids unexpected side effects, such as an
<input/>
not receiving focus on click.With this change, also listen for and clear any text selection that happens as a side effect during an active drag operation.
Thanks to @yonathan06 for reporting this behaviour.
0.4.0 - 2022-01-09
- TypeScript Typings! Thanks to @areknawo, Solid DnD is now fully typed.
-
Breaking Change As part of adding typings to Solid DnD, change most function signatures to use positional parameters over an options object. This simplifies the typing and makes it easier to use and understand the function parameters.
For reference, the rules used when applying this change were:
- Default to multiple positional params. For example, a call to
createDraggable({ id })
should now becreateDraggable(id)
. - Use an object when multiple params are related as a single entity (such as
an 'event'). For example, an
onDragEnd(event)
handler can remain unchanged (accepting a single parameter). - Use an options object when there are a large number of parameters (>3).
- Default to multiple positional params. For example, a call to
-
Breaking Change Rename
DragDropContext
toDragDropProvider
andSortableContext
toSortableProvider
to match Solid convention and better reflect usage. Note thatuseDragDropContext
anduseSortableContext
remain unchanged.
- Fix
eventMap[key] is undefined
error when attempting to drag a draggable that has been composed manually using thedraggable.dragActivators
property. This was due to naive key renaming in theasHandlers
logic and so did not affect draggable usage as a directive.
0.3.3 - 2021-11-03
- Remove leftover debug log.
0.3.2 - 2021-11-03
- Cleanup dangling references to removed items. When draggables, droppables or sensors removed, clean up dangling references to them in the state (such as 'active' or 'previous' values). This helps prevent potential infinite recursion (such as in onDragEnd) where an item (like a draggable) oscillates between having a valid 'previous' value reference and undefined.
0.3.1 - 2021-09-05
- As part of the fix for detecting collisions on drag start,
recomputeLayouts
no longer automatically callsdetectCollisions
when layouts have changed. Instead, it returns a boolean indicating whether a layout change detected and the caller can choose to calldetectCollisions
if desired.
- Fix case where a drag with no movement results in an incorrect drop. This was
due to collisions not being detected on drag start if layouts had not changed
(the common case). Collisions now always detected by
dragStart
.
0.3.0 - 2021-09-04
- Add
sensorStart
andsensorEnd
to support sensors explicitly indicating whether they are active or not. Note that only one sensor can be considered active at a time.
-
Activate sensor in
createPointerSensor
if the pointer has moved more than 10 pixels. This is irrespective of whether the delay condition has been met. It addresses the issue where a dragged item appears to jump to its new location after a delay if the pointer moved quickly at the outset of the drag. -
Make managing sensor active state explicit. Returning a truthy value from a sensor activator will no longer cause that sensor to be automatically marked as the active sensor. In addition, other activators will continue to be called until a sensor explicitly indicates it is active by calling
sensorStart
. Similarly, an active sensor must now callsensorEnd
when it is no longer active (typically when a drag completes). This makes it clearer that a sensor is responsible for managing its activation state (and how to do so), especially in cases of delayed activation.
0.2.0 - 2021-07-12
Update to work with Solid 1.0 and streamline the interface with new directives.
- Update
createDraggable
,createDroppable
andcreateSortable
to provide a custom directive. These can be used with the Soliduse:___
syntactic sugar for common usage setup - no need to pass refs and props around:
const MyComponent = (props) => {
const draggable = createDraggable({ id: props.id });
return <div use:draggable>Drag me!</div>;
};
If finer control needed, the underlying primitives are accessible by property lookup on the directive::
const MyComponent = (props) => {
const draggable = createDraggable({ id: props.id });
return (
<div ref={draggable.ref}>
<div {...draggable.dragActivators}>Drag Handle</div>
Drag me!
</div>
);
};
- Automatically detect and register usage of
DragOverlay
. Add toDragDropContext
state ausingDragOverlay
property that can be checked. - Return a new function
displace
as part of theDragDropContext
that can be used to set the transform for a droppable or draggable. See usage increateSortable
for example.
- Breaking Change Update to work with Solid 1.0! Requires updating peer dependency of Solid to 1.0 or greater.
- Refactor
isActiveDraggable
andisActiveDroppable
to appear as resolved properties rather than functions to call (this is more consistent with the rest of interface). E.g.draggable.isActiveDraggable()
->draggable.isActivateDraggable
. - Refactor sensor interface to use event type rather than handler name. For
example, make
createPointerSensor
usepointerdown
rather thanonPointerDown
for activation. As part of this, add aasHandlers
option todraggableActivators
to control whether to return object withon___
form or not (default isfalse
). - Rename occurrences of
translate
totransform
, which feels a more appropriate name. E.g.translateStyle
should now betransformStyle
and thetranslate
property returned fromcreate___
calls should be calledtransform
. - Assume valid
transform
value is always present. In particular,transformStyle
no longer checks for anull
transform value. - Improve vertical sort algorithm to better handle arbitrary gaps (such as those
created by the CSS gap property on flexbox). As part of this, remove the now
redundant
outerHeight
andouterWidth
properties from the layout data returned byelementLayout
. - Update
README.md
to reflect simpler directive interface for draggables and droppables.
- Remove support for explicitly managing droppable
disabled
state. The current implementation feels limiting and potentially confusing. For example, it prevents detecting when a draggable is over a disabled droppable and styling it appropriately. Note that a similar effect todisabled
can be achieved by determining drop suitability inonDragEnd
.
0.1.2 - 2021-07-03
Simplify releasing.
- Use release-it to simplify performing a release.
- Add keywords to
package.json
for easier discoverability of package. - Add default publish configuration to
package.json
.
0.1.1 - 2021-06-22
Initial release supporting plain drag and drop as well as an early preset for sortable lists.
- Add
createDraggable
to easily integrate drag behaviour into components, with the component maintaining control over how it looks and behaves. - Add
createDroppable
to register and manage droppable areas. - Support conditionally enabling and disabling droppables via a
disabled
option oncreateDroppable
. - Support dragging representations of a draggable through the use of a
DragOverlay
(which can be removed from the normal document flow). - Support using sensors to detect and manage drag starts.
- Add
createPointerSensor
as the default sensor, and wrap for convenience in a<DragDropSensors/>
component. - Support customising collision detection algorithms and provide two initial
ones for common usage (
mostIntersectingLayout
andclosestLayoutCenter
). - Add sortable list primitives (
SortableContext
andcreateSortable
) for drag and drop vertical list reordering. - Support using multiple (or nested)
DragDropContext
for containers isolated from each other.