Fix web mouse move and mouse wheel such that they are similar to desktop
@@ -89,7 +89,7 @@ impl Window
fn add_mousemove_event_listener(&self, events: Rc<RefCell<Vec<Event>>>)
{
let closure = Closure::wrap(Box::new(move |event: web_sys::MouseEvent| {
- (*events).borrow_mut().push(Event::MouseMotion {delta: (event.offset_x() as f64, event.offset_y() as f64)});
+ (*events).borrow_mut().push(Event::MouseMotion {delta: (event.movement_x() as f64, event.movement_y() as f64)});
}) as Box<dyn FnMut(_)>);
self.canvas.add_event_listener_with_callback("mousemove", closure.as_ref().unchecked_ref()).unwrap();
closure.forget();
@@ -98,7 +98,7 @@ impl Window
fn add_mousewheel_event_listener(&self, events: Rc<RefCell<Vec<Event>>>)
{
let closure = Closure::wrap(Box::new(move |event: web_sys::WheelEvent| {
- (*events).borrow_mut().push(Event::MouseWheel {delta: event.delta_y() as f64});
+ (*events).borrow_mut().push(Event::MouseWheel {delta: 0.02499999912 * event.delta_y() as f64});
}) as Box<dyn FnMut(_)>);
self.canvas.add_event_listener_with_callback("wheel", closure.as_ref().unchecked_ref()).unwrap();
closure.forget();
