pub struct UseHover {
pub target: NodeRef<Element>,
pub hovered: Signal<bool>,
/* private fields */
}Expand description
Reactive state for a hover watcher.
The handle carries the element the hook watches — a NodeRef the
caller attaches to its own markup — and the signal that reports
whether the pointer is currently over it.
The watcher listens on the document rather than on the element itself, for the same reason the click-outside watcher does: the element does not exist while the first render is being built, and a document listener can then ask whether the pointer’s node sits inside the watched element.
Fields§
§target: NodeRef<Element>The element the hook watches.
Attach it to the caller’s markup with the ref: attribute.
hovered: Signal<bool>Whether the pointer is currently over the watched element.
Implementations§
Source§impl UseHover
Inherent implementation of UseHover.
impl UseHover
Inherent implementation of UseHover.
Sourcepub fn is_hovered(&self) -> bool
pub fn is_hovered(&self) -> bool
Returns the current hover state as a snapshot.
§Returns
bool-truewhen the pointer is over the watched element.
Source§impl UseHover
impl UseHover
pub fn get_target(&self) -> &NodeRef<Element>
pub fn get_mut_target(&mut self) -> &mut NodeRef<Element>
pub fn set_target(&mut self, val: NodeRef<Element>) -> &mut Self
pub fn get_hovered(&self) -> Signal<bool>
pub fn get_mut_hovered(&mut self) -> &mut Signal<bool>
pub fn set_hovered(&mut self, val: Signal<bool>) -> &mut Self
pub fn get_mut_teardown(&mut self) -> &mut Rc<RefCell<Option<Box<dyn Fn()>>>>
pub fn set_teardown( &mut self, val: Rc<RefCell<Option<Box<dyn Fn()>>>>, ) -> &mut Self
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for UseHover
impl !Send for UseHover
impl !Sync for UseHover
impl !UnwindSafe for UseHover
impl Freeze for UseHover
impl Unpin for UseHover
impl UnsafeUnpin for UseHover
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