-
-
Notifications
You must be signed in to change notification settings - Fork 833
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
Add the onvisible
event handler to Element
#2911
base: main
Are you sure you want to change the base?
Conversation
This example is based on https://codepen.io/ryanfinni/pen/VwZeGxN
|
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 working on this! I had a few questions about some APIs, otherwise the implementation looks good
@@ -110,6 +110,7 @@ impl WebviewEdits { | |||
data.into_any() | |||
} | |||
} | |||
dioxus_html::EventData::Visible(_) => data.into_any(), |
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.
This looks the same as the branch following it. Should it be merged or do we need to handle converting visible data to any in a different way?
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.
Indeed. I'm going to remove this branch.
} | ||
|
||
/// Get the element whose intersection with the root changed | ||
pub fn get_target(&self) -> VisibleResult<ElementId> { |
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.
ElementId
isn't very useful in user-facing code. It is mainly used in core/the renderers. We could use MountedData
here which wraps the ElementId
or web_sys::Element
with accessors.
The target here will always be the element that the event listener is attatched to right? If that is true, then it might be better to wait until we add target() -> MountedData
to all events together.
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.
This is also my understanding (cf. https://css-tricks.com/a-few-functional-uses-for-intersection-observer-to-know-when-an-element-is-in-view/). Are you referring to the #2858?
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.
Are you referring to the #2858?
Yes, bothrelatedTarget
andtarget
need the mounteddata for the element
This PR add the capability to handle the visible events for a given
Element
:For now, the IntersectionObserverEntry.target is not used/serialized. If it make sense to use it, how can we serialize it? Could we use the
data-dioxus-id
?