feat: 去处事件节流 (#1151)

This commit is contained in:
YiQianYao 2022-06-15 15:25:58 +08:00 committed by GitHub
parent 8012a6b7f1
commit 9417a24484
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 13 deletions

View File

@ -46,8 +46,6 @@ export default class PickingService implements IPickingService {
private pickBufferScale: number = 1.0; private pickBufferScale: number = 1.0;
private lastPickTime: number = new Date().getTime();
// Tip: 记录当前拾取中的 layers // Tip: 记录当前拾取中的 layers
private pickedLayers: ILayer[] = []; private pickedLayers: ILayer[] = [];
@ -209,17 +207,7 @@ export default class PickingService implements IPickingService {
return; return;
} }
this.alreadyInPicking = true; this.alreadyInPicking = true;
const t = new Date().getTime();
// TODO: 优化拾取操作 在右键时 mousedown 和 contextmenu 几乎同时触发,所以不能舍去这一次的触发
if (
t - this.lastPickTime > 10 ||
['contextmenu', 'click', 'dblclick', 'mouseup'].includes(target.type)
) {
await this.pickingLayers(target); await this.pickingLayers(target);
}
// await this.pickingLayers(target);
// @ts-ignore
this.lastPickTime = t;
this.layerService.renderLayers(); this.layerService.renderLayers();
this.alreadyInPicking = false; this.alreadyInPicking = false;
} }