From eaacfec566f7f353f7b05ce5f3de419b33d7197a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Finn=20B=C3=B6ger?= Date: Thu, 7 May 2020 18:25:55 +0200 Subject: [PATCH] set dimensions of board container to actual dimensions of canvas to ensure scroll bars work correctly --- client-data/board.css | 4 ++++ client-data/js/board.js | 14 +++++++++++--- client-data/tools/zoom/zoom.js | 1 + 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/client-data/board.css b/client-data/board.css index efd41894..12a5ab44 100644 --- a/client-data/board.css +++ b/client-data/board.css @@ -4,6 +4,10 @@ html, body, svg { font-family: Liberation sans, sans-serif; } +#board { + overflow: hidden; +} + #canvas { transform-origin: 0 0; } diff --git a/client-data/js/board.js b/client-data/js/board.js index e29c1811..864dc77f 100644 --- a/client-data/js/board.js +++ b/client-data/js/board.js @@ -377,7 +377,7 @@ function updateDocumentTitle() { //List of hook functions that will be applied to messages before sending or drawing them function resizeCanvas(m) { //Enlarge the canvas whenever something is drawn near its border - var x = m.x | 0, y = m.y | 0 + var x = m.x | 0, y = m.y | 0; var MAX_BOARD_SIZE = 65536; // Maximum value for any x or y on the board if (x > Tools.svg.width.baseVal.value - 2000) { Tools.svg.width.baseVal.value = Math.min(x + 2000, MAX_BOARD_SIZE); @@ -385,6 +385,14 @@ function resizeCanvas(m) { if (y > Tools.svg.height.baseVal.value - 2000) { Tools.svg.height.baseVal.value = Math.min(y + 2000, MAX_BOARD_SIZE); } + resizeBoard(); +} + +function resizeBoard() { + // Update board container size + var board = document.getElementById("board"); + board.style.width = Tools.svg.width.baseVal.value * Tools.getScale() + "px"; + board.style.height = Tools.svg.height.baseVal.value * Tools.getScale() + "px"; } function updateUnreadCount(m) { @@ -408,10 +416,10 @@ Tools.setScale = function setScale(scale) { }, 1000); Tools.scale = scale; return scale; -} +}; Tools.getScale = function getScale() { return Tools.scale; -} +}; //List of hook functions that will be applied to tools before adding them Tools.toolHooks = [ diff --git a/client-data/tools/zoom/zoom.js b/client-data/tools/zoom/zoom.js index aee6052e..d61de72d 100644 --- a/client-data/tools/zoom/zoom.js +++ b/client-data/tools/zoom/zoom.js @@ -43,6 +43,7 @@ origin.scrollX + origin.x * (newScale - oldScale), origin.scrollY + origin.y * (newScale - oldScale) ); + resizeBoard(); } var animation = null;