Skip to content

Commit 61eb557

Browse files
author
Clauderic Demers
committed
fix: drop animation for virtualized lists
1 parent 15bd5a4 commit 61eb557

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

src/Manager/index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default class Manager {
1010
}
1111

1212
remove(collection, ref) {
13-
const index = this.getIndex(collection, ref);
13+
const index = this.findIndex(collection, ref);
1414

1515
if (index !== -1) {
1616
this.refs[collection].splice(index, 1);
@@ -22,13 +22,17 @@ export default class Manager {
2222
}
2323

2424
getActive() {
25-
return this.refs[this.active.collection].find(
25+
return this.nodeAtIndex(this.active.index);
26+
}
27+
28+
nodeAtIndex(index, collection = this.active.collection) {
29+
return this.refs[collection].find(
2630
// eslint-disable-next-line eqeqeq
27-
({node}) => node.sortableInfo.index == this.active.index,
31+
({node}) => node.sortableInfo.index == index,
2832
);
2933
}
3034

31-
getIndex(collection, ref) {
35+
findIndex(collection, ref) {
3236
return this.refs[collection].indexOf(ref);
3337
}
3438

src/SortableContainer/index.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,6 @@ export default function sortableContainer(
267267
left: this.scrollContainer.scrollLeft,
268268
top: this.scrollContainer.scrollTop,
269269
};
270-
271270
this.initialWindowScroll = {
272271
left: window.pageXOffset,
273272
top: window.pageYOffset,
@@ -673,22 +672,17 @@ export default function sortableContainer(
673672
return new Promise((resolve) => {
674673
const {dropAnimationDuration, dropAnimationEasing} = this.props;
675674
const {containerScrollDelta, windowScrollDelta} = this;
676-
const nodes = this.manager.getRefs();
677-
const {edgeOffset: oldOffset, node: oldNode} = nodes[this.index];
678-
const {edgeOffset: newOffset, node: newNode} = nodes[this.newIndex];
675+
const oldOffset = this.offsetEdge;
676+
const {edgeOffset: newOffset, node: newNode} = this.manager.nodeAtIndex(
677+
this.newIndex,
678+
);
679679
const deltaX =
680680
this.newIndex > this.index
681-
? newOffset.left -
682-
oldNode.offsetWidth +
683-
newNode.offsetWidth -
684-
oldOffset.left
681+
? newOffset.left - this.width + newNode.offsetWidth - oldOffset.left
685682
: newOffset.left - oldOffset.left;
686683
const deltaY =
687684
this.newIndex > this.index
688-
? newOffset.top -
689-
oldNode.offsetHeight +
690-
newNode.offsetHeight -
691-
oldOffset.top
685+
? newOffset.top - this.height + newNode.offsetHeight - oldOffset.top
692686
: newOffset.top - oldOffset.top;
693687

694688
setTranslate3d(this.helper, {

0 commit comments

Comments
 (0)