From a941056db424bb6062a7e117c18c2380cfab9a26 Mon Sep 17 00:00:00 2001 From: Victor Seiji Hariki Date: Sat, 17 Dec 2022 01:07:02 -0300 Subject: [PATCH] fix viewport location limits Signed-off-by: Victor Seiji Hariki --- js/initalize/layers.populate.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/js/initalize/layers.populate.js b/js/initalize/layers.populate.js index 403a08b..57156b8 100644 --- a/js/initalize/layers.populate.js +++ b/js/initalize/layers.populate.js @@ -269,8 +269,14 @@ mouse.listen.window.btn.middle.onpaint.on((evn) => { viewport.cy = worldInit.y + (evn.iy - evn.y) / viewport.zoom; // Limits - viewport.cx = Math.max(Math.min(viewport.cx, imageCollection.size.w), 0); - viewport.cy = Math.max(Math.min(viewport.cy, imageCollection.size.h), 0); + viewport.cx = Math.max( + Math.min(viewport.cx, imageCollection.size.w - imageCollection.origin.x), + -imageCollection.origin.x + ); + viewport.cy = Math.max( + Math.min(viewport.cy, imageCollection.size.h - imageCollection.origin.y), + -imageCollection.origin.y + ); // Draw Viewport location }