prevent zooming out further than the whole canvas

This commit is contained in:
ophir 2021-01-10 20:22:46 +01:00
parent 69db0af4c2
commit a10347695b

View file

@ -451,8 +451,11 @@ Tools.messageHooks = [resizeCanvas, updateUnreadCount];
Tools.scale = 1.0;
var scaleTimeout = null;
Tools.setScale = function setScale(scale) {
var fullScale = Math.max(window.innerWidth, window.innerHeight) / Tools.server_config.MAX_BOARD_SIZE;
var minScale = Math.max(0.1, fullScale);
var maxScale = 10;
if (isNaN(scale)) scale = 1;
scale = Math.max(0.1, Math.min(10, scale));
scale = Math.max(minScale, Math.min(maxScale, scale));
Tools.svg.style.willChange = 'transform';
Tools.svg.style.transform = 'scale(' + scale + ')';
clearTimeout(scaleTimeout);