VadimDez / ng2-pdf-viewer

📄 PDF Viewer Component for Angular
https://vadimdez.github.io/ng2-pdf-viewer/
MIT License
1.3k stars 418 forks source link

PDF Viewer Events #1024

Open senti-lozada opened 1 year ago

senti-lozada commented 1 year ago
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,

leonardomnds commented 1 year ago

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
    });
  }
stale[bot] commented 8 months ago

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.