allefeld / atom-pdfjs-viewer

Themed, fully featured PDF viewer for the Atom editor
MIT License
12 stars 3 forks source link

FR: after reloading a modified PDF, keep the scroll position #12

Closed avm99963 closed 2 years ago

avm99963 commented 3 years ago

This is useful when writing long latex files which are constantly being built while editing.

I see there were some efforts to do this:

https://github.com/allefeld/atom-pdfjs-viewer/blob/a9c8c8890572c9c81dad1a38704320f0717b963a/lib/pdfjs-viewer-view.js#L247-L255

That snippets suggests that a workaround like the ones shared in https://github.com/mozilla/pdf.js/issues/11359#issuecomment-659154737 and https://github.com/mozilla/pdf.js/issues/11496#issuecomment-573650428 was tried unsuccessfully.

allefeld commented 3 years ago

The official solution would be to make sure the PDF ID does not change when the PDF is regenerated. See: https://github.com/allefeld/atom-pdfjs-viewer/issues/3#issuecomment-622022837

But you're right, I also tried to hack this, unsuccessfully. Thanks for the pointers to a workaround, I'll look into that! The drawback would be that then different documents might inherit each other's scroll position.

allefeld commented 2 years ago

I added code to implement the workaround from https://github.com/mozilla/pdf.js/issues/11359#issuecomment-659154737. It is disabled by default, but can be enabled by a new package option "Override PDF ID".

allefeld commented 2 years ago

published with v1.3.0