Product Version: 8.6.0
I created my own table of content by retrieving bookmarks with documentViewer.getDocument().getBookmarks();
with that each node of my table of content has the page and the vertical position where the associted text section start.
My problem is that I can scroll to a page with this.documentViewer.setCurrentPage($event.node.origin.page,true); but I didn’t find a way to scroll to a specfic position to have the start of a section at the top of the webviewer which is the default behaviour of the table of content in the left panel (that i can’t use).
is there a function to scroll to a specific position ?
if not, is there way to achieve that ?
We don’t have an official API to trigger a smooth scroll to any position in the document, but the code below may be able to unblock you. I have added this feature request to our backlog to be worked on in the future.
You can try using the
DocumentViewer.getScrollViewElement() API followed by
scrollViewElement.scroll() to trigger a smooth scroll. See sample below:
const documentViewer = instance.Core.documentViewer;
const scrollViewElement = documentViewer.getScrollViewElement();
left: null, // Can set to null since we only care about vertical scrolling.
The downside is these coordinates are just DOM/browser coordinates - they are not related to the document page - so there will be some conversion required when specifying top or left.
Let me know how this works for you!