What method/event will tell me when the PDF is scrolling?

I’m using the latest version of Webviewer. No server. I just load a PDF. It works fine.

I would like a javascript function called when the user starts and stops scrolling/panning/zooming the PDF. Is this possible? Like whenever the mobile device is panning the PDF pages up or down or whatever, I’d like to set a variable on/off while it happens. Any idea?

Hello,
You can achieve this by first obtaining the scroll view element and then attaching an event listener for the ‘scroll’ event. To detect when a user stops scrolling, you can utilize the setTimeout method within the event listener.
The following code snippet should work for scrolling, zooming and panning.

  const { documentViewer } = instance.Core;
  const pdfViewerElement = documentViewer.getScrollViewElement();
  let isScrolling = false; 
  let scrollTimer = null;

  pdfViewerElement.addEventListener('scroll', () => {
    isScrolling = true;
    console.log('scrolling');
    clearTimeout(scrollTimer);

    scrollTimer = setTimeout(() => {
      isScrolling = false;
      console.log('Scrolling stopped');
    }, 150);
  });

Please adjust anything to fit your needs.

Best Regards,
Darian Chen