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: fixes Html element moving with scrollControls closes #1048 #1126
base: master
Are you sure you want to change the base?
fix: fixes Html element moving with scrollControls closes #1048 #1126
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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 5f5f5ed:
|
Can you explain in further detail why you've done the changes you've made please? |
When you set your |
im not sure this is a fix. imo it breaks. the node that components should use is always connected. it only falls back to domElement bc of older r3f. domElement would also break portaling, right now html can run in split views because each can have its own connected node, but gl.domElement only exists once. if you have a scroll container you cannot use client coordinates, you need offset (as in event.offsetX & event.offsetY <Canvas eventPrefix="offset" and it would also make sense to make the event source a shared parent, this is what would break here <Canvas eventPrefix="offset" eventSource={document.getElementById("root")} there is no one solution fits all. most of the time you want client, but in some situations you need offset. |
Ok, that makes sense, I guess that In order to fix it I would have to refactor the way ScrollControls work instead? Prevent it to transform the root? and act on a child node? or I could also add a flag, here in Html component that allows the What do you suggest? |
good question @TomasGonzalez did you figure something out? |
I'll give some thought to this this week, please don't close the PR yet. |
@joshuaellis @drcmda I'm sorry but I've got no time to fully fix this issue by the method I mentioned #1126 (comment) but I found a very simple work around, you just have to pass |
It seems that this work around prevents you from scrolling when your mouse is over the Html element (If you apply
|
The work around simply prioritized the Dom element that was used in versions where it used to work... I don't see how this could mess up the scroll (If it was working already) |
I've also been experiencing issues with the My understanding about what's happening is that when using a portal to the DOM element mentioned in the workaround, events that occur within the There might be a way to correct this using the However, I did figure out another workaround that seemed to generally get the behavior I was expecting. Rather than using
With this, event propagation seems to work as expected again, and it handles "nested" scrolling properly (i.e. if the HTML content can scroll, you can scroll within it without moving the ScrollControl until reaching the top/bottom of the scroll, and then the ScrollControl receives the scroll again). The only issue I've seen so far is that it seems to act very strangely on Firefox - the HTML content will jump around while scrolling. It works fine on Chrome and Safari though. Here is a codesandbox that demonstrates this. |
Why
Html component is currently having issues when used along the Scroll controls, resolves #1048
What
I modified the
target
DOMElement selection conditional
to prioritize the parent element returned bygl.domElement.parentNode
instead of the element returned byevents.connected
Checklist