Add the onvisible event handler to Element (#2911)
* Add the `onvisible` event using the IntersectionObserver * Add a visible example This example is based on https://codepen.io/ryanfinni/pen/VwZeGxN * Remove web-sys CustomEvent feature for html package * update js bindings and hash * Use dioxus doc instead of lorem ipsum * Fix clippy warning * Add get_target method to the event data * Make `get_time` return an Instant instead of a f64 * fix merge conflicts, compilinga * remove target * small nits * serialzie as time_ms * fix timing, works on desktop * remove latent nits, fix hash * box size clippy * fix browserlist cargo.lock --------- Co-authored-by: Evan Almloff <evanalmloff@gmail.com> Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
This commit is contained in:
20 files changed
+961
-289
No files matched your search
@@ -105,6 +105,9 @@ fn deserialize_raw(name: &str, data: &serde_json::Value) -> Result<EventData, se
|
||||
// Scroll
|
||||
"scroll" => Scroll(de(data)?),
|
||||
|
||||
// Visible
|
||||
"visible" => Visible(de(data)?),
|
||||
|
||||
// Wheel
|
||||
"wheel" => Wheel(de(data)?),
|
||||
|
||||
@@ -163,6 +166,7 @@ pub enum EventData {
|
||||
Touch(SerializedTouchData),
|
||||
Resize(SerializedResizeData),
|
||||
Scroll(SerializedScrollData),
|
||||
Visible(SerializedVisibleData),
|
||||
Wheel(SerializedWheelData),
|
||||
Media(SerializedMediaData),
|
||||
Animation(SerializedAnimationData),
|
||||
@@ -207,6 +211,9 @@ impl EventData {
|
||||
EventData::Scroll(data) => {
|
||||
Rc::new(PlatformEventData::new(Box::new(data))) as Rc<dyn Any>
|
||||
}
|
||||
EventData::Visible(data) => {
|
||||
Rc::new(PlatformEventData::new(Box::new(data))) as Rc<dyn Any>
|
||||
}
|
||||
EventData::Wheel(data) => {
|
||||
Rc::new(PlatformEventData::new(Box::new(data))) as Rc<dyn Any>
|
||||
}
|
||||
@@ -415,6 +422,14 @@ impl HtmlEventConverter for SerializedHtmlEventConverter {
|
||||
.into()
|
||||
}
|
||||
|
||||
fn convert_visible_data(&self, event: &PlatformEventData) -> VisibleData {
|
||||
event
|
||||
.downcast::<SerializedVisibleData>()
|
||||
.cloned()
|
||||
.unwrap()
|
||||
.into()
|
||||
}
|
||||
|
||||
fn convert_wheel_data(&self, event: &PlatformEventData) -> WheelData {
|
||||
event
|
||||
.downcast::<SerializedWheelData>()
|
||||
|
||||
Reference in new issue
Block a user