mirror of
https://github.com/igorski/bitmappery.git
synced 2026-07-29 02:07:59 +02:00
Scope timeout function onto window object
This commit is contained in:
@@ -48,7 +48,7 @@ export const hasQueue = (): boolean => queueLength() > 0;
|
||||
export const queueLength = (): number => stateQueue.size;
|
||||
|
||||
export const flushQueue = (): void => {
|
||||
clearTimeout( timeout );
|
||||
window.clearTimeout( timeout );
|
||||
stateQueue.clear();
|
||||
};
|
||||
|
||||
@@ -80,13 +80,13 @@ export const enqueueState = ( key: string, undoRedoState: UndoRedoState ): void
|
||||
processQueue();
|
||||
}
|
||||
stateQueue.set( key, undoRedoState );
|
||||
setTimeout( processQueue, ENQUEUE_TIMEOUT );
|
||||
window.setTimeout( processQueue, ENQUEUE_TIMEOUT );
|
||||
};
|
||||
|
||||
/* internal methods */
|
||||
|
||||
function processQueue(): void {
|
||||
clearTimeout( timeout );
|
||||
window.clearTimeout( timeout );
|
||||
stateQueue.forEach( undoRedoState => store.commit( "saveState", undoRedoState ));
|
||||
stateQueue.clear();
|
||||
}
|
||||
|
||||
@@ -425,14 +425,14 @@ class LayerSprite extends ZoomableSprite {
|
||||
}
|
||||
|
||||
debouncePaintStore( timeout: number = 5000 ): void {
|
||||
this._pendingPaintState = setTimeout( this.storePaintState.bind( this ), timeout ) as unknown as number;
|
||||
this._pendingPaintState = window.setTimeout( this.storePaintState.bind( this ), timeout ) as unknown as number;
|
||||
}
|
||||
|
||||
async storePaintState(): Promise<boolean> {
|
||||
if ( !this._pendingPaintState ) {
|
||||
return true;
|
||||
}
|
||||
clearTimeout( this._pendingPaintState );
|
||||
window.clearTimeout( this._pendingPaintState );
|
||||
if ( this._brush.down ) {
|
||||
// still painting, debounce again (layer.source only updated on handleRelease())
|
||||
this.debouncePaintStore( 1000 );
|
||||
|
||||
Reference in New Issue
Block a user