fix: core render loop

This commit is contained in:
chenshenhai 2021-06-02 19:01:57 +08:00
parent a2bec8eda9
commit f9b5bbb114
2 changed files with 7 additions and 5 deletions

View file

@ -144,10 +144,9 @@ class Core {
this[_selectedUUID] = uuid;
} else {
const [index] = this[_element].isPointInElement(point, this[_data]);
// console.log('index ===', index);
this.selectElement(index);
}
// console.log('this[_mode] =', this[_mode], point)
this.draw();
}
private _handleMoveStart(point: TypePoint): void {

View file

@ -52,8 +52,11 @@ export class Renderer {
requestAnimationFrame(() => {
// console.log('------ render frame ------', this._loader.isComplete())
let item: QueueItem | undefined = this._queue[0];
let isLastFrame = false;
if (this._queue.length > 1) {
item = this._queue.shift();
} else {
isLastFrame = true;
}
if (this._loader.isComplete() !== true) {
this._drawFrame();
@ -62,13 +65,13 @@ export class Renderer {
drawContext(ctx, item.data, item.helper, this._loader);
this._board.draw();
this._retainQueueOneItem();
if (this._queue.length > 1) {
if (!isLastFrame) {
this._drawFrame();
} else {
this._status = DrawStatus.FREE
this._status = DrawStatus.FREE;
}
} else {
this._status = DrawStatus.FREE
this._status = DrawStatus.FREE;
}
})
}