Skip to content

Commit 9fc4885

Browse files
authored
bugfix: Fix zoom on mobile (galileo-map#273)
This commit adds passing through the touch events to the event_processor which allows pinch zoom to work on touch devices.
1 parent 3ab722c commit 9fc4885

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

galileo-egui/src/egui_map.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use egui::{Event, Image, ImageSource, Sense, TextureId, Ui, Vec2};
88
use egui_wgpu::wgpu::{FilterMode, TextureView};
99
use egui_wgpu::RenderState;
1010
use galileo::control::{
11-
EventProcessor, MapController, MouseButton, RawUserEvent, UserEventHandler,
11+
EventProcessor, MapController, MouseButton, RawUserEvent, TouchEvent, UserEventHandler,
1212
};
1313
use galileo::galileo_types::cartesian::{Point2, Size};
1414
use galileo::galileo_types::geo::impls::GeoPoint2d;
@@ -434,6 +434,24 @@ impl<'a> EguiMapState {
434434

435435
Some(RawUserEvent::Scroll(zoom))
436436
}
437+
Event::Touch {
438+
device_id: _,
439+
id,
440+
phase,
441+
pos,
442+
force: _,
443+
} => {
444+
let event = TouchEvent {
445+
touch_id: id.0,
446+
position: Point2::new(pos.x as f64, pos.y as f64),
447+
};
448+
match phase {
449+
egui::TouchPhase::Start => Some(RawUserEvent::TouchStart(event)),
450+
egui::TouchPhase::Move => Some(RawUserEvent::TouchMove(event)),
451+
egui::TouchPhase::End => Some(RawUserEvent::TouchEnd(event)),
452+
egui::TouchPhase::Cancel => Some(RawUserEvent::TouchEnd(event)),
453+
}
454+
}
437455

438456
_ => None,
439457
}

0 commit comments

Comments
 (0)