pub struct EventListenerOptions {
pub phase: EventListenerPhase,
pub passive: bool,
}Expand description
Specifies options for EventListener::new_with_options and
EventListener::once_with_options.
§Default
EventListenerOptions {
phase: EventListenerPhase::Bubble,
passive: true,
}§Examples
Sets phase to EventListenerPhase::Capture, using the default for the rest:
let options = EventListenerOptions::run_in_capture_phase();Sets passive to false, using the default for the rest:
let options = EventListenerOptions::enable_prevent_default();Specifies all options:
let options = EventListenerOptions {
phase: EventListenerPhase::Capture,
passive: false,
};Fields§
§phase: EventListenerPhaseThe phase that the event listener should be run in.
passive: boolIf this is true then performance is improved, but it is not possible to use
event.prevent_default().
If this is false then performance might be reduced, but now it is possible to use
event.prevent_default().
You can read more about the performance costs here.
Implementations§
Source§impl EventListenerOptions
impl EventListenerOptions
Sourcepub fn run_in_capture_phase() -> Self
pub fn run_in_capture_phase() -> Self
Returns an EventListenerOptions with phase set to EventListenerPhase::Capture.
This is the same as:
EventListenerOptions {
phase: EventListenerPhase::Capture,
..Default::default()
}Sourcepub fn enable_prevent_default() -> Self
pub fn enable_prevent_default() -> Self
Returns an EventListenerOptions with passive set to false.
This is the same as:
EventListenerOptions {
passive: false,
..Default::default()
}Trait Implementations§
Source§impl Clone for EventListenerOptions
impl Clone for EventListenerOptions
Source§fn clone(&self) -> EventListenerOptions
fn clone(&self) -> EventListenerOptions
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for EventListenerOptions
impl Debug for EventListenerOptions
Source§impl Default for EventListenerOptions
impl Default for EventListenerOptions
impl Copy for EventListenerOptions
Auto Trait Implementations§
impl Freeze for EventListenerOptions
impl RefUnwindSafe for EventListenerOptions
impl Send for EventListenerOptions
impl Sync for EventListenerOptions
impl Unpin for EventListenerOptions
impl UnwindSafe for EventListenerOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more