Struct gloo::events::EventListenerOptions
source · pub struct EventListenerOptions {
pub phase: EventListenerPhase,
pub passive: bool,
}
Available on crate feature
events
only.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: EventListenerPhase
The phase that the event listener should be run in.
passive: bool
If 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() -> EventListenerOptions
pub fn run_in_capture_phase() -> EventListenerOptions
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() -> EventListenerOptions
pub fn enable_prevent_default() -> EventListenerOptions
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
source§fn default() -> EventListenerOptions
fn default() -> EventListenerOptions
Returns the “default value” for a type. Read more
impl Copy for EventListenerOptions
Auto Trait Implementations§
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