pub struct Hover {
pub on_start: Option<Rc<RefCell<dyn FnMut(())>>>,
pub on_end: Option<Rc<RefCell<dyn FnMut(())>>>,
pub on_cancel: Option<Rc<RefCell<dyn FnMut(())>>>,
pub on_pointer_appear: Option<Rc<RefCell<dyn FnMut(HoverPointerAppearData)>>>,
pub on_pointer_update: Option<Rc<RefCell<dyn FnMut(HoverPointerUpdateData)>>>,
pub on_pointer_disappear: Option<Rc<RefCell<dyn FnMut(HoverPointerDisappearData)>>>,
pub on_pointer_cancel: Option<Rc<RefCell<dyn FnMut(HoverPointerCancelData)>>>,
}Expand description
use dioxus::prelude::*;
use dioxus_gestures::{
state::gestures::hover::Hover,
use_gestures::{use_gestures, Gestures},
};
const UNHOVERED_TEXT: &str = "Hover over me!";
const HOVERED_TEXT: &str = "Hovering ...";
#[component]
pub fn HoverExample() -> Element {
let mut text = use_signal(|| UNHOVERED_TEXT);
let gestures = use_gestures(
Gestures::default().hover(
Hover::default()
.on_start(move |_| text.set(HOVERED_TEXT))
.on_end(move |_| text.set(UNHOVERED_TEXT))
.on_cancel(move |_| text.set(UNHOVERED_TEXT)),
),
);
rsx! {
div {
class: "target hover",
style: format!("
user-select: none;
touch-action: none;
position: relative;
"),
..gestures.event_handlers(),
"{text}"
}
}
}Fields§
§on_start: Option<Rc<RefCell<dyn FnMut(())>>>§on_end: Option<Rc<RefCell<dyn FnMut(())>>>§on_cancel: Option<Rc<RefCell<dyn FnMut(())>>>§on_pointer_appear: Option<Rc<RefCell<dyn FnMut(HoverPointerAppearData)>>>§on_pointer_update: Option<Rc<RefCell<dyn FnMut(HoverPointerUpdateData)>>>§on_pointer_disappear: Option<Rc<RefCell<dyn FnMut(HoverPointerDisappearData)>>>§on_pointer_cancel: Option<Rc<RefCell<dyn FnMut(HoverPointerCancelData)>>>Implementations§
Source§impl Hover
impl Hover
pub fn on_start(self, handler: impl FnMut(()) + 'static) -> Self
pub fn on_end(self, handler: impl FnMut(()) + 'static) -> Self
pub fn on_cancel(self, handler: impl FnMut(()) + 'static) -> Self
pub fn on_pointer_appear( self, handler: impl FnMut(HoverPointerAppearData) + 'static, ) -> Self
pub fn on_pointer_update( self, handler: impl FnMut(HoverPointerUpdateData) + 'static, ) -> Self
pub fn on_pointer_disappear( self, handler: impl FnMut(HoverPointerDisappearData) + 'static, ) -> Self
pub fn on_pointer_cancel( self, handler: impl FnMut(HoverPointerCancelData) + 'static, ) -> Self
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Hover
impl !Send for Hover
impl !Sync for Hover
impl !UnwindSafe for Hover
impl Freeze for Hover
impl Unpin for Hover
impl UnsafeUnpin for Hover
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
Source§fn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
Create an instance of this type from an initialization function
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<Ret> SpawnIfAsync<(), Ret> for Ret
impl<Ret> SpawnIfAsync<(), Ret> for Ret
Source§impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
Source§fn super_from(input: T) -> O
fn super_from(input: T) -> O
Convert from a type to another type.
Source§impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
Source§fn super_into(self) -> O
fn super_into(self) -> O
Convert from a type to another type.