mirror of
https://github.com/maplibre/maplibre-rs.git
synced 2025-12-08 19:05:57 +00:00
Fix hidpi on web (#294)
* Set wasm-bindgen version * Expose scaling factor
This commit is contained in:
parent
ad95f7665f
commit
8b3c9ef7d0
@ -63,7 +63,7 @@ image = { version = "0.24", default-features = false, features = ["jpeg", "webp"
|
||||
include_dir = "0.7.3"
|
||||
instant = { version = "0.1.12", features = ["wasm-bindgen"] } # TODO: Untrusted dependency
|
||||
jni = "0.21.1"
|
||||
js-sys = "0.3.64"
|
||||
js-sys = "0.3"
|
||||
log = "0.4.20"
|
||||
lyon = { version = "1.0.1", features = [] }
|
||||
naga = { version = "0.13.0", features = ["wgsl-in"] }
|
||||
@ -87,10 +87,10 @@ tracing-subscriber = "0.3.17"
|
||||
tracing-tracy = "0.10"
|
||||
tracing-wasm = "0.2.1" # TODO: Low quality dependency (remove in a separate PR!)
|
||||
walkdir = "2.4.0"
|
||||
wasm-bindgen = "0.2"
|
||||
wasm-bindgen = "=0.2.87"
|
||||
wasm-bindgen-futures = "0.4"
|
||||
wasm-bindgen-test = "0.3"
|
||||
web-sys = "0.3.64" # Individual features are customized in each crate
|
||||
web-sys = "0.3" # Individual features are customized in each crate
|
||||
wgpu = "0.17.0"
|
||||
|
||||
[profile.release]
|
||||
|
||||
@ -56,6 +56,10 @@ impl<ET> HeadedMapWindow for WinitMapWindow<ET> {
|
||||
self.window.request_redraw()
|
||||
}
|
||||
|
||||
fn scale_factor(&self) -> f64 {
|
||||
self.window.scale_factor()
|
||||
}
|
||||
|
||||
fn id(&self) -> u64 {
|
||||
self.window.id().into()
|
||||
}
|
||||
@ -77,7 +81,7 @@ impl<ET: 'static + PartialEq + Debug> EventLoop<ET> for WinitEventLoop<ET> {
|
||||
let mut current_frame: u64 = 0;
|
||||
|
||||
let mut input_controller = InputController::new(0.2, 100.0, 0.1);
|
||||
let mut scale_factor = 1.0;
|
||||
let mut scale_factor = map.window().scale_factor();
|
||||
|
||||
self.event_loop
|
||||
.run(move |event, _window_target, control_flow| {
|
||||
@ -125,6 +129,7 @@ impl<ET: 'static + PartialEq + Debug> EventLoop<ET> for WinitEventLoop<ET> {
|
||||
}
|
||||
WindowEvent::ScaleFactorChanged { new_inner_size: winit::dpi::PhysicalSize { width, height}, scale_factor: new_scale_factor } => {
|
||||
if let Ok(map_context) = map.context_mut() {
|
||||
log::info!("New scaling factor: {}", new_scale_factor);
|
||||
scale_factor = *new_scale_factor;
|
||||
let size = PhysicalSize::new(*width, *height).expect("window values should not be zero");
|
||||
map_context.resize(size, scale_factor);
|
||||
|
||||
@ -19,6 +19,8 @@ pub trait HeadedMapWindow: MapWindow {
|
||||
// TODO: Can we avoid this?
|
||||
fn request_redraw(&self);
|
||||
|
||||
fn scale_factor(&self) -> f64;
|
||||
|
||||
fn id(&self) -> u64;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user