Skip to content

Commit e894da2

Browse files
authored
Merge pull request #2668 from spamguy/sidebar
Minimize CPU-hungry sidebar drag operations
2 parents edc3ee7 + 30bbedf commit e894da2

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

assets/javascripts/views/layout/resizer.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,20 @@ app.views.Resizer = class Resizer extends app.View {
4444
return;
4545
}
4646
this.lastDragValue = value;
47-
if (this.lastDrag && this.lastDrag > Date.now() - 50) {
47+
if (this.rafPending) {
4848
return;
4949
}
50-
this.lastDrag = Date.now();
51-
this.resize(value, false);
50+
this.rafPending = requestAnimationFrame(() => {
51+
this.rafPending = null;
52+
this.resize(this.lastDragValue, false);
53+
});
5254
}
5355

5456
onDragEnd(event) {
57+
if (this.rafPending) {
58+
cancelAnimationFrame(this.rafPending);
59+
this.rafPending = null;
60+
}
5561
$.off(window, "dragover", this.onDrag);
5662
let value = event.pageX || event.screenX - window.screenX;
5763
if (

0 commit comments

Comments
 (0)