Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
<DragOverlay>
component's drop animation has been refactored, which fixes a number of bugs with the existing implementation and introduces new functionality.What's new?
Scrolling the draggable node into view if needed
The drop animation now ensures that the the draggable node that we are animating to is in the viewport before performing the drop animation and scrolls it into view if needed.
Changes to the
dropAnimation
propThe
dropAnimation
prop of<DragOverlay>
now accepts either a configuration object or a custom drop animation function.The configuration object adheres to the following shape:
The default drop animation options are:
The
keyframes
option allows consumers to override the keyframes of the drop animation. For example, here is how you would add a fade out transition to the drop animation using keyframes:The
dragSourceOpacity
option has been deprecated in favour of letting consumers define arbitrary side effects that should run before the animation starts. Side effects may return a cleanup function that should run when the drop animation has completed.Drop animation side effects are a powerful abstraction that provide a lot of flexibility. The
defaultDropAnimationSideEffects
function is exported by@dnd-kit/core
and aims to facilitate the types of side-effects we anticipate most consumers will want to use out of the box:For advanced side-effects, consumers may define a custom
sideEffects
function that may optionally return a cleanup function that will be executed when the drop animation completes:For even more advanced use-cases, consumers may also provide a function to the
dropAnimation
prop, which adheres to the following shape:Bug fixes
<DragOverlay>
now respects themeasuringConfiguration
specified for thedragOverlay
anddraggable
properties when measuring the rects to animate to and from.<DragOverlay>
component now supports rendering children while performing the drop animation. Previously, the drag overlay would be in a broken state when trying to pick up an item while a drop animation was in progress.Migration steps
For consumers that were relying on the
dragSourceOpacity
property in theirdropAnimation
configuration: