Skip to content

Commit

Permalink
chore(floor-creator): remove obsolete code in floor-creator
Browse files Browse the repository at this point in the history
 Fabric has fixed a bug and we don't need the workaround anymore
  • Loading branch information
Smrtnyk committed Dec 26, 2024
1 parent 0a438e1 commit 52698de
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 19 deletions.
8 changes: 2 additions & 6 deletions packages/floor-creator/src/CanvasHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { FloorEditor } from "./FloorEditor.js";
import type { FabricObject, TFiller } from "fabric";
import { Group } from "fabric";
import { EventEmitter } from "@posva/event-emitter";
import { isEqual, once } from "es-toolkit";
import { delay, isEqual, once } from "es-toolkit";

export interface HistoryState {
width: number;
Expand Down Expand Up @@ -240,9 +240,7 @@ export class CanvasHistory extends EventEmitter<HistoryEvents> {
});

// Additional wait to ensure all object events have fired
await new Promise<void>((resolve) => {
setTimeout(resolve, 0);
});
await delay(0);
} finally {
this.isHistoryProcessing = false;
this.emit("stateChange");
Expand All @@ -253,11 +251,9 @@ export class CanvasHistory extends EventEmitter<HistoryEvents> {
const obj1 = JSON.parse(json1);
const obj2 = JSON.parse(json2);

// Normalize the objects by removing irrelevant properties
const objects1 = CanvasHistory.normalize(obj1.objects);
const objects2 = CanvasHistory.normalize(obj2.objects);

// Compare the normalized objects
return isEqual(objects1, objects2);
}
}
12 changes: 0 additions & 12 deletions packages/floor-creator/src/FloorViewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,6 @@ export class FloorViewer extends Floor {
this.eventManager.destroy();
this.zoomManager.destroy();
this.touchManager.destroy();
// This is an ugly hack to work around the fact that fabric does not clear the mouseDownTimeout
// during dispose. This causes an exception to be thrown if the canvas is disposed while the mouse
// is down. Reported this issue https://github.com/fabricjs/fabric.js/issues/10248
// @ts-expect-error -- private property
// eslint-disable-next-line no-underscore-dangle -- fabric naming
const mouseDownTimeout = this.canvas._willAddMouseDown;
if (mouseDownTimeout) {
clearTimeout(mouseDownTimeout);
// @ts-expect-error -- private property
// eslint-disable-next-line no-underscore-dangle -- fabric naming
this.canvas._willAddMouseDown = 0;
}
await this.canvas.dispose();
}

Expand Down
1 change: 0 additions & 1 deletion packages/floor-creator/src/TouchManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export class TouchManager {
const pinch = new Pinch({ enable: true, direction: DIRECTION_ALL });
const pan = new Pan({ direction: DIRECTION_ALL, threshold: 50 });

// Add the recognizers to the hammerManager instance
this.hammerManager.add([pinch, pan, doubleTap]);

this.hammerManager.on("pinch", this.onPinch);
Expand Down

0 comments on commit 52698de

Please sign in to comment.