-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Add previous/next-page functionality that takes scroll/spread-modes into account (issue 11946) #12870
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
3f27189
to
1190193
Compare
/botio unittest |
From: Bot.io (Linux m4)ReceivedCommand cmd_unittest from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.67.70.0:8877/ba2de5820cad997/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_unittest from @Snuffleupagus received. Current queue size: 0 Live output at: http://3.101.106.178:8877/44c8e1db573662c/output.txt |
From: Bot.io (Linux m4)FailedFull output at http://54.67.70.0:8877/ba2de5820cad997/output.txt Total script time: 3.60 mins
|
From: Bot.io (Windows)SuccessFull output at http://3.101.106.178:8877/44c8e1db573662c/output.txt Total script time: 4.66 mins
|
From: Bot.io (Linux m4)ReceivedCommand cmd_preview from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.67.70.0:8877/3b9c59e060d8335/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.67.70.0:8877/3b9c59e060d8335/output.txt Total script time: 4.18 mins Published |
c12d070
to
07e90aa
Compare
…nto account (issue 11946) - For wrapped scrolling, we unfortunately need to do a fair bit of parsing of the *current* page layout. Compared to e.g. the spread-modes, where we can easily tell how the pages are laid out, with wrapped scrolling we cannot tell without actually checking. In particular documents with varying page sizes require some care, since we need to check all pages on the "row" of the current page are visible and that there aren't any "holes" present. Otherwise, in the general case, there's a risk that we'd skip over pages if we'd simply always advance to the previous/next "row" in wrapped scrolling. - For horizontal scrolling, this patch simply maintains the current behaviour of advancing *one* page at a time. The reason for this is to prevent inconsistent behaviour for the next and previous cases, since those cannot be handled identically. For the next-case, it'd obviously be simple to advance to the first not completely visible page. However for the previous-case, we'd only be able to go back *one* page since it's not possible to (easily) determine the page layout of non-visible pages (documents with varying page sizes being a particular issue). - For vertical scrolling, this patch maintains the current behaviour by default. When spread-modes are being used, we'll now attempt to advance to the next *spread*, rather than just the next page, whenever possible. To prevent skipping over a page, this two-page advance will only apply when both pages of the current spread are visible (to avoid breaking documents with varying page sizes) and when the second page in the current spread is fully visible *horizontally* (to handle larger zoom values). In order to reduce the performance impact of these changes, note that the previous/next-functionality will only call `getVisibleElements` for the scroll/spread-modes where that's necessary and that "normal" vertical scrolling is thus unaffected by these changes. To support these changes, the `getVisibleElements` helper function will now also include the `widthPercent` in addition to the existing `percent` property. The `PDFViewer._updateHelper` method is changed slightly w.r.t. updating the `currentPageNumber` for the non-vertical/spread modes, i.e. won't affect "normal" vertical scrolling, since that helped simplify the overall calculation of the page advance. Finally, these new `BaseViewer` methods also allow (some) simplification of previous/next-page functionality in various viewer components. *Please note:* There's one thing that this patch does not attempt to change, namely disabling of the previous/next toolbarButtons respectively the firstPage/lastPage secondaryToolbarButtons. The reason for this is that doing so would add quite a bit of complexity in general, and if for some reason `BaseViewer._getPageAdvance` would get things wrong we could end up incorrectly disabling the buttons. Hence it seemed overall safer to *not* touch this, and accept that the buttons won't be `disabled` despite in some edge-cases no further scrolling being possible.
07e90aa
to
a2b592f
Compare
From: Bot.io (Linux m4)ReceivedCommand cmd_preview from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.67.70.0:8877/b714e4ea9af8c06/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.67.70.0:8877/b714e4ea9af8c06/output.txt Total script time: 4.28 mins Published |
Thank you! I had a good look at this isn't entirely trivial, but I couldn't spot any logic errors and in my manual testing this also seems to work as expected. |
For wrapped scrolling, we unfortunately need to do a fair bit of parsing of the current page layout. Compared to e.g. the spread-modes, where we can easily tell how the pages are laid out, with wrapped scrolling we cannot tell without actually checking. In particular documents with varying page sizes require some care, since we need to check all pages on the "row" of the current page are visible and that there aren't any "holes" present. Otherwise, in the general case, there's a risk that we'd skip over pages if we'd simply always advance to the previous/next "row" in wrapped scrolling.
For horizontal scrolling, this patch simply maintains the current behaviour of advancing one page at a time. The reason for this is to prevent inconsistent behaviour for the next and previous cases, since those cannot be handled identically. For the next-case, it'd obviously be simple to advance to the first not completely visible page. However for the previous-case, we'd only be able to go back one page since it's not possible to (easily) determine the page layout of non-visible pages (documents with varying page sizes being a particular issue).
For vertical scrolling, this patch maintains the current behaviour by default. When spread-modes are being used, we'll now attempt to advance to the next spread, rather than just the next page, whenever possible. To prevent skipping over a page, this two-page advance will only apply when both pages of the current spread are visible (to avoid breaking documents with varying page sizes) and when the second page in the current spread is fully visible horizontally (to handle larger zoom values).
In order to reduce the performance impact of these changes, note that the previous/next-functionality will only call
getVisibleElements
for the scroll/spread-modes where that's necessary and that "normal" vertical scrolling is thus unaffected by these changes.To support these changes, the
getVisibleElements
helper function will now also include thewidthPercent
in addition to the existingpercent
property.The
PDFViewer._updateHelper
method is changed slightly w.r.t. updating thecurrentPageNumber
for the non-vertical/spread modes, i.e. won't affect "normal" vertical scrolling, since that helped simplify the overall calculation of the page advance.Finally, these new
BaseViewer
methods also allow (some) simplification of previous/next-page functionality in various viewer components.Please note: There's one thing that this patch does not attempt to change, namely disabling of the previous/next toolbarButtons respectively the firstPage/lastPage secondaryToolbarButtons. The reason for this is that doing so would add quite a bit of complexity in general, and if for some reason
BaseViewer._getPageAdvance
would get things wrong we could end up incorrectly disabling the buttons. Hence it seemed overall safer to not touch this, and accept that the buttons won't bedisabled
despite in some edge-cases no further scrolling being possible.Fixes #11946