diff --git a/.husky/pre-commit b/.husky/pre-commit index 6351299..7b3fc5c 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -2,3 +2,4 @@ . "$(dirname "$0")/_/husky.sh" npm --workspace=react-vfx run lint-staged +npm --workspace=@vfx-js/core run lint-staged diff --git a/.husky/pre-publish b/.husky/pre-publish index e269761..cb9e1eb 100644 --- a/.husky/pre-publish +++ b/.husky/pre-publish @@ -2,4 +2,4 @@ . "$(dirname "$0")/_/husky.sh" npm run lint -npm --workspace=react-vfx run build +npm run build diff --git a/packages/vfx-js/src/vfx-player.ts b/packages/vfx-js/src/vfx-player.ts index 7df02c3..dca7b7e 100644 --- a/packages/vfx-js/src/vfx-player.ts +++ b/packages/vfx-js/src/vfx-player.ts @@ -72,6 +72,7 @@ export class VFXPlayer { } destroy(): void { + this.stop(); if (typeof window !== "undefined") { window.removeEventListener("resize", this.#resize); window.removeEventListener("mousemove", this.#mousemove); diff --git a/packages/vfx-js/src/vfx.ts b/packages/vfx-js/src/vfx.ts index 11158c1..84d7306 100644 --- a/packages/vfx-js/src/vfx.ts +++ b/packages/vfx-js/src/vfx.ts @@ -16,6 +16,7 @@ const canvasStyle = { */ export class VFX { #player: VFXPlayer; + #canvas: HTMLCanvasElement; /** * Creates VFX instance and start playing immediately. @@ -29,6 +30,7 @@ export class VFX { canvas.style.setProperty("z-index", opts.zIndex.toString()); } document.body.appendChild(canvas); + this.#canvas = canvas; this.#player = new VFXPlayer(canvas); this.#player.play(); @@ -86,6 +88,7 @@ export class VFX { */ destroy(): void { this.#player.destroy(); + this.#canvas.remove(); } #addImage(element: HTMLImageElement, opts: VFXProps): void {