mirror of
https://github.com/rust-windowing/winit.git
synced 2026-08-30 21:30:03 -04:00
Web: increase cursor position accuracy (#3380)
This commit is contained in:
@@ -28,6 +28,7 @@ Unreleased` header.
|
|||||||
- **Breaking:** Rename `VideoMode` to `VideoModeHandle` to represent that it doesn't hold static data.
|
- **Breaking:** Rename `VideoMode` to `VideoModeHandle` to represent that it doesn't hold static data.
|
||||||
- **Breaking:** No longer export `platform::x11::XNotSupported`.
|
- **Breaking:** No longer export `platform::x11::XNotSupported`.
|
||||||
- **Breaking:** Renamed `platform::x11::XWindowType` to `platform::x11::WindowType`.
|
- **Breaking:** Renamed `platform::x11::XWindowType` to `platform::x11::WindowType`.
|
||||||
|
- On Web, increase cursor position accuracy.
|
||||||
|
|
||||||
# 0.29.9
|
# 0.29.9
|
||||||
|
|
||||||
|
|||||||
@@ -81,9 +81,22 @@ impl MouseButton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn mouse_position(event: &MouseEvent) -> LogicalPosition<f64> {
|
pub fn mouse_position(event: &MouseEvent) -> LogicalPosition<f64> {
|
||||||
|
#[wasm_bindgen]
|
||||||
|
extern "C" {
|
||||||
|
type MouseEventExt;
|
||||||
|
|
||||||
|
#[wasm_bindgen(method, getter, js_name = offsetX)]
|
||||||
|
fn offset_x(this: &MouseEventExt) -> f64;
|
||||||
|
|
||||||
|
#[wasm_bindgen(method, getter, js_name = offsetY)]
|
||||||
|
fn offset_y(this: &MouseEventExt) -> f64;
|
||||||
|
}
|
||||||
|
|
||||||
|
let event: &MouseEventExt = event.unchecked_ref();
|
||||||
|
|
||||||
LogicalPosition {
|
LogicalPosition {
|
||||||
x: event.offset_x() as f64,
|
x: event.offset_x(),
|
||||||
y: event.offset_y() as f64,
|
y: event.offset_y(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user