Automatic scrolling when text selecting

Which product are you using?
PDF.js Express Viewer
PDF.js Express Version
Detailed description of issue
Is it possibly to have the page scrolling when the text selection is active, meaning when the user reaches the bottom of the page with the cursor scrolling should happen automatically.

Expected behaviour
When the user reaches the bottom of the page with the cursor a scrolling action should be done until the user releases the left mouse button and the text selection is completed. The aim is to select text on multiple consecutive pages.

Does your issue happen with every document, or just one?
All documents.

Hi there,

Thank you for contacting pdf.js express forums,

We do not have an automatic scrolling effect which holding click, but you could implement something like this using the documentViewer event and methods available:

Here is a prototype:

let active = true;
  documentViewer.addEventListener('mouseMove', (e) => {
    documentViewer.addEventListener('mouseLeftUp', (e) =>{
      active = false;

    const scrollElement = documentViewer.getScrollViewElement();
    const scrollLeft = scrollElement.scrollLeft || 0;
    const scrollTop = scrollElement.scrollTop || 0;

    const coordinate = {
      x: e.pageX + scrollLeft,
      y: e.pageY + scrollTop

    if (active && e.pageY > 500) {
      const pageNumber = documentViewer.getCurrentPage();
      documentViewer.setCurrentPage(pageNumber + 1, true)

Best regards,
Kevin Kim


Thank you for the answer I will try this prototype

Best regards,