How do I disable changing the page when tapping on the page edges?

Q: How do I disable changing the page when tapping on the page edges?

A: By default when using the PSPDFKit.ScrollMode PER_SPREAD, tapping on the edges of a page will navigate to the next or previous page. To disable this behaviour you can use the following workaround to ignore those touch events:

instance.contentDocument.addEventListener(
  'click',
  function(event) {
    if (
      instance.contentDocument.querySelector('.PSPDFKit-Viewport').contains(event.target) &&
      !event.target.closest('.PSPDFKit-Page')
    ) {
      event.stopImmediatePropagation()
    }
  },
  { capture: true },
)