panzoom icon indicating copy to clipboard operation
panzoom copied to clipboard

Adding zoom in/zoom out and reset buttons

Open jonathonberlin opened this issue 5 years ago • 3 comments

Hi there,

Love this library. I'd like to combine this with a Zoom in/Zoom out and Reset button.

Do you know of any examples of this type of functionality?

I found buttons here that I was able to implement here: https://stackoverflow.com/questions/47635341/zooming-in-out-an-image-by-clicking-zoom-buttons-javascript

This is built on a different library: dragscroll. This library doesn't appear to have the mobile functionality I'm looking for.

Thank you!

Jonathon

jonathonberlin avatar Jan 27 '20 15:01 jonathonberlin

I found this: https://jsfiddle.net/1esrkvmz/

And this: https://github.com/anvaka/panzoom/issues/69

So I'm good. Haha!

jonathonberlin avatar Jan 28 '20 15:01 jonathonberlin

How do I get that JS Fiddle example https://jsfiddle.net/1esrkvmz/ working with zoomAbs?

When I try to chain .zoomAbs like this

var newArea = panzoom(area, {
  zoomSpeed: 0.2,
  maxZoom: 4,
  minZoom: 0.1,
}).zoomAbs(
  x, // initial x position
  y, // initial y position
  1  // initial zoom
);

I get the error 'newArea is not defined', but without .zoomAbs it works fine.

kevgibs avatar Jun 11 '20 16:06 kevgibs

Scratch that, digging around on #69 I found this

newArea.zoomAbs(x, y, 1);

kevgibs avatar Jun 11 '20 16:06 kevgibs