History

Merge pull request #2668 from spamguy/sidebar

Minimize CPU-hungry sidebar drag operations

Simon Legner committed 7 months agomain

Commit e894da22 parents edc3ee7 30bbedf1 file · +9 −3Browse files

Unified · Split

assets/javascripts/views/layout/resizer.js+9−3
@@ -44,14 +44,20 @@ app.views.Resizer = class Resizer extends app.View { · 43 unmodified lines
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 (