fix build issues

This commit is contained in:
Charles Edward Gagnon 2024-08-12 20:34:11 -04:00
parent 31f019a944
commit cb889066ce

View file

@ -109,10 +109,11 @@ where
move |event: web_sys::MouseEvent| { move |event: web_sys::MouseEvent| {
let result = coord_type.extract_mouse_coords(&event); let result = coord_type.extract_mouse_coords(&event);
let (x, y) = result; if let Some((x, y)) = result {
set_x.set(x); set_x.set(x);
set_y.set(y); set_y.set(y);
set_source_type.set(UseMouseSourceType::Mouse); set_source_type.set(UseMouseSourceType::Mouse);
}
} }
}; };
@ -137,10 +138,11 @@ where
.expect("Just checked that there's at least on touch"), .expect("Just checked that there's at least on touch"),
); );
let (x, y) = result; if let Some((x, y)) = result {
set_x.set(x); set_x.set(x);
set_y.set(y); set_y.set(y);
set_source_type.set(UseMouseSourceType::Touch); set_source_type.set(UseMouseSourceType::Touch);
}
} }
} }
}; };
@ -244,7 +246,7 @@ impl Default for UseMouseOptions<UseWindow, web_sys::Window, Infallible> {
/// Defines how to get the coordinates from the event. /// Defines how to get the coordinates from the event.
#[derive(Clone)] #[derive(Clone)]
pub enum UseMouseCoordType<E> { pub enum UseMouseCoordType<E: UseMouseEventExtractor + Clone> {
Page, Page,
Client, Client,
Screen, Screen,
@ -279,7 +281,9 @@ impl<E: UseMouseEventExtractor + Clone> UseMouseEventExtractor for UseMouseCoord
UseMouseCoordType::Client => (event.client_x() as f64, event.client_y() as f64), UseMouseCoordType::Client => (event.client_x() as f64, event.client_y() as f64),
UseMouseCoordType::Screen => (event.screen_x() as f64, event.client_y() as f64), UseMouseCoordType::Screen => (event.screen_x() as f64, event.client_y() as f64),
UseMouseCoordType::Movement => (event.movement_x() as f64, event.movement_y() as f64), UseMouseCoordType::Movement => (event.movement_x() as f64, event.movement_y() as f64),
UseMouseCoordType::Custom(ref extractor) => return extractor.extract_mouse_coords(event), UseMouseCoordType::Custom(ref extractor) => {
return extractor.extract_mouse_coords(event)
}
}) })
} }
@ -289,7 +293,9 @@ impl<E: UseMouseEventExtractor + Clone> UseMouseEventExtractor for UseMouseCoord
UseMouseCoordType::Client => (touch.client_x() as f64, touch.client_y() as f64), UseMouseCoordType::Client => (touch.client_x() as f64, touch.client_y() as f64),
UseMouseCoordType::Screen => (touch.screen_x() as f64, touch.client_y() as f64), UseMouseCoordType::Screen => (touch.screen_x() as f64, touch.client_y() as f64),
UseMouseCoordType::Movement => return None, UseMouseCoordType::Movement => return None,
UseMouseCoordType::Custom(ref extractor) => return extractor.extract_touch_coords(touch), UseMouseCoordType::Custom(ref extractor) => {
return extractor.extract_touch_coords(touch)
}
}) })
} }
} }