Skip to content

Commit 3ce35f3

Browse files
committedDec 9, 2017
fix: dragging past the bottom of the tree no longer slows down rendering
When dragging a node with a visible child to the last row displayed for the tree, a render was triggered for each dragover event, causing significant slowdown. The issue lied in the fact that the child was being perceived as another node with which the dragged node should swap with. The new implementation adds another condition - stopping the rendering short if the previous render used the same drag position (depth and minimum index).
1 parent 9c3524f commit 3ce35f3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed
 

Diff for: ‎src/react-sortable-tree.js

+8
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,14 @@ class ReactSortableTree extends Component {
319319
depth: draggedDepth,
320320
minimumTreeIndex: draggedMinimumTreeIndex,
321321
}) {
322+
// Ignore this hover if it is at the same position as the last hover
323+
if (
324+
this.state.draggedDepth === draggedDepth &&
325+
this.state.draggedMinimumTreeIndex === draggedMinimumTreeIndex
326+
) {
327+
return;
328+
}
329+
322330
// Fall back to the tree data if something is being dragged in from
323331
// an external element
324332
const draggingTreeData = this.state.draggingTreeData || this.props.treeData;

0 commit comments

Comments
 (0)
Please sign in to comment.