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

fix: consider page scroll when retrieving container point #484

Merged
merged 2 commits into from
Sep 8, 2023
Merged

fix: consider page scroll when retrieving container point #484

merged 2 commits into from
Sep 8, 2023

Conversation

pontusdacke
Copy link
Contributor

Suggested solution for #482

Takes page scroll in account in getContainerPoint so zoom with mousewheel works correct when restrictPosition is set to false.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Sep 7, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 655722b:

Sandbox Source
react-easy-crop Configuration

@ValentinH
Copy link
Owner

Thanks for this PR. I'll have a look and play a bit with this solution. I reminds me of an issue I had to address on https://github.com/ValentinH/react-easy-sort where I had to use some properties that were already taking the scroll into account.

In the end, the issue isn't related with restrictPosition=false, it's also present when it's set to true but it's less obvious.

@ValentinH
Copy link
Owner

ValentinH commented Sep 8, 2023

I checked what was done on react-easy-sort and basically, we are storing the container position in the window on every gesture start and then we use this position to translate the event point (which is relative to the window) to the position inside the container.

Relevant piece of code:

@pontusdacke
Copy link
Contributor Author

I applied your suggestion, storing the position on each gesture. It seem to have achieved the same results, fixing our reported issue.

@ValentinH ValentinH added bug Something isn't working patch Increment the patch version when merged labels Sep 8, 2023
@ValentinH
Copy link
Owner

Thank you for the quick fix! Merging this, it will be automatically published in a few minutes 🎉

@ValentinH ValentinH merged commit 65950bb into ValentinH:main Sep 8, 2023
2 checks passed
@github-actions
Copy link

github-actions bot commented Sep 8, 2023

🚀 PR was released in v5.0.2 🚀

@github-actions github-actions bot added the released This issue/pull request has been released. label Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working patch Increment the patch version when merged released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants