Skip to content

Commit

Permalink
Allow sortable animations across groups
Browse files Browse the repository at this point in the history
  • Loading branch information
clauderic committed Sep 21, 2024
1 parent 92676b4 commit 5b36f8f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/sortable-group-aniamtion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@dnd-kit/dom': patch
---

Allow sortable animations when changing to a different group even when the index remains the same.
15 changes: 4 additions & 11 deletions packages/dom/src/sortable/sortable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,13 @@ export class Sortable<T extends Data = Data> {
() => {
const {index, group, previousIndex, manager: _} = this;

if (group !== previousGroup) {
previousGroup = group;
// Re-run this effect whenever the index changes
if (index !== previousIndex || group !== previousGroup) {
this.previousIndex = index;
return;
}
previousGroup = group;

// Re-run this effect whenever the index changes
if (index === previousIndex) {
return;
this.animate();
}

this.previousIndex = index;

this.animate();
},
() => {
const {target} = this;
Expand Down

0 comments on commit 5b36f8f

Please sign in to comment.