Browse Source
fix(p5): Resolve zoom sketch blanking on window resize
fix(p5): Resolve zoom sketch blanking on window resize
The zoom sketch canvas would turn blank after the browser window was resized. The root cause was a race condition between the JavaScript `windowResized` event and the browser's layout rendering. The resize event was triggering the `zoomSketch` to resize its own canvas before its parent container (`#zoom-panel`) had been assigned its new, non-zero dimensions by the layout engine. This resulted in the zoom canvas being recreated with a size of 0x0 pixels. This commit resolves the issue by: 1. In `radarSketch.js`, deferring the resize call for the zoom sketch using `setTimeout`. This pushes the execution to the end of the event loop, giving the browser time to update the container's dimensions first. 2. In `zoomSketch.js`, modifying the `handleResize` function to destroy the old, invalid canvas. The canvas is now correctly recreated with the proper dimensions on the next `updateAndDraw` call (triggered by mouse movement), making the solution robust and independent of specific timings.refactor/modularize
2 changed files with 99 additions and 82 deletions
Write
Preview
Loading…
Cancel
Save
Reference in new issue