implement on mounted for desktop
This commit is contained in:
1 parent
cb5cb56ad3
commit
7636c046fa
8 files changed
+450
-24
No files matched your search
@@ -2,6 +2,7 @@ use std::{any::Any, rc::Rc};
|
||||
|
||||
use crate::events::*;
|
||||
use dioxus_core::ElementId;
|
||||
use euclid::Rect;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Debug, Clone, PartialEq)]
|
||||
@@ -113,6 +114,9 @@ fn fun_name(
|
||||
// Toggle
|
||||
"toggle" => Toggle(de(data)?),
|
||||
|
||||
// Mounted
|
||||
"mounted" => Mounted,
|
||||
|
||||
// ImageData => "load" | "error";
|
||||
// OtherData => "abort" | "afterprint" | "beforeprint" | "beforeunload" | "hashchange" | "languagechange" | "message" | "offline" | "online" | "pagehide" | "pageshow" | "popstate" | "rejectionhandled" | "storage" | "unhandledrejection" | "unload" | "userproximity" | "vrdisplayactivate" | "vrdisplayblur" | "vrdisplayconnect" | "vrdisplaydeactivate" | "vrdisplaydisconnect" | "vrdisplayfocus" | "vrdisplaypointerrestricted" | "vrdisplaypointerunrestricted" | "vrdisplaypresentchange";
|
||||
other => {
|
||||
@@ -151,6 +155,7 @@ pub enum EventData {
|
||||
Animation(AnimationData),
|
||||
Transition(TransitionData),
|
||||
Toggle(ToggleData),
|
||||
Mounted,
|
||||
}
|
||||
|
||||
impl EventData {
|
||||
@@ -172,6 +177,7 @@ impl EventData {
|
||||
EventData::Animation(data) => Rc::new(data) as Rc<dyn Any>,
|
||||
EventData::Transition(data) => Rc::new(data) as Rc<dyn Any>,
|
||||
EventData::Toggle(data) => Rc::new(data) as Rc<dyn Any>,
|
||||
EventData::Mounted => Rc::new(MountedData::new(())) as Rc<dyn Any>,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -215,3 +221,49 @@ fn test_back_and_forth() {
|
||||
|
||||
assert_eq!(data, p);
|
||||
}
|
||||
|
||||
/// Message to update a node to support MountedData
|
||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub struct NodeUpdate {
|
||||
/// The id of the node to update
|
||||
pub id: u32,
|
||||
/// The id of the request
|
||||
pub request_id: usize,
|
||||
/// The data to update the node with
|
||||
pub data: NodeUpdateData,
|
||||
}
|
||||
|
||||
/// Message to update a node to support MountedData
|
||||
#[cfg_attr(
|
||||
feature = "serialize",
|
||||
derive(serde::Serialize, serde::Deserialize),
|
||||
serde(tag = "type")
|
||||
)]
|
||||
pub enum NodeUpdateData {
|
||||
SetFocus { focus: bool },
|
||||
GetClientRect {},
|
||||
ScrollTo { behavior: ScrollBehavior },
|
||||
}
|
||||
|
||||
/// The result of a element query
|
||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct MountedReturn {
|
||||
/// A unique id for the query
|
||||
pub id: usize,
|
||||
/// The result of the query
|
||||
pub data: Option<MountedReturnData>,
|
||||
}
|
||||
|
||||
/// The data of a element query
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[cfg_attr(
|
||||
feature = "serialize",
|
||||
derive(serde::Serialize, serde::Deserialize),
|
||||
serde(tag = "type")
|
||||
)]
|
||||
pub enum MountedReturnData {
|
||||
SetFocus(()),
|
||||
GetClientRect(Rect<f64, f64>),
|
||||
ScrollTo(()),
|
||||
}
|
||||
Reference in new issue
Block a user