Fix an issue with minimap.

pull/3621/head
Mitja Bezenšek 2024-04-26 10:05:11 +02:00
rodzic e03328faf3
commit d33ea078f4
2 zmienionych plików z 6 dodań i 2 usunięć

Wyświetl plik

@ -6,6 +6,7 @@ import {
normalizeWheel,
releasePointerCapture,
setPointerCapture,
useContainer,
useEditor,
useIsDarkMode,
} from '@tldraw/editor'
@ -15,6 +16,7 @@ import { MinimapManager } from './MinimapManager'
/** @public */
export function DefaultMinimap() {
const editor = useEditor()
const container = useContainer()
const rCanvas = React.useRef<HTMLCanvasElement>(null!)
const rPointing = React.useRef(false)
@ -22,7 +24,7 @@ export function DefaultMinimap() {
const minimapRef = React.useRef<MinimapManager>()
React.useEffect(() => {
const minimap = new MinimapManager(editor, rCanvas.current)
const minimap = new MinimapManager(editor, rCanvas.current, container)
minimapRef.current = minimap
return minimapRef.current.close
}, [editor])

Wyświetl plik

@ -21,7 +21,8 @@ export class MinimapManager {
shapeGeometryCache: ComputedCache<Float32Array | null, TLShape>
constructor(
public editor: Editor,
public readonly elem: HTMLCanvasElement
public readonly elem: HTMLCanvasElement,
public readonly container: HTMLElement
) {
this.gl = setupWebGl(elem)
this.shapeGeometryCache = editor.store.createComputedCache('webgl-geometry', (r: TLShape) => {
@ -94,6 +95,7 @@ export class MinimapManager {
this.canvasBoundingClientRect.set(rect)
})
observer.observe(this.elem)
observer.observe(this.container)
return () => observer.disconnect()
}