-
Notifications
You must be signed in to change notification settings - Fork 10k
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
[api-minor] Simplify API to implement zoom in custom viewers #18179
[api-minor] Simplify API to implement zoom in custom viewers #18179
Conversation
3d6ce52
to
b65ba0d
Compare
Looking at a working patch, written by an actual human, I'm happy to retract that statement since it's clear that it avoids a bunch of code duplication :-) |
/botio integrationtest |
From: Bot.io (Linux m4)ReceivedCommand cmd_integrationtest from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.241.84.105:8877/41d5c1423b09441/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_integrationtest from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.193.163.58:8877/c713b44aab198d2/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.241.84.105:8877/41d5c1423b09441/output.txt Total script time: 7.85 mins
|
From: Bot.io (Windows)FailedFull output at http://54.193.163.58:8877/c713b44aab198d2/output.txt Total script time: 16.62 mins
|
This is the test failing on windows (line 727 is throwing): pdf.js/test/integration/stamp_editor_spec.mjs Lines 713 to 730 in 95a7de9
It is failing because the |
`updateScale` receives a `drawingDelay`, a `scaleFactor` and/or a number of `steps`. If `scaleFactor` is a positive number different from `1` the current scale is multiplied by that number. Otherwise, if `steps` if a positive integer the current scale is multiplied by `DEFAULT_SCALE_DELTA` `steps` times. Finally, if `steps` is a negative integer, the current scale is divided by `DEFAULT_SCALE_DELTA` `abs(steps)` times.
b65ba0d
to
9d334fc
Compare
/botio integrationtest |
From: Bot.io (Linux m4)ReceivedCommand cmd_integrationtest from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.241.84.105:8877/1a80676073ff22b/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_integrationtest from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.193.163.58:8877/aa3933c8fd7da6b/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.241.84.105:8877/1a80676073ff22b/output.txt Total script time: 7.82 mins
|
From: Bot.io (Windows)SuccessFull output at http://54.193.163.58:8877/aa3933c8fd7da6b/output.txt Total script time: 19.04 mins
|
/botio-linux preview |
From: Bot.io (Linux m4)ReceivedCommand cmd_preview from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.241.84.105:8877/55892e089776b04/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.241.84.105:8877/55892e089776b04/output.txt Total script time: 1.17 mins Published |
/botio integrationtest |
From: Bot.io (Linux m4)ReceivedCommand cmd_integrationtest from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.241.84.105:8877/8b3e402acee8dcf/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_integrationtest from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.193.163.58:8877/1724685ff947a26/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.241.84.105:8877/8b3e402acee8dcf/output.txt Total script time: 7.75 mins
|
From: Bot.io (Windows)SuccessFull output at http://54.193.163.58:8877/1724685ff947a26/output.txt Total script time: 18.98 mins
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me, with a couple of final comments; thank you!
This parameter allows defining which point should remain fixed while scaling the document. It can be used, for example, to implement "zoom around the cursor" or "zoom around pinch center". The logic was previously implemented in `web/app.js`, but moving it to the viewer scaling utilities themselves makes it easier to implement similar zooming functionalities in other embedders.
9d334fc
to
b7933d8
Compare
/botio-linux integrationtest |
From: Bot.io (Linux m4)ReceivedCommand cmd_integrationtest from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.241.84.105:8877/d288c01ae5dfbfa/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.241.84.105:8877/d288c01ae5dfbfa/output.txt Total script time: 7.82 mins
|
Thanks for the quick review! |
Closes #18076
This PR extends the zoom/scale API to simplify the logic in custom viewer wrappers:
updateScale
function that does bothincreaseScale
/decreaseScale
. Ad you can see from the commit itself, it significantly reduces code duplication both in embedders (see the changes inweb/app.js
) and inweb/pdf_viewer.js
itselfNote that this PR increases the net number of lines because it adds a test, but ignoring the new test it would be +56 -95.
@Snuffleupagus In #18098 (comment) you said that you probably do not want
updateScale
, but I still uploaded it since it de-duplicates a significant amount of code. What do you think about it? (the second commit could be done independently from the first one)Commits: