mirror of
https://github.com/enso-org/enso.git
synced 2024-12-28 14:42:25 +03:00
Fix visualizations scrolling bug on Mac (#3215)
This commit is contained in:
parent
a4355876fa
commit
e6f30c31a8
@ -151,32 +151,3 @@ define_bindings! {
|
|||||||
MouseEvent::mouseleave => on_leave (OnLeave),
|
MouseEvent::mouseleave => on_leave (OnLeave),
|
||||||
WheelEvent::wheel => on_wheel (OnWheel),
|
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),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -306,7 +306,7 @@ pub struct Mouse {
|
|||||||
pub position: Uniform<Vector2<i32>>,
|
pub position: Uniform<Vector2<i32>>,
|
||||||
pub hover_ids: Uniform<Vector4<u32>>,
|
pub hover_ids: Uniform<Vector4<u32>>,
|
||||||
pub target: Rc<Cell<PointerTarget>>,
|
pub target: Rc<Cell<PointerTarget>>,
|
||||||
pub handles: Rc<[callback::Handle; 3]>,
|
pub handles: Rc<[callback::Handle; 4]>,
|
||||||
pub frp: enso_frp::io::Mouse,
|
pub frp: enso_frp::io::Mouse,
|
||||||
pub scene_frp: Frp,
|
pub scene_frp: Frp,
|
||||||
pub logger: Logger,
|
pub logger: Logger,
|
||||||
@ -355,7 +355,10 @@ impl Mouse {
|
|||||||
current_js_event
|
current_js_event
|
||||||
.make_event_handler(f!((event:&mouse::OnUp) frp.up.emit(event.button()))),
|
.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 {
|
Self {
|
||||||
mouse_manager,
|
mouse_manager,
|
||||||
last_position,
|
last_position,
|
||||||
|
@ -185,7 +185,7 @@ impl CurrentJsEvent {
|
|||||||
// asked to.
|
// asked to.
|
||||||
if let Some(e) = current {
|
if let Some(e) = current {
|
||||||
if !is_passed {
|
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.
|
// not be triggered.
|
||||||
e.prevent_default();
|
e.prevent_default();
|
||||||
e.stop_propagation();
|
e.stop_propagation();
|
||||||
|
Loading…
Reference in New Issue
Block a user