From d3aeff8838e0491b545101ea7c7bef0158169e3c Mon Sep 17 00:00:00 2001 From: dAxpeDDa Date: Sun, 4 Jun 2023 12:46:03 +0200 Subject: [PATCH] Remove unnecessary `preventDefault()` calls --- src/platform_impl/web/event_loop/window_target.rs | 1 - src/platform_impl/web/web_sys/canvas.rs | 8 -------- src/platform_impl/web/web_sys/pointer.rs | 8 +------- 3 files changed, 1 insertion(+), 16 deletions(-) diff --git a/src/platform_impl/web/event_loop/window_target.rs b/src/platform_impl/web/event_loop/window_target.rs index 310c0a86..d1ba53e8 100644 --- a/src/platform_impl/web/event_loop/window_target.rs +++ b/src/platform_impl/web/event_loop/window_target.rs @@ -91,7 +91,6 @@ impl EventLoopWindowTarget { canvas.set_attribute("data-raw-handle", &id.0.to_string()); canvas.on_touch_start(prevent_default); - canvas.on_touch_end(prevent_default); let runner = self.runner.clone(); let has_focus_clone = has_focus.clone(); diff --git a/src/platform_impl/web/web_sys/canvas.rs b/src/platform_impl/web/web_sys/canvas.rs index a7faeea4..8d3d5a07 100644 --- a/src/platform_impl/web/web_sys/canvas.rs +++ b/src/platform_impl/web/web_sys/canvas.rs @@ -138,14 +138,6 @@ impl Canvas { })); } - pub fn on_touch_end(&mut self, prevent_default: bool) { - self.on_touch_end = Some(self.common.add_event("touchend", move |event: Event| { - if prevent_default { - event.prevent_default(); - } - })); - } - pub fn on_blur(&mut self, mut handler: F) where F: 'static + FnMut(), diff --git a/src/platform_impl/web/web_sys/pointer.rs b/src/platform_impl/web/web_sys/pointer.rs index c21fa4c3..c24355b6 100644 --- a/src/platform_impl/web/web_sys/pointer.rs +++ b/src/platform_impl/web/web_sys/pointer.rs @@ -203,13 +203,7 @@ impl PointerHandler { let pointer_type = event.pointer_type(); match pointer_type.as_str() { - "touch" => { - if prevent_default { - // prevent scroll on mobile web - event.prevent_default(); - } - } - "mouse" => (), + "touch" | "mouse" => (), _ => return, }