Skip to content

Commit

Permalink
Inline mouse wheel raw event closure
Browse files Browse the repository at this point in the history
It was meant only to be able to use the same variable names without
shadowing the rest of the code, but a simple block accomplishes the same
thing.
  • Loading branch information
YgorSouza committed Mar 29, 2023
1 parent 4d95a75 commit 3d1655d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions crates/eframe/src/web/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ pub fn install_canvas_events(runner_container: &mut AppRunnerContainer) -> Resul
&canvas,
"wheel",
|event: web_sys::WheelEvent, mut runner_lock| {
let mut push_raw_event = || {
{
let unit = match event.delta_mode() {
web_sys::WheelEvent::DOM_DELTA_PIXEL => egui::MouseWheelUnit::Point,
web_sys::WheelEvent::DOM_DELTA_LINE => egui::MouseWheelUnit::Line,
Expand All @@ -417,8 +417,7 @@ pub fn install_canvas_events(runner_container: &mut AppRunnerContainer) -> Resul
delta,
modifiers,
});
};
push_raw_event();
}
let scroll_multiplier = match event.delta_mode() {
web_sys::WheelEvent::DOM_DELTA_PAGE => {
canvas_size_in_points(runner_lock.canvas_id()).y
Expand Down
5 changes: 2 additions & 3 deletions crates/egui-winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ impl State {
}

fn on_mouse_wheel(&mut self, delta: winit::event::MouseScrollDelta) {
let mut push_raw_event = || {
{
let (unit, delta) = match delta {
winit::event::MouseScrollDelta::LineDelta(x, y) => {
(egui::MouseWheelUnit::Line, egui::vec2(x, y))
Expand All @@ -568,8 +568,7 @@ impl State {
delta,
modifiers,
});
};
push_raw_event();
}
let delta = match delta {
winit::event::MouseScrollDelta::LineDelta(x, y) => {
let points_per_scroll_line = 50.0; // Scroll speed decided by consensus: https://github.com/emilk/egui/issues/461
Expand Down

0 comments on commit 3d1655d

Please sign in to comment.