From 0ca756bb863fee7f9bc10dce433583e2afec8c68 Mon Sep 17 00:00:00 2001 From: maazkhan Date: Tue, 9 Sep 2025 11:15:41 +0530 Subject: [PATCH] Fix buffer overflow issue: Clear previous canvas object on window resize --- daisy.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/daisy.js b/daisy.js index 7bb1a10..428162c 100644 --- a/daisy.js +++ b/daisy.js @@ -147,6 +147,15 @@ */ function resizeHandler() { // resize the canvas + + destroy(); + //Create canvas + canvas = document.createElement('canvas'); + canvas.className = 'pg-canvas'; + canvas.style.display = 'block'; + element.insertBefore(canvas, element.firstChild); + ctx = canvas.getContext('2d'); + styleCanvas(); var elWidth = element.offsetWidth; @@ -355,6 +364,7 @@ function destroy() { console.log('destroy'); + particles = []; canvas.parentNode.removeChild(canvas); hook('onDestroy'); if ($) {