From 87c6825b0f5cd5482994e7d495d9f1faccc3d731 Mon Sep 17 00:00:00 2001 From: avi Date: Fri, 8 Dec 2023 21:14:16 -0800 Subject: [PATCH 1/2] add transition events --- src/events.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/events.rs b/src/events.rs index f678d3c..8c5435a 100644 --- a/src/events.rs +++ b/src/events.rs @@ -430,6 +430,18 @@ make_event!(SelectionChange => web_sys::Event); static_event_impl!(SelectionChange => "selectionchange"); +make_event!(TransitionCancel => web_sys::Event); +static_event_impl!(TransitionCancel => "transitioncancel"); + +make_event!(TransitionEnd => web_sys::Event); +static_event_impl!(TransitionEnd => "transitionend"); + +make_event!(TransitionRun => web_sys::Event); +static_event_impl!(TransitionRun => "transitionrun"); + +make_event!(TransitionStart => web_sys::Event); +static_event_impl!(TransitionStart => "transitionstart"); + impl Input { // TODO should this work on other types as well ? From 4691d5ecceb533ce20c456fcbc2be75a5cb33ac0 Mon Sep 17 00:00:00 2001 From: avi Date: Fri, 8 Dec 2023 21:33:22 -0800 Subject: [PATCH 2/2] add bespoke transitiionevent macro --- Cargo.toml | 1 + src/events.rs | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 20a351c..bdb8ee5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -69,6 +69,7 @@ features = [ "Touch", "TouchEvent", "TouchList", + "TransitionEvent", "UiEvent", "Window", ] diff --git a/src/events.rs b/src/events.rs index 8c5435a..08c61d5 100644 --- a/src/events.rs +++ b/src/events.rs @@ -430,16 +430,28 @@ make_event!(SelectionChange => web_sys::Event); static_event_impl!(SelectionChange => "selectionchange"); -make_event!(TransitionCancel => web_sys::Event); +macro_rules! make_transition_event { + ($name:ident) => { + make_event!($name => web_sys::TransitionEvent); + + impl $name { + #[inline] pub fn property_name(&self) -> String { self.event.property_name() } + #[inline] pub fn elapsed_time(&self) -> f32 { self.event.elapsed_time() } + #[inline] pub fn pseudo_element(&self) -> String { self.event.pseudo_element() } + } + }; +} + +make_transition_event!(TransitionCancel); static_event_impl!(TransitionCancel => "transitioncancel"); -make_event!(TransitionEnd => web_sys::Event); +make_transition_event!(TransitionEnd); static_event_impl!(TransitionEnd => "transitionend"); -make_event!(TransitionRun => web_sys::Event); +make_transition_event!(TransitionRun); static_event_impl!(TransitionRun => "transitionrun"); -make_event!(TransitionStart => web_sys::Event); +make_transition_event!(TransitionStart); static_event_impl!(TransitionStart => "transitionstart");