Skip to content

Commit 54dabff

Browse files
committed
Avoid huge repaint on toggleSortCursor in Sorter. Fixes #595
1 parent 9f44aeb commit 54dabff

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

src/canvas/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,13 @@ module.exports = () => {
351351
this.dragging = 1;
352352
let toListen = this.getScrollListeners();
353353
frameRect = CanvasView.getFrameOffset(1);
354-
on(toListen, 'mousemove', this.autoscroll);
355-
on(toListen, 'mouseup', this.stopAutoscroll);
354+
355+
// By detaching those from the stack avoid browsers lags
356+
// Noticeable with "fast" drag of blocks
357+
setTimeout(() => {
358+
on(toListen, 'mousemove', this.autoscroll);
359+
on(toListen, 'mouseup', this.stopAutoscroll);
360+
}, 0);
356361
},
357362

358363
autoscroll(e) {

src/utils/Sorter.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,25 +89,22 @@ module.exports = Backbone.View.extend({
8989
* @param {Boolean} active
9090
*/
9191
toggleSortCursor(active) {
92-
//console.log('disabled toggleSortCursor');
93-
//return;
9492
var em = this.em;
9593
var body = document.body;
9694
var pfx = this.ppfx || this.pfx;
9795
var sortCls = pfx + 'grabbing';
9896
var emBody = em ? em.get('Canvas').getBody() : '';
99-
if(active) {
97+
98+
// Avoid updating body className as it causes a huge repaint
99+
// Noticeable with "fast" drag of blocks
100+
if (active) {
100101
em && em.get('Canvas').startAutoscroll();
101-
body.className += ' ' + sortCls;
102-
if(em) {
103-
emBody.className += ' ' + sortCls;
104-
}
102+
//body.className += ' ' + sortCls;
103+
//if (em) emBody.className += ' ' + sortCls;
105104
} else {
106105
em && em.get('Canvas').stopAutoscroll();
107-
body.className = body.className.replace(sortCls, '').trim();
108-
if(em) {
109-
emBody.className = emBody.className.replace(sortCls, '').trim();
110-
}
106+
//body.className = body.className.replace(sortCls, '').trim();
107+
//if(em) emBody.className = emBody.className.replace(sortCls, '').trim();
111108
}
112109
},
113110

0 commit comments

Comments
 (0)