Skip to content
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

Using screenX, screenY instead of pageX, pageY for transform calculation #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Rakibul-GDN
Copy link

Changed This:
const x = ((e.pageX - offsetLeft) / parseInt(width, 10)) * 100 const y = ((e.pageY - offsetTop) / parseInt(height, 10)) * 100
To This:
const x = ((e.screenX - offsetLeft) / parseInt(width, 10)) * 100 const y = ((e.screenY - offsetTop) / parseInt(height, 10)) * 100

Because, when we use multiple react-img-zoom components on the same page, the behavior of the component changes as the page height increases. We don't want that. We want the behavior to stay the same for all the components. So using screen value instead of page value to make sure it stays the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant