panzoom
panzoom copied to clipboard
add helper functions moveToCenterOfElement and moveToCenterOfBounds
const DOMElemRef = document.querySelector('.some-element')
moveToCenterOfElement(DOMElemRef) // moves viewport to the center of this element
const elemBounds = document.querySelector('.some-element').getBoundingClientRect()
moveToCenterOfBounds(elemBounds) // moves viewport to the center of this bounding box
moveToCenterOfBounds is useful to have separately so you can pass just the bounding box around. Or make your own one without having to use HTML, eg moveToCenterOfBounds({ left: 0, top: 0, width: 100, height: 100 })
@anvaka This is very helpful. Any chance it can be merged?