From 54fd4c587df4a94534bf88d139706bcc37863391 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mitja=20Bezen=C5=A1ek?= Date: Fri, 26 Apr 2024 13:30:28 +0200 Subject: [PATCH] Keep the same logic of isInViewport. --- .../lib/ui/components/Minimap/DefaultMinimap.tsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/tldraw/src/lib/ui/components/Minimap/DefaultMinimap.tsx b/packages/tldraw/src/lib/ui/components/Minimap/DefaultMinimap.tsx index b4ae1b01d..78117534e 100644 --- a/packages/tldraw/src/lib/ui/components/Minimap/DefaultMinimap.tsx +++ b/packages/tldraw/src/lib/ui/components/Minimap/DefaultMinimap.tsx @@ -75,23 +75,23 @@ export function DefaultMinimap() { const _vpPageBounds = editor.getViewportPageBounds() - minimapRef.current.isInViewport = _vpPageBounds.containsPoint(point) + const clampedPoint = minimapRef.current.minimapScreenPointToPagePoint( + e.clientX, + e.clientY, + false, + true + ) + minimapRef.current.isInViewport = _vpPageBounds.containsPoint(clampedPoint) const commonBounds = Box.Common([editor.getCurrentPageBounds() ?? new Box(), _vpPageBounds]) // If we clicked inside of the allowed area, but outside of the viewport, we wish to move the camera - if (commonBounds.containsPoint(point) && !minimapRef.current.isInViewport) { + if (commonBounds.containsPoint(point) && !_vpPageBounds.containsPoint(point)) { const delta = Vec.Sub(_vpPageBounds.center, _vpPageBounds.point) const pagePoint = Vec.Add(point, delta) minimapRef.current.originPagePoint.setTo(pagePoint) minimapRef.current.originPageCenter.setTo(point) editor.centerOnPoint(point, { duration: ANIMATION_MEDIUM_MS }) } else { - const clampedPoint = minimapRef.current.minimapScreenPointToPagePoint( - e.clientX, - e.clientY, - false, - true - ) minimapRef.current.originPagePoint.setTo(clampedPoint) minimapRef.current.originPageCenter.setTo(_vpPageBounds.center) }