fix: stop loupe being shown in incorrect position on mouseenter #113
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.
Description
This library had an issue where if the mouse was quickly moved into the container and stopped, the loupe would be incorrectly positioned.
This was because the internal code was using
getBoundingClientRect
to calculate the width of the zoom pane, which was changing during the mouseenter animation. This animation was using CSS transforms to change the apparent width of the zoom pane. This caused the positioning logic to incorrectly position the image, and the loupe container.This PR fixes this by using
offsetWidth
andoffsetHeight
instead, which aren't affected by transforms.The issue:
After solution:
This fixes #86.
Bug Fix
fix(<area>): fixed bug #issue-number
Steps to Test
To test this PR:
npm install && npm run build
.new Drift(...)
part in index.html to the snippet below to make the bug easier to reproduce.browser-sync start --server --files "dist/*"
.Code snippet to change relevant part index.html to: