Use allowed bounds.

pull/3617/head
Mitja Bezenšek 2024-04-26 13:50:37 +02:00
rodzic bba52623fa
commit 307f65b9c0
1 zmienionych plików z 8 dodań i 1 usunięć

Wyświetl plik

@ -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)