From 307f65b9c0b4216006d49b03ecafddc51934edae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mitja=20Bezen=C5=A1ek?= Date: Fri, 26 Apr 2024 13:50:37 +0200 Subject: [PATCH] Use allowed bounds. --- .../src/lib/ui/components/Minimap/DefaultMinimap.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/tldraw/src/lib/ui/components/Minimap/DefaultMinimap.tsx b/packages/tldraw/src/lib/ui/components/Minimap/DefaultMinimap.tsx index 18cace632..fc898ec8c 100644 --- a/packages/tldraw/src/lib/ui/components/Minimap/DefaultMinimap.tsx +++ b/packages/tldraw/src/lib/ui/components/Minimap/DefaultMinimap.tsx @@ -1,5 +1,6 @@ import { ANIMATION_MEDIUM_MS, + Box, TLPointerEventInfo, Vec, getPointerInfo, @@ -74,9 +75,15 @@ export function DefaultMinimap() { const _vpPageBounds = editor.getViewportPageBounds() const commonBounds = minimapRef.current.getContentPageBounds() + const allowedBounds = new Box( + commonBounds.x - _vpPageBounds.width / 2, + commonBounds.y - _vpPageBounds.height / 2, + commonBounds.width + _vpPageBounds.width, + commonBounds.height + _vpPageBounds.height + ) // If we clicked inside of the allowed area, but outside of the viewport - if (commonBounds.containsPoint(point) && !_vpPageBounds.containsPoint(point)) { + if (allowedBounds.containsPoint(point) && !_vpPageBounds.containsPoint(point)) { minimapRef.current.isInViewport = _vpPageBounds.containsPoint(point) const delta = Vec.Sub(_vpPageBounds.center, _vpPageBounds.point) const pagePoint = Vec.Add(point, delta)