Skip to content

Commit

Permalink
fix: dragging past the bottom of the tree no longer slows down rendering
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
fritz-c committed Dec 9, 2017
1 parent 9c3524f commit 3ce35f3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/react-sortable-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,14 @@ class ReactSortableTree extends Component {
depth: draggedDepth,
minimumTreeIndex: draggedMinimumTreeIndex,
}) {
// Ignore this hover if it is at the same position as the last hover
if (
this.state.draggedDepth === draggedDepth &&
this.state.draggedMinimumTreeIndex === draggedMinimumTreeIndex
) {
return;
}

// Fall back to the tree data if something is being dragged in from
// an external element
const draggingTreeData = this.state.draggingTreeData || this.props.treeData;
Expand Down

0 comments on commit 3ce35f3

Please sign in to comment.