Add the onresize event handler to Element (#2479)
* Add the capability to handle resize event for web target * Add the capability to handle resize event for desktop target * Return all the sizes, not just the first one * Fix conversion from platform to generic ResizedData for liveview * Update the generated interpreter js code base * Fix clippy warnings * Fix inconsistent use of block_size and inline_size * Rename `onresized` event to `onresize` * Remove the the special-casing logic from the binding logic * Propagating the resize events using CustomEvent * Fix case convention in core ts * revert changes to unified bindings * Cleanup as suggested * add a resize example * Fix desktop resize events * remove tracing from resize example * use the raw resize entry so we can downcast on web * remove unused ResizeEventDetail --------- Co-authored-by: Evan Almloff <evanalmloff@gmail.com>
This commit is contained in:
1 parent
4d6fb74e87
commit
2f49a89638
19 files changed
+442
-50
No files matched your search
@@ -99,6 +99,9 @@ fn deserialize_raw(name: &str, data: &serde_json::Value) -> Result<EventData, se
|
||||
// Touch
|
||||
"touchcancel" | "touchend" | "touchmove" | "touchstart" => Touch(de(data)?),
|
||||
|
||||
// Resize
|
||||
"resize" => Resize(de(data)?),
|
||||
|
||||
// Scroll
|
||||
"scroll" => Scroll(de(data)?),
|
||||
|
||||
@@ -158,6 +161,7 @@ pub enum EventData {
|
||||
Pointer(SerializedPointerData),
|
||||
Selection(SerializedSelectionData),
|
||||
Touch(SerializedTouchData),
|
||||
Resize(SerializedResizeData),
|
||||
Scroll(SerializedScrollData),
|
||||
Wheel(SerializedWheelData),
|
||||
Media(SerializedMediaData),
|
||||
@@ -197,6 +201,9 @@ impl EventData {
|
||||
EventData::Touch(data) => {
|
||||
Rc::new(PlatformEventData::new(Box::new(data))) as Rc<dyn Any>
|
||||
}
|
||||
EventData::Resize(data) => {
|
||||
Rc::new(PlatformEventData::new(Box::new(data))) as Rc<dyn Any>
|
||||
}
|
||||
EventData::Scroll(data) => {
|
||||
Rc::new(PlatformEventData::new(Box::new(data))) as Rc<dyn Any>
|
||||
}
|
||||
@@ -360,6 +367,13 @@ impl HtmlEventConverter for SerializedHtmlEventConverter {
|
||||
.unwrap()
|
||||
.into()
|
||||
}
|
||||
fn convert_resize_data(&self, event: &PlatformEventData) -> ResizeData {
|
||||
event
|
||||
.downcast::<SerializedResizeData>()
|
||||
.cloned()
|
||||
.unwrap()
|
||||
.into()
|
||||
}
|
||||
|
||||
fn convert_scroll_data(&self, event: &PlatformEventData) -> ScrollData {
|
||||
event
|
||||
|
||||
Reference in new issue
Block a user