diff --git a/.changeset/metal-mice-develop.md b/.changeset/metal-mice-develop.md deleted file mode 100644 index bebca028..00000000 --- a/.changeset/metal-mice-develop.md +++ /dev/null @@ -1,58 +0,0 @@ ---- -'@dnd-kit/core': minor ---- - -Make it possible to add visual cues when using activation constraints. - -### Context - -Activation constraints are used when we want to prevent accidental dragging or when -pointer press can mean more than "start dragging". - -A typical use case is a button that needs to respond to both "click" and "drag" gestures. -Clicks can be distinguished from drags based on how long the pointer was -held pressed. - -### The problem - -A control that responds differently to a pointer press based on duration or distance can -be confusing to use -- the user has to guess how long to keep holding or how far to keep -dragging until their intent is acknowledged. - -Implementing such cues is currently possible by attaching extra event listeners so that -we know when a drag is pending. Furthermore, the listener needs to have access to -the same constraints that were applied to the sensor initiating the drag. This can be -made to work in simple cases, but it becomes error-prone and difficult to maintain in -complex scenarios. - -### Solution - -This changeset proposes the addition of two new events: `onDragPending` and `onDragAbort`. - -#### `onDragPending` - -A drag is considered to be pending when the pointer has been pressed and there are -activation constraints that need to be satisfied before a drag can start. - -This event is initially fired on pointer press. At this time `offset` (see below) will be -`undefined`. - -It will subsequently be fired every time the pointer is moved. This is to enable -visual cues for distance-based activation. - -The event's payload contains all the information necessary for providing visual feedback: - -```typescript -export interface DragPendingEvent { - id: UniqueIdentifier; - constraint: PointerActivationConstraint; - initialCoordinates: Coordinates; - offset?: Coordinates | undefined; -} -``` - -#### `onDragAbort` - -A drag is considered aborted when an activation constraint for a pending drag was violated. -Useful as a prompt to cancel any visual cue animations currently in progress. -Note that this event will _not_ be fired when dragging ends or is canceled. diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index b0140061..586a273e 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -1,5 +1,64 @@ # @dnd-kit/core +## 6.3.0 + +### Minor Changes + +- [#1539](https://github.com/clauderic/dnd-kit/pull/1539) [`0c6a28d`](https://github.com/clauderic/dnd-kit/commit/0c6a28d1b32c72cfbc6e103c9f430a1e8ebe7301) Thanks [@irobot](https://github.com/irobot)! - Make it possible to add visual cues when using activation constraints. + + ### Context + + Activation constraints are used when we want to prevent accidental dragging or when + pointer press can mean more than "start dragging". + + A typical use case is a button that needs to respond to both "click" and "drag" gestures. + Clicks can be distinguished from drags based on how long the pointer was + held pressed. + + ### The problem + + A control that responds differently to a pointer press based on duration or distance can + be confusing to use -- the user has to guess how long to keep holding or how far to keep + dragging until their intent is acknowledged. + + Implementing such cues is currently possible by attaching extra event listeners so that + we know when a drag is pending. Furthermore, the listener needs to have access to + the same constraints that were applied to the sensor initiating the drag. This can be + made to work in simple cases, but it becomes error-prone and difficult to maintain in + complex scenarios. + + ### Solution + + This changeset proposes the addition of two new events: `onDragPending` and `onDragAbort`. + + #### `onDragPending` + + A drag is considered to be pending when the pointer has been pressed and there are + activation constraints that need to be satisfied before a drag can start. + + This event is initially fired on pointer press. At this time `offset` (see below) will be + `undefined`. + + It will subsequently be fired every time the pointer is moved. This is to enable + visual cues for distance-based activation. + + The event's payload contains all the information necessary for providing visual feedback: + + ```typescript + export interface DragPendingEvent { + id: UniqueIdentifier; + constraint: PointerActivationConstraint; + initialCoordinates: Coordinates; + offset?: Coordinates | undefined; + } + ``` + + #### `onDragAbort` + + A drag is considered aborted when an activation constraint for a pending drag was violated. + Useful as a prompt to cancel any visual cue animations currently in progress. + Note that this event will _not_ be fired when dragging ends or is canceled. + ## 6.2.0 ### Minor Changes diff --git a/packages/core/package.json b/packages/core/package.json index 5d133aa7..7c3ff7ef 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@dnd-kit/core", - "version": "6.2.0", + "version": "6.3.0", "description": "dnd kit – a lightweight React library for building performant and accessible drag and drop experiences", "author": "Claudéric Demers", "license": "MIT", diff --git a/packages/modifiers/CHANGELOG.md b/packages/modifiers/CHANGELOG.md index 611b3b48..376bdef4 100644 --- a/packages/modifiers/CHANGELOG.md +++ b/packages/modifiers/CHANGELOG.md @@ -1,5 +1,12 @@ # @dnd-kit/modifiers +## 9.0.0 + +### Patch Changes + +- Updated dependencies [[`0c6a28d`](https://github.com/clauderic/dnd-kit/commit/0c6a28d1b32c72cfbc6e103c9f430a1e8ebe7301)]: + - @dnd-kit/core@6.3.0 + ## 8.0.0 ### Patch Changes diff --git a/packages/modifiers/package.json b/packages/modifiers/package.json index a86b6232..09e0ea02 100644 --- a/packages/modifiers/package.json +++ b/packages/modifiers/package.json @@ -1,6 +1,6 @@ { "name": "@dnd-kit/modifiers", - "version": "8.0.0", + "version": "9.0.0", "description": "Translate modifier presets for use with `@dnd-kit` packages.", "author": "Claudéric Demers", "license": "MIT", @@ -30,11 +30,11 @@ "tslib": "^2.0.0" }, "peerDependencies": { - "@dnd-kit/core": "^6.2.0", + "@dnd-kit/core": "^6.3.0", "react": ">=16.8.0" }, "devDependencies": { - "@dnd-kit/core": "^6.2.0" + "@dnd-kit/core": "^6.3.0" }, "publishConfig": { "access": "public" diff --git a/packages/sortable/CHANGELOG.md b/packages/sortable/CHANGELOG.md index bc430cd3..a0d2426c 100644 --- a/packages/sortable/CHANGELOG.md +++ b/packages/sortable/CHANGELOG.md @@ -1,5 +1,12 @@ # @dnd-kit/sortable +## 10.0.0 + +### Patch Changes + +- Updated dependencies [[`0c6a28d`](https://github.com/clauderic/dnd-kit/commit/0c6a28d1b32c72cfbc6e103c9f430a1e8ebe7301)]: + - @dnd-kit/core@6.3.0 + ## 9.0.0 ### Patch Changes diff --git a/packages/sortable/package.json b/packages/sortable/package.json index 0253af98..940a903f 100644 --- a/packages/sortable/package.json +++ b/packages/sortable/package.json @@ -1,6 +1,6 @@ { "name": "@dnd-kit/sortable", - "version": "9.0.0", + "version": "10.0.0", "description": "Official sortable preset and sensors for dnd kit", "author": "Claudéric Demers", "license": "MIT", @@ -31,10 +31,10 @@ }, "peerDependencies": { "react": ">=16.8.0", - "@dnd-kit/core": "^6.2.0" + "@dnd-kit/core": "^6.3.0" }, "devDependencies": { - "@dnd-kit/core": "^6.2.0" + "@dnd-kit/core": "^6.3.0" }, "publishConfig": { "access": "public"