CrazyTim / spin-wheel

An easy to use, themeable component for randomising choices and prizes.
https://crazytim.github.io/spin-wheel/examples/themes
MIT License
174 stars 45 forks source link

Wheel inside a `<dialog>` disappears when resizing the window while the `<dialog>` is closed #42

Closed matronator closed 3 months ago

matronator commented 3 months ago

I have put the wheel inside a <dialog> tag and want it to be visible only when the user clicks a button to show the dialog. However when the dialog is closed, if I resize the window and then open the dialog, the wheel is gone. I have to resize the window again for it to become visible.

I think it might be because the canvas is auto-adjusting its size on resize event, but when the dialog is hidden, it sets its size to 0px by 0px, thus disappearing and only after resizing again with the modal open it sets the correct dimensions for its size.

matronator commented 3 months ago

Okay, after looking at the source code, I found resize() method and if I call that right after I open the dialog, it shows the wheel again. But I didn't find any mention of this method anywhere, so maybe put it in the README?

CrazyTim commented 3 months ago

Duplicate of #26