Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any possible way to implement pinch & zoom function in the container canvas? #22

Closed
nessgor opened this issue Oct 14, 2016 · 21 comments

Comments

@nessgor
Copy link

nessgor commented Oct 14, 2016

For example using hammer.js?

http://hammerjs.github.io/

VadimDez added a commit that referenced this issue Oct 15, 2016
@VadimDez VadimDez added this to the 0.0.13 milestone Oct 15, 2016
@VadimDez VadimDez self-assigned this Oct 15, 2016
VadimDez added a commit that referenced this issue Oct 15, 2016
@VadimDez VadimDez modified the milestone: 0.0.13 Nov 1, 2016
@nsuhanshetty
Copy link

Looking forward to this feature, as I am applying this to a mobile app.

@VadimDez VadimDez removed this from the 0.0.13 milestone Nov 22, 2016
@liangwenzhong
Copy link

+1

@michaeljcoyne
Copy link

Any news on this? I can't use this without pinch zoom.

@jjacobs33589
Copy link

I also am looking for this

@SaeedSyedAli96
Copy link

Anyone Implemented this? Help needed!

@tabirkeland
Copy link

I implemented this in Ionic 3.9.2 in a modal. Here is a Gist to show how to implement.

@jtcrowson
Copy link

@tabirkeland That's with buttons though. What about the pinch gesture?

@tabirkeland
Copy link

@jtcrowson I have not had the chance to try it which pinch.

You could try using the "pinch" gesture outlined here and calling the zoomIn() and zoomOut() functions depending on user input.

@jtcrowson
Copy link

Biggest issue with using a gesture framework (like hammer.js) on the ng2-pdf-viewer is that it disables touch scrolling.

@sattip
Copy link

sattip commented May 9, 2018

Any luck?

@woutervddn
Copy link

waiting for this as well, tried to get it to work myself but no luck... :(

@jtcrowson
Copy link

I got it to work with pinch (although it's not very smooth), but couldn't get scroll to work with it.

@wnabil
Copy link

wnabil commented May 20, 2018

using hammerjs it is something like that

const container: HTMLElement = document.getElementById('pdf-file-container');

const hammer = new Hammer(container, {
  domEvents: true
});

hammer.get('pinch').set({
  enable: true
});

hammer.on('pinchend', (event: any) => {
  // get the current zoom value
  let zoom = this.currentZoom;
  // get the scaled amount
  const scale = zoom * event.scale / 10;
  // if the user is zooming in
  if (event.additionalEvent === 'pinchout') {
    zoom += scale;
  } else {
    // if zooming out
    zoom -= scale * 10;
  }

  // if zoom is too small or too big set them to max values
  if (zoom < 1) {
    zoom = 1;
  } else if (zoom > 2) {
    zoom = 2;
  }

  // set the current zoom
  this.currentZoom = zoom;
});

i am not sure if there is a better way but this works fine currently

@hitmacreed
Copy link

hitmacreed commented Oct 25, 2018

for ionic 3 users here i found an work arround

@cxw13424219787
Copy link

using ngx-pinch-zoom, specific query google

@cxw13424219787
Copy link

  <pinch-zoom>
    <div class="oat-pdf-container">
      <pdf-viewer [src]="pdfSrc"
        [autoresize]="true" 
        [original-size]="false"
        [show-all]="true"
        [zoom]="currentZoom"
        style="display: block;"
      ></pdf-viewer>
    </div>
  </pinch-zoom>

@stale
Copy link

stale bot commented Jul 31, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jul 31, 2020
@stale stale bot closed this as completed Aug 30, 2020
@dipankarmondal
Copy link

any one able to do this?

@cxw13424219787
Copy link

cxw13424219787 commented May 11, 2023 via email

@vikaskandari
Copy link

Thanks to @cxw13424219787 the solution works perfectly for angular now here are some additional information and resources :-

Angular 18+ support of ngx-pinch-zoom its fork as orignal one is outdated
https://www.npmjs.com/package/@meddv/ngx-pinch-zoom

npm i @meddv/ngx-pinch-zoom

Html Code

<pinch-zoom>
      <div  [style.height.px]="500" [style.width.%]="100">
        <pdf-viewer 
             [src]="'https://vadimdez.github.io/ng2-pdf-viewer/assets/pdf-test.pdf'" 
             [render-text]="true" 
             [original-size]="false" 
            [style.height.px]="500">
         </pdf-viewer>
      </div>
    </pinch-zoom>

Make sure to give a height on pdf-viewer and its parent element otherwise it won't show.

i have tested it and works perfectly without any issues with angular 18.

@cxw13424219787
Copy link

cxw13424219787 commented Oct 19, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests