panzoom icon indicating copy to clipboard operation
panzoom copied to clipboard

add helper functions moveToCenterOfElement and moveToCenterOfBounds

Open Illyism opened this issue 5 years ago • 1 comments

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

Illyism avatar Apr 02 '19 23:04 Illyism

@anvaka This is very helpful. Any chance it can be merged?

savtwo avatar Aug 31 '20 22:08 savtwo