Skip to content

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

Open
Rakibul-GDN wants to merge 1 commit into
LeoNero:masterfrom
Rakibul-GDN:transform-calculate-with-screenX
Open

Using screenX, screenY instead of pageX, pageY for transform calculation#25
Rakibul-GDN wants to merge 1 commit into
LeoNero:masterfrom
Rakibul-GDN:transform-calculate-with-screenX

Conversation

@Rakibul-GDN
Copy link
Copy Markdown

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