do history updates less ofte
This commit is contained in:
parent
bf23d0a390
commit
898af135fa
|
@ -103,6 +103,7 @@ class PixelPlainterControls {
|
||||||
document.activeElement.blur();
|
document.activeElement.blur();
|
||||||
|
|
||||||
if (event.button === 0) {
|
if (event.button === 0) {
|
||||||
|
clearTimeout(this.onViewFinishChangeTimeOut);
|
||||||
this.isClicking = true;
|
this.isClicking = true;
|
||||||
const { clientX, clientY } = event;
|
const { clientX, clientY } = event;
|
||||||
this.clickTapStartTime = Date.now();
|
this.clickTapStartTime = Date.now();
|
||||||
|
@ -117,13 +118,16 @@ class PixelPlainterControls {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* try to avoid updating history too often
|
||||||
|
*/
|
||||||
scheduleOnViewFinishChange() {
|
scheduleOnViewFinishChange() {
|
||||||
if (this.onViewFinishChangeTimeOut) {
|
if (this.onViewFinishChangeTimeOut) {
|
||||||
clearTimeout(this.onViewFinishChangeTimeOut);
|
clearTimeout(this.onViewFinishChangeTimeOut);
|
||||||
}
|
}
|
||||||
this.onViewFinishChangeTimeOut = setTimeout(() => {
|
this.onViewFinishChangeTimeOut = setTimeout(() => {
|
||||||
this.store.dispatch(onViewFinishChange());
|
this.store.dispatch(onViewFinishChange());
|
||||||
}, 250);
|
}, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
onMouseUp(event) {
|
onMouseUp(event) {
|
||||||
|
@ -155,7 +159,7 @@ class PixelPlainterControls {
|
||||||
}
|
}
|
||||||
this.viewport.style.cursor = 'auto';
|
this.viewport.style.cursor = 'auto';
|
||||||
}
|
}
|
||||||
store.dispatch(onViewFinishChange());
|
this.scheduleOnViewFinishChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
static getTouchCenter(event) {
|
static getTouchCenter(event) {
|
||||||
|
@ -267,6 +271,7 @@ class PixelPlainterControls {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
document.activeElement.blur();
|
document.activeElement.blur();
|
||||||
|
|
||||||
|
clearTimeout(this.onViewFinishChangeTimeOut);
|
||||||
this.clickTapStartTime = Date.now();
|
this.clickTapStartTime = Date.now();
|
||||||
this.clickTapStartCoords = PixelPlainterControls.getTouchCenter(event);
|
this.clickTapStartCoords = PixelPlainterControls.getTouchCenter(event);
|
||||||
const state = this.store.getState();
|
const state = this.store.getState();
|
||||||
|
@ -324,7 +329,7 @@ class PixelPlainterControls {
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
store.dispatch(onViewFinishChange());
|
this.scheduleOnViewFinishChange();
|
||||||
this.clearTabTimeout();
|
this.clearTabTimeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ import SocketServer from './socket/SocketServer';
|
||||||
import APISocketServer from './socket/APISocketServer';
|
import APISocketServer from './socket/APISocketServer';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
PORT, HOST, HOURLY_EVENT, SHARD_NAME,
|
PORT, HOST, HOURLY_EVENT,
|
||||||
} from './core/config';
|
} from './core/config';
|
||||||
import { SECOND } from './core/constants';
|
import { SECOND } from './core/constants';
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user