VadimDez/ng2-pdf-viewer

PDF Viewer Events

senti-lozada opened this issue · 2 comments

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

Would like to ask if there are any events that can be used on tag, I was hoping to use (scroll) event when it has scroll for limited height ex.

<pdf-viewer (scroll)="onScroll($event)" [show-all]="true" [src]="fileBytes" *ngIf="fileBytes" style="width: 100%; height: 100%;" [zoom]="zoom_to">

Thank you,

I also needed the scroll event, this was the solution I used.

on .html

<pdf-viewer (after-load-complete)="listenScroll()" ...otherProps></pdf-viewer>

and on .ts

constructor(
    @Inject(DOCUMENT)
    private document: Document,
    private renderer: Renderer2
  ) { }

  listenScroll(): void {
    const scrollableEl = this.document.querySelector<HTMLDivElement>('.ng2-pdf-viewer-container');

    if (!scrollableEl) { return; }

    this.renderer.listen(scrollableEl, 'scroll', (event: Event) => {
      // do anything
    });
  }

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.