kopia lustrzana https://github.com/Tldraw/Tldraw
Fix an issue with minimap.
rodzic
e03328faf3
commit
d33ea078f4
|
@ -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])
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue