Fix visualizations scrolling bug on Mac (#3215)

This commit is contained in:
Ilya Bogdanov 2022-01-10 14:51:59 +03:00 committed by GitHub
parent a4355876fa
commit e6f30c31a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 32 deletions

View File

@ -151,32 +151,3 @@ define_bindings! {
MouseEvent::mouseleave => on_leave (OnLeave),
WheelEvent::wheel => on_wheel (OnWheel),
}
/// A handles of callbacks emitting events on bound FRP graph. See `callback::Handle`.
#[derive(Debug)]
pub struct MouseFrpCallbackHandles {
on_move: callback::Handle,
on_down: callback::Handle,
on_up: callback::Handle,
on_wheel: callback::Handle,
}
// FIXME: This is obsolete. Use mouse bindings from scene instead.
/// Bind FRP graph to MouseManager.
pub fn bind_frp_to_mouse(frp: &Mouse, mouse_manager: &MouseManager) -> MouseFrpCallbackHandles {
let dom_shape = mouse_manager.dom.clone_ref().shape();
let on_move = enclose!((frp.position => frp) move |e:&OnMove| {
let position = Vector2(e.client_x() as f32,e.client_y() as f32);
let position = position - Vector2(dom_shape.width,dom_shape.height) / 2.0;
frp.emit(position);
});
let on_down = enclose!((frp.down => frp) move |_:&OnDown | frp.emit(Button0));
let on_up = enclose!((frp.up => frp) move |_:&OnUp | frp.emit(Button0));
let on_wheel = enclose!((frp.wheel => frp) move |_:&OnWheel| frp.emit(()));
MouseFrpCallbackHandles {
on_move: mouse_manager.on_move.add(on_move),
on_down: mouse_manager.on_down.add(on_down),
on_up: mouse_manager.on_up.add(on_up),
on_wheel: mouse_manager.on_wheel.add(on_wheel),
}
}

View File

@ -306,7 +306,7 @@ pub struct Mouse {
pub position: Uniform<Vector2<i32>>,
pub hover_ids: Uniform<Vector4<u32>>,
pub target: Rc<Cell<PointerTarget>>,
pub handles: Rc<[callback::Handle; 3]>,
pub handles: Rc<[callback::Handle; 4]>,
pub frp: enso_frp::io::Mouse,
pub scene_frp: Frp,
pub logger: Logger,
@ -355,7 +355,10 @@ impl Mouse {
current_js_event
.make_event_handler(f!((event:&mouse::OnUp) frp.up.emit(event.button()))),
);
let handles = Rc::new([on_move, on_down, on_up]);
let on_wheel = mouse_manager
.on_wheel
.add(current_js_event.make_event_handler(f_!(frp.wheel.emit(()))));
let handles = Rc::new([on_move, on_down, on_up, on_wheel]);
Self {
mouse_manager,
last_position,

View File

@ -185,7 +185,7 @@ impl CurrentJsEvent {
// asked to.
if let Some(e) = current {
if !is_passed {
// Prevent events from propagating ot user agent, so default browser actions will
// Prevent events from propagating to user agent, so default browser actions will
// not be triggered.
e.prevent_default();
e.stop_propagation();