mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-22 06:37:56 +01:00
Add delay on load.
This commit is contained in:
parent
046215898e
commit
fa5def64ca
@ -37,7 +37,7 @@ class Workspace {
|
|||||||
|
|
||||||
private _renderQueue: Element2D[];
|
private _renderQueue: Element2D[];
|
||||||
|
|
||||||
private queueRenderEnabled: boolean;
|
private _queueRenderEnabled: boolean;
|
||||||
|
|
||||||
constructor(screenManager: ScreenManager, zoom: number, isReadOnly: boolean) {
|
constructor(screenManager: ScreenManager, zoom: number, isReadOnly: boolean) {
|
||||||
// Create a suitable container ...
|
// Create a suitable container ...
|
||||||
@ -103,7 +103,7 @@ class Workspace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
append(shape: Element2D): void {
|
append(shape: Element2D): void {
|
||||||
if (this.queueRenderEnabled) {
|
if (this._queueRenderEnabled) {
|
||||||
this._renderQueue.push(shape);
|
this._renderQueue.push(shape);
|
||||||
} else {
|
} else {
|
||||||
this.appendInternal(shape);
|
this.appendInternal(shape);
|
||||||
@ -119,20 +119,23 @@ class Workspace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enableQueueRender(value: boolean): Promise<void> {
|
enableQueueRender(value: boolean): Promise<void> {
|
||||||
this.queueRenderEnabled = value;
|
this._queueRenderEnabled = value;
|
||||||
|
|
||||||
let result = Promise.resolve();
|
let result = Promise.resolve();
|
||||||
if (!value) {
|
if (!value) {
|
||||||
result = this.processRenderQueue(this._renderQueue.reverse(), 300);
|
// eslint-disable-next-line arrow-body-style
|
||||||
|
result = Workspace.delay(100).then(() => {
|
||||||
|
return this.processRenderQueue(this._renderQueue.reverse(), 300);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private processRenderQueue(renderQueue: Element2D[], batch: number): Promise<void> {
|
private static delay(t: number) {
|
||||||
function delay(t: number) {
|
return new Promise((resolve) => setTimeout(resolve, t));
|
||||||
return new Promise((resolve) => setTimeout(resolve, t));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
private processRenderQueue(renderQueue: Element2D[], batch: number): Promise<void> {
|
||||||
let result: Promise<void>;
|
let result: Promise<void>;
|
||||||
if (renderQueue.length > 0) {
|
if (renderQueue.length > 0) {
|
||||||
result = new Promise((resolve: (queue: Element2D[]) => void) => {
|
result = new Promise((resolve: (queue: Element2D[]) => void) => {
|
||||||
@ -142,7 +145,7 @@ class Workspace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
resolve(renderQueue);
|
resolve(renderQueue);
|
||||||
}).then((queue) => delay(30).then(() => this.processRenderQueue(queue, batch)));
|
}).then((queue) => Workspace.delay(30).then(() => this.processRenderQueue(queue, batch)));
|
||||||
} else {
|
} else {
|
||||||
result = Promise.resolve();
|
result = Promise.resolve();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user