Proposed fix for zoom out issue #384#596
Open
mitchjb-sos wants to merge 1 commit intoembedpdf:mainfrom
Open
Conversation
|
@mitchjb-sos is attempting to deploy a commit to the OpenBook Team on Vercel. A member of the Team first needs to authorize it. |
|
well done |
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a proposed fix for #384.
I am not sure about the original intention of the math or the feature, but the issue arises due to differences between how browsers report
deltaYwith mouse wheel scrolling.I believe the values that are reported for various browser:
Chromium: +/-100
Firefox: +/-3
Safari: Hardware accelerated, aka, values are provided by mouse
When users with Chromium browsers attempt to Ctrl + scroll,
accumulatedWheelScaleends up being clamped to 2/0.1, hence the reported zoom out by 10%:(Special thanks to lystormenvoy who helped point to the source code where the issue resides.)
The proposed solution is as follows:
I changed the
zoomFactorcalculation to utilize only the sign, or direction, from the scroll and apply a staticzoomStep(which perhaps should be utilizing thezoomStepconfig from the zoom plugin config, as you can see in my comment).I also changed to the
clampfunction that I saw defined above for limitingaccumulatedWheelScale.I attempted to modify all corresponding props and APIs for the various frameworks, but I am really only a React dev and it would be good to review all of the code before merging!
Lastly, this is my first ever FOSS pull request, so please feel free to give gentle feedback! 😃