mirror of
https://github.com/adoyle0/leptos-use.git
synced 2025-02-02 10:54:15 -05:00
remove useless code churn
remove useless type
This commit is contained in:
parent
5d6d55dd89
commit
72cc82713d
2 changed files with 16 additions and 18 deletions
|
@ -276,27 +276,25 @@ pub trait UseMouseEventExtractor {
|
||||||
|
|
||||||
impl<E: UseMouseEventExtractor + Clone> UseMouseEventExtractor for UseMouseCoordType<E> {
|
impl<E: UseMouseEventExtractor + Clone> UseMouseEventExtractor for UseMouseCoordType<E> {
|
||||||
fn extract_mouse_coords(&self, event: &web_sys::MouseEvent) -> Option<(f64, f64)> {
|
fn extract_mouse_coords(&self, event: &web_sys::MouseEvent) -> Option<(f64, f64)> {
|
||||||
Some(match self {
|
match self {
|
||||||
UseMouseCoordType::Page => (event.page_x() as f64, event.page_y() as f64),
|
UseMouseCoordType::Page => Some((event.page_x() as f64, event.page_y() as f64)),
|
||||||
UseMouseCoordType::Client => (event.client_x() as f64, event.client_y() as f64),
|
UseMouseCoordType::Client => Some((event.client_x() as f64, event.client_y() as f64)),
|
||||||
UseMouseCoordType::Screen => (event.screen_x() as f64, event.client_y() as f64),
|
UseMouseCoordType::Screen => Some((event.screen_x() as f64, event.client_y() as f64)),
|
||||||
UseMouseCoordType::Movement => (event.movement_x() as f64, event.movement_y() as f64),
|
UseMouseCoordType::Movement => {
|
||||||
UseMouseCoordType::Custom(ref extractor) => {
|
Some((event.movement_x() as f64, event.movement_y() as f64))
|
||||||
return extractor.extract_mouse_coords(event)
|
}
|
||||||
|
UseMouseCoordType::Custom(ref extractor) => extractor.extract_mouse_coords(event),
|
||||||
}
|
}
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn extract_touch_coords(&self, touch: &web_sys::Touch) -> Option<(f64, f64)> {
|
fn extract_touch_coords(&self, touch: &web_sys::Touch) -> Option<(f64, f64)> {
|
||||||
Some(match self {
|
match self {
|
||||||
UseMouseCoordType::Page => (touch.page_x() as f64, touch.page_y() as f64),
|
UseMouseCoordType::Page => Some((touch.page_x() as f64, touch.page_y() as f64)),
|
||||||
UseMouseCoordType::Client => (touch.client_x() as f64, touch.client_y() as f64),
|
UseMouseCoordType::Client => Some((touch.client_x() as f64, touch.client_y() as f64)),
|
||||||
UseMouseCoordType::Screen => (touch.screen_x() as f64, touch.client_y() as f64),
|
UseMouseCoordType::Screen => Some((touch.screen_x() as f64, touch.client_y() as f64)),
|
||||||
UseMouseCoordType::Movement => return None,
|
UseMouseCoordType::Movement => None,
|
||||||
UseMouseCoordType::Custom(ref extractor) => {
|
UseMouseCoordType::Custom(ref extractor) => extractor.extract_touch_coords(touch),
|
||||||
return extractor.extract_touch_coords(touch)
|
|
||||||
}
|
}
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -199,7 +199,7 @@ where
|
||||||
impl Default for UseMouseInElementOptions<UseWindow, web_sys::Window, Infallible> {
|
impl Default for UseMouseInElementOptions<UseWindow, web_sys::Window, Infallible> {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
coord_type: UseMouseCoordType::<Infallible>::default(),
|
coord_type: UseMouseCoordType::default(),
|
||||||
target: use_window(),
|
target: use_window(),
|
||||||
touch: true,
|
touch: true,
|
||||||
reset_on_touch_ends: false,
|
reset_on_touch_ends: false,
|
||||||
|
|
Loading…
Add table
Reference in a new issue