mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-04-06 03:57:56 +08:00
fix: 修复throttle引起的问题
This commit is contained in:
parent
feb9ac9a81
commit
148d4547b0
@ -85,6 +85,13 @@ export default class StageMask extends Rule {
|
||||
private mode: Mode = Mode.ABSOLUTE;
|
||||
private pageResizeObserver: ResizeObserver | null = null;
|
||||
private wrapperResizeObserver: ResizeObserver | null = null;
|
||||
/**
|
||||
* 高亮事件处理函数
|
||||
* @param event 事件对象
|
||||
*/
|
||||
private highlightHandler = throttle((event: MouseEvent): void => {
|
||||
this.emit('highlight', event);
|
||||
}, throttleTime);
|
||||
|
||||
constructor(config: StageMaskConfig) {
|
||||
const wrapper = createWrapper();
|
||||
@ -96,7 +103,7 @@ export default class StageMask extends Rule {
|
||||
this.content.addEventListener('mousedown', this.mouseDownHandler);
|
||||
this.wrapper.appendChild(this.content);
|
||||
this.content.addEventListener('wheel', this.mouseWheelHandler);
|
||||
this.content.addEventListener('mousemove', throttle(this.highlightHandler, throttleTime));
|
||||
this.content.addEventListener('mousemove', this.highlightHandler);
|
||||
}
|
||||
|
||||
public setMode(mode: Mode) {
|
||||
@ -228,7 +235,7 @@ export default class StageMask extends Rule {
|
||||
|
||||
private mouseUpHandler = (): void => {
|
||||
globalThis.document.removeEventListener('mouseup', this.mouseUpHandler);
|
||||
this.content.addEventListener('mousemove', throttle(this.highlightHandler, throttleTime));
|
||||
this.content.addEventListener('mousemove', this.highlightHandler);
|
||||
this.emit('select');
|
||||
};
|
||||
|
||||
@ -271,12 +278,4 @@ export default class StageMask extends Rule {
|
||||
|
||||
this.emit('scroll', event);
|
||||
};
|
||||
|
||||
/**
|
||||
* 高亮事件处理函数
|
||||
* @param event 事件对象
|
||||
*/
|
||||
private highlightHandler = (event: MouseEvent): void => {
|
||||
this.emit('highlight', event);
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user