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

Adjust for the viewport scrollX and scrollY #3

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

Adjust for the viewport scrollX and scrollY #3

wants to merge 1 commit into from

Conversation

caleb
Copy link

@caleb caleb commented Feb 13, 2015

Without this patch, if you scroll the basic example down and click the button to rearrange the boxes, the clones are rendered absolute to the document at the viewport coordinates of the real nodes.

This causes them to be rendered higher on the page than the real nodes, and it looks like the boxes are jumping.

To fix this we need to convert the viewport coordinates to document coordinates by adding the scroll position.

I was surprised how few lines of code magic move was, it's pretty neat what you can do with React with that few lines!

getBoundingClientRect() returns coordinates relative to the viewport, so
to position the portal clones exactly where the real nodes are, you have
to adjust for the scrolling of the viewport.
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