Resizing browser causes dice to not appear
Closed this issue · 4 comments
clevett commented
If you hide the canvas by using hide()
and then resize the browser the world is resized with width and height 0 because of 'display: none'.
This can be fixed by resizing the world after calling .show()
clevett commented
We fixed this on our local fork by doing this:
resizeWorld(resize) {
this.#DiceWorld.resize(resize);
this.#DicePhysics.postMessage({
action: "resize",
...resize,
});
}
show() {
this.canvas.style.display = "block";
this.resizeWorld({
width: this.canvas.clientWidth,
height: this.canvas.clientHeight,
});
// make this method chainable
return this;
}
clevett commented
You should be able to just update show() with the resizeWorld call then it will fix the dice disappearing on resize.
AdventureBeard commented
Just wanted to bump this, as this issue is still present and a fairly critical bug.
marvink commented
Yes especial on mobile devices this issue is a bummer.