PDF.js viewer pinch to zoom

Jordan picture Jordan · Aug 12, 2014 · Viewed 11.7k times · Source

I'm using PDF.js for rendering my documents on a web app I'm working on.

However I need to enable pinch to zoom on mobile devices for this and it doesn't look like the library itself allows native zooming.

Is there a library that I could use to the code to simulate (at the very least) pinch and zoom on the same scale as the viewers dropdown zoom selection?

Answer

Jordan picture Jordan · Jan 26, 2015

I had found an answer to this solution. I ended up using hammer.js for the pdf.js

http://hammerjs.github.io/

edit

var mc = new Hammer.Manager(myElement, myOptions);

mc.add( new Hammer.Pan({ direction: Hammer.DIRECTION_ALL, threshold: 0 }) );
mc.add( new Hammer.Tap({ event: 'quadrupletap', taps: 4 }) );

mc.on("pan", handlePan);
mc.on("quadrupletap", handleTaps);