yagni mm? [skip ci]

This commit is contained in:
Benjamin Lu
2025-09-06 21:05:05 -07:00
parent 8b5c7ffb60
commit aecbdced12

View File

@@ -11,8 +11,6 @@
import { useElementBounding } from '@vueuse/core'
import { shallowRef, watch } from 'vue'
type Rect = DOMRectReadOnly
// Target container element (covers the canvas fully and shares its origin)
const containerRef = shallowRef<HTMLElement | null>(null)
@@ -42,25 +40,12 @@ watch([x, y, width, height], () => {
if (listeners.size) listeners.forEach((cb) => cb())
})
export function invalidate(notify = false) {
if (notify && listeners.size) listeners.forEach((cb) => cb())
}
export function onCanvasRectChange(cb: () => void): () => void {
ensureContainer()
listeners.add(cb)
return () => listeners.delete(cb)
}
export function getCanvasRect(): Rect {
ensureContainer()
const lx = x.value || 0
const ly = y.value || 0
const w = width.value || 0
const h = height.value || 0
return new DOMRect(lx, ly, w, h)
}
export function getCanvasClientOrigin() {
ensureContainer()
return { left: x.value || 0, top: y.value || 0 }