Improve image zooming (scroll wheel) #1887
Merged
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.
I propose a few small changes to the image zooming code that should improve UX in this area:
.modal-container
element does not include the header, so the calculation should not compensate for this. After this change the same image location stays under the mouse cursor position when zooming in/out. Previously the position drifted away slightly.maxHeight
/maxWidth
over 100% does not enlarge the image, so I had to switch toheight
/width
. This in turn required switching animations off - it looked very ugly with the animations on. The animations did not work previously, so it seems a fair trade-off for me. 馃槈 I have also made a few cosmetic changes to simplify calculations.zoomRatio
calculations to always increase/decrease it by 10% (rather than linearly). This feels more natural - esp. with larger zoom levels.When zooming beyond 100% this still uses the preview image - so obviously there will be some blurriness. Requesting the original image in this case would certainly be a better solution, but it seems to be something for a separate PR.
PS. As a follow-up, I plan to work on pinch to zoom on mobile devices (#917)
Edit I see that all cypress tests failed. 馃槥 This seems to be unrelated to this PR.