Web: increase cursor position accuracy (#3380)
This commit is contained in:
parent
816798bfd1
commit
4fe38d8067
2 changed files with 16 additions and 2 deletions
|
|
@ -28,6 +28,7 @@ Unreleased` header.
|
|||
- **Breaking:** Rename `VideoMode` to `VideoModeHandle` to represent that it doesn't hold static data.
|
||||
- **Breaking:** No longer export `platform::x11::XNotSupported`.
|
||||
- **Breaking:** Renamed `platform::x11::XWindowType` to `platform::x11::WindowType`.
|
||||
- On Web, increase cursor position accuracy.
|
||||
|
||||
# 0.29.9
|
||||
|
||||
|
|
|
|||
|
|
@ -81,9 +81,22 @@ impl MouseButton {
|
|||
}
|
||||
|
||||
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 {
|
||||
x: event.offset_x() as f64,
|
||||
y: event.offset_y() as f64,
|
||||
x: event.offset_x(),
|
||||
y: event.offset_y(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue