-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Use rectIntersect instead of a custom argument to rectUnion #64855
Use rectIntersect instead of a custom argument to rectUnion #64855
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: +513 B (+0.03%) Total Size: 1.78 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a minor thing but I think it's more cohesive if we stick to broadly well defined concepts like union and intersect instead of adding a custom argument to rectUnion which makes it a custom thing.
Good thinking - thanks for the follow up.
Agree 💯 with the clearer naming and intentions.
But in testing I can't get it to work as before, can you? Using test instructions posted over in #62711 (comment)
*/ | ||
bounds = rectIntersect( | ||
bounds, | ||
new window.DOMRect( 0, -Infinity, viewport.innerWidth, Infinity ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you test this with Infinity?
What's the reason behind that value? It seems to have reverted the efforts in #62711 😄
I thought we were interested in visibility, so defined bounds on the container would work but I could be missing something
new window.DOMRect( 0, 0, viewport.innerWidth, viewport.innerHeight )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't the original code only clip along the X axis?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, true 🤔
I'll withdraw that, and speculate that consumers of getVisibleElementBounds
don't know how to deal with NaN
values being returned here (?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm ok. Forget rectIntersect
then, we can just adjust left
and right
manually. I still think it's nice to not do this in rectUnion
though. Pushed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the follow up!
Toolbar appears where expected, scrolling looks good.
LTR
2024-09-03.13.11.27.mp4
RTL
2024-09-03.13.12.25.mp4
Also tested in a few block themes - TT4, TT3, TT2
Small follow up to #62711 – see #62711 (comment).
It's a minor thing but I think it's more cohesive if we stick to broadly well defined concepts like union and intersect instead of adding a custom argument to
rectUnion
which makes it a custom thing.Up to @ramonjd, though. I can take it or leave it.