Skip to content

Commit 9f4c0aa

Browse files
AlexAlex
authored andcommitted
force minimum canvas size of 1x1 to avoid crashes
1 parent 0731769 commit 9f4c0aa

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

js/script.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ function placeImage(_image) {
285285
const ctx = canvas.getContext('2d');
286286

287287
// reset canvas size
288-
canvas.width = settings.screenWidth;
289-
canvas.height = settings.screenHeight;
288+
canvas.width = Number.isFinite(settings.screenWidth) && settings.screenWidth > 0 ? settings.screenWidth : 1;
289+
canvas.height = Number.isFinite(settings.screenHeight) && settings.screenHeight > 0 ? settings.screenHeight : 1;
290290
// eslint-disable-next-line no-param-reassign
291291
_image.ctx = ctx;
292292
ctx.save();

0 commit comments

Comments
 (0)