Skip to content

Commit

Permalink
* dtable: refactor mousemove plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
catouse committed Oct 18, 2024
1 parent f95170a commit b73d409
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/dtable/src/plugins/mousemove/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,30 @@ const mousemovePlugin: DTablePlugin<DTableMousemoveTypes> = {
mousemove(event) {
if (this.data.mmRafID) {
cancelAnimationFrame(this.data.mmRafID);
this.data.mmRafID = 0;
}

this.data.mmRafID = requestAnimationFrame(() => {
this.emitCustomEvent('mousemovesmooth', event);
this.data.mmRafID = 0;
});
event.preventDefault();
},
document_mousemove(event) {
if (this.data.dmmRafID) {
cancelAnimationFrame(this.data.dmmRafID);
this.data.dmmRafID = 0;
}

this.data.dmmRafID = requestAnimationFrame(() => {
this.emitCustomEvent('document_mousemovesmooth', event);
this.data.mmRafID = 0;
});
},
},
methods: {
ignoreNextClick(timeout = 10) {
if (this.data.ignoreNextClick) {
clearTimeout(this.data.ignoreNextClick);
}
this.data.ignoreNextClick = window.setTimeout(() => {
this.data.ignoreNextClick = undefined;
}, timeout);
Expand Down

0 comments on commit b73d409

Please sign in to comment.