Skip to content

Commit

Permalink
Use the editor.runasync
Browse files Browse the repository at this point in the history
  • Loading branch information
melvsparks committed Aug 12, 2020
1 parent c9f6d24 commit 289614d
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export default class TableResize implements EditorPlugin {
private horizontalResizer: HTMLDivElement;
private verticalResizer: HTMLDivElement;
private resizingState: ResizeState = ResizeState.None;
private resizeTableAnimationFrameID: number;

private currentInsertTd: HTMLTableCellElement;
private insertingState: ResizeState = ResizeState.None;
Expand Down Expand Up @@ -72,6 +71,10 @@ export default class TableResize implements EditorPlugin {
this.editor = null;
}

/**
* Handle events triggered from editor
* @param event PluginEvent object
*/
onPluginEvent(e: PluginEvent) {
switch (e.eventType) {
case PluginEventType.Input:
Expand Down Expand Up @@ -328,7 +331,7 @@ export default class TableResize implements EditorPlugin {
}

private frameAnimateResizeTable = (e: MouseEvent) => {
this.resizeTableAnimationFrameID = requestAnimationFrame(() => this.resizeTable(e));
this.editor.runAsync(() => this.resizeTable(e));
};

private resizeTable = (e: MouseEvent) => {
Expand Down Expand Up @@ -364,7 +367,6 @@ export default class TableResize implements EditorPlugin {
const doc = this.editor.getDocument();
doc.removeEventListener('mousemove', this.frameAnimateResizeTable, true);
doc.removeEventListener('mouseup', this.endResizeTable, true);
cancelAnimationFrame(this.resizeTableAnimationFrameID);

this.editor.addUndoSnapshot((start, end) => {
this.frameAnimateResizeTable(e);
Expand Down

0 comments on commit 289614d

Please sign in to comment.