Skip to content

Commit 266f459

Browse files
committed
fix: fix removeEventListener
1 parent 82eaa46 commit 266f459

File tree

1 file changed

+11
-8
lines changed
  • packages/frontendmu-nuxt/components/inspira

1 file changed

+11
-8
lines changed

packages/frontendmu-nuxt/components/inspira/Vortex.vue

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -212,19 +212,22 @@ function renderToScreen(canvas: HTMLCanvasElement, ctx: CanvasRenderingContext2D
212212
ctx.restore()
213213
}
214214
215+
function handleResize() {
216+
const canvas = canvasRef.value
217+
const ctx = canvas?.getContext('2d')
218+
219+
if (canvas && ctx) {
220+
resize(canvas, ctx)
221+
}
222+
}
223+
215224
onMounted(() => {
216225
setup()
217-
window.addEventListener('resize', () => {
218-
const canvas = canvasRef.value
219-
const ctx = canvas?.getContext('2d')
220-
if (canvas && ctx) {
221-
resize(canvas, ctx)
222-
}
223-
})
226+
window.addEventListener('resize', handleResize)
224227
})
225228
226229
onUnmounted(() => {
227-
window.removeEventListener('resize', () => { })
230+
window.removeEventListener('resize', handleResize)
228231
})
229232
</script>
230233

0 commit comments

Comments
 (0)