Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Releases: officient/panzoom

v7.2.0

03 Apr 12:21
b228dd4
Compare
Choose a tag to compare
  • zoomToFullView
  • zoomToCenter
  • moveToCenterOfElement
  • moveToCenterOfBounds

Adds a zoomToCenter function

  • zoomToCenter(1.2) Zooms in by 20%
  • zoomToCenter(0.8) Zooms out by 20%

I wanted more granular control than using the delta -1 or +1 and comparing by zoomSpeed. Especially if using this with a + or - button to zoom it makes sense to have it defined like this.


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



zoomToFullView zooms out or in to show the entire view