From b40fd6540442fae9ca0c28f7e2136a6342e1d643 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arno=C5=A1t=20Pleskot?= Date: Mon, 18 Sep 2023 15:00:52 +0200 Subject: [PATCH] feat: fix overscroll animation trigger when zoomed in --- src/scene/scrollConstraints.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/scene/scrollConstraints.ts b/src/scene/scrollConstraints.ts index a0497170d4..940ca9f9ea 100644 --- a/src/scene/scrollConstraints.ts +++ b/src/scene/scrollConstraints.ts @@ -294,13 +294,19 @@ const isViewportOutsideOfConstrainedArea = (state: AppState) => { const { scrollX, scrollY, width, height, scrollConstraints, zoom } = state; + // Adjust scroll and dimensions according to the zoom level + const adjustedScrollX = scrollX * zoom.value; + const adjustedScrollY = scrollY * zoom.value; + const adjustedWidth = width / zoom.value; + const adjustedHeight = height / zoom.value; + return ( - scrollX > scrollConstraints.x || - scrollX - width < - scrollConstraints.x - scrollConstraints.width * zoom.value || - scrollY > scrollConstraints.y || - scrollY - height < - scrollConstraints.y - scrollConstraints.height * zoom.value + adjustedScrollX > scrollConstraints.x || + adjustedScrollX - adjustedWidth < + scrollConstraints.x - scrollConstraints.width || + adjustedScrollY > scrollConstraints.y || + adjustedScrollY - adjustedHeight < + scrollConstraints.y - scrollConstraints.height ); };