document position lost

32 views
Skip to first unread message

Perry Manole

unread,
Apr 12, 2014, 3:55:56 AM4/12/14
to pdfnet-w...@googlegroups.com
I have a page that hosts multiple viewers but only one is shown at a time. Whenever I hide the DIV container of the viewer and then show it again the panning position of the document is lost. Everying else remains like zooming, cursor mode, text selection, etc.

How do I maintain the panning position?

Matt Parizeau

unread,
Apr 14, 2014, 8:18:16 PM4/14/14
to pdfnet-w...@googlegroups.com
Interestingly it seems like Chrome does preserve the position but Firefox and IE don't. Regardless, I tried saving the scroll position before hiding and then setting it after showing and this seemed to work.

To select the element that scrolls you can do something like: 
var documentContent = $(viewerElement).find('iframe')[0].contentWindow.$('#DocumentViewer');

Then before hiding the container get the scroll values:
var scrollLeft = documentContent.scrollLeft();
var scrollTop = documentContent.scrollTop();

Then after showing the container scroll to those saved positions:
documentContent.scrollLeft(scrollLeft);
documentContent
.scrollTop(scrollTop);

Matt Parizeau
Software Developer
PDFTron Systems Inc.
Reply all
Reply to author
Forward
0 new messages