Commit ead47c9b authored by Florian Blasius's avatar Florian Blasius 🤘

web: hover event

parent 12719f45
Pipeline #9140 passed with stage
in 1 minute and 10 seconds
......@@ -682,4 +682,32 @@ fn connect_event_handlers(
.unwrap();
closure.forget();
}
// hover (enter)
{
let events = events.clone();
let closure = Closure::wrap(Box::new(move |_: web_sys::MouseEvent| {
events
.borrow_mut()
.push(HoverEvent { entered: true }.to_event());
}) as Box<dyn FnMut(_)>);
canvas
.add_event_listener_with_callback("mouseenter", closure.as_ref().unchecked_ref())
.unwrap();
closure.forget();
}
// hover (leave)
{
let events = events.clone();
let closure = Closure::wrap(Box::new(move |_: web_sys::MouseEvent| {
events
.borrow_mut()
.push(HoverEvent { entered: false }.to_event());
}) as Box<dyn FnMut(_)>);
canvas
.add_event_listener_with_callback("mouseleave", closure.as_ref().unchecked_ref())
.unwrap();
closure.forget();
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment