Ng2-pdf-viewer: How to disable scroll on page change?

Created on 1 Apr 2019  路  8Comments  路  Source: VadimDez/ng2-pdf-viewer

Bug Report or Feature Request (mark with an x)
- [ ] Regression (a behavior that used to work and stopped working in a new release)
- [X ] Bug report -> please search issues before submitting
- [ ] Feature request
- [ ] Documentation issue or request

Every time I change a page, it automatically scroll to the begining document. Is there any way to disable it?

Here is my code:

<pdf-viewer [src]="pdfObj.url" [show-all]="false" [stick-to-page]="flase" [(page)]="currentPDFPage" [original-size]="false" style="display: block;" [rotation]="rotation" [zoom]="zoom" (error)="onError($event)" (after-load-complete)="afterLoadComplete($event)"> </pdf-viewer>

Most helpful comment

Hey there! I still have this problem. How I suppose to disable the scroll on top when page changes? Using [stick-to-page]="false"? I can't make it work..
As workaround, for now I've commented this portion of code

_get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollIntoView", this).call(this, {
        pageDiv: pageDiv,
        pageSpot: pageSpot,
        pageNumber: pageNumber
      });

in node_modules/pdfjs-dist/web/pdf_viewer.js (Ln 6336)

All 8 comments

I want to know how to solve that issue too.

You can don't set the [page] by removing [(page)]="currentPDFPage"?

Hi, same issue for me, any news about this problem ?

Also an issue for me. If I am navigating from page to page, my Next and Previous button move out of the visible screen when it snaps to the viewer.

Please anybody have a solution for this issue.
Is very unconfortable and if you ut some logos in the head of the page hide them.
This scroll must be an optional feature in properties and no forced always

Hey there! I still have this problem. How I suppose to disable the scroll on top when page changes? Using [stick-to-page]="false"? I can't make it work..
As workaround, for now I've commented this portion of code

_get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollIntoView", this).call(this, {
        pageDiv: pageDiv,
        pageSpot: pageSpot,
        pageNumber: pageNumber
      });

in node_modules/pdfjs-dist/web/pdf_viewer.js (Ln 6336)

I have found a workaround that doesn't involve directly changing the pdfjs module. So what you need to do is to capture on your component the PdfViewerComponent. Then you can access the pdfviewer and inside there is an object call scroll.down and you can set it to false. And that's it you will no longer have scrolling when changing pages.

Angular Component

```
@ViewChild(PdfViewerComponent, { static: false })
private pdfComponent: PdfViewerComponent;

initLoadCompleted(pdf: PDFDocumentProxy): void {
this.pdfComponent.pdfViewer.scroll.down = false;
}

**HTML**

[src]="pdfData" (after-load-complete)="initLoadCompleted($event)"
[render-text]="true"
[page]="currentPage"
[show-all]="false">

```

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Vigneshjana picture Vigneshjana  路  3Comments

viktorhajer picture viktorhajer  路  7Comments

sabarinathancs picture sabarinathancs  路  4Comments

roginneil picture roginneil  路  3Comments

kevinariasf picture kevinariasf  路  6Comments