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:
ASR-ASUandEvan Almloff authored and GitHub committed 2024-08-15 01:23:49 +00:00
1 parent 4d6fb74e87
commit 2f49a89638
19 files changed
+442 -50

No files matched your search

+3 -2
View File
@@ -98,6 +98,7 @@ export class NativeInterpreter extends JSChannel_ {
// make sure we pass the handler to the base interpreter
const handler: EventListener = (event) =>
this.handleEvent(event, event.type, true);
super.initialize(root, handler);
}
@@ -209,7 +210,7 @@ export class NativeInterpreter extends JSChannel_ {
// This is to support the prevent_default: "onclick" attribute that dioxus has had for a while, but is not necessary
// now that we expose preventDefault to the virtualdom on desktop
// Liveview will still need to use this
this.preventDefaults(event, target);
this.preventDefaults(event);
// liveview does not have synchronous event handling, so we need to send the event to the host
if (this.liveview) {
@@ -262,7 +263,7 @@ export class NativeInterpreter extends JSChannel_ {
// - prevent anchor tags from navigating
// - prevent buttons from submitting forms
// - let the virtualdom attempt to prevent the event
preventDefaults(event: Event, target: EventTarget) {
preventDefaults(event: Event) {
if (event.type === "submit") {
event.preventDefault();
}