Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c3882a6

Browse files
wombletonwuweiweiwu
authored andcommittedNov 10, 2019
Fix drag hover performance (frontend-collective#503)
* codesandbox relies on version 1.2.XX * only do dragHover work after raf
1 parent 1b66ade commit c3882a6

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed
 

‎package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
"babel-eslint": "^10.0.1",
9696
"babel-jest": "^23.6.0",
9797
"babel-loader": "^8.0.4",
98-
"codesandbox": "^1.2.10",
98+
"codesandbox": "~1.2.10",
9999
"coveralls": "^3.0.1",
100100
"cross-env": "^5.1.6",
101101
"enzyme": "^3.10.0",

‎src/utils/dnd-manager.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,15 @@ export default class DndManager {
232232
return;
233233
}
234234

235-
this.dragHover({
236-
node: draggedNode,
237-
path: monitor.getItem().path,
238-
minimumTreeIndex: dropTargetProps.listIndex,
239-
depth: targetDepth,
235+
// throttle `dragHover` work to available animation frames
236+
cancelAnimationFrame(this.rafId);
237+
this.rafId = requestAnimationFrame(() => {
238+
this.dragHover({
239+
node: draggedNode,
240+
path: monitor.getItem().path,
241+
minimumTreeIndex: dropTargetProps.listIndex,
242+
depth: targetDepth,
243+
});
240244
});
241245
},
242246

0 commit comments

Comments
 (0)
Failed to load comments.