From 0f09a7eaa0e4fa2ea77cba051f8d1d5e0a725bac Mon Sep 17 00:00:00 2001 From: luoxiaozero <48741584+luoxiaozero@users.noreply.github.com> Date: Mon, 15 Jul 2024 21:17:49 +0800 Subject: [PATCH] fix: events were not removed when the scrollbar cleared (#216) --- thaw/src/scrollbar/mod.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/thaw/src/scrollbar/mod.rs b/thaw/src/scrollbar/mod.rs index 6ad6411..a7ec175 100644 --- a/thaw/src/scrollbar/mod.rs +++ b/thaw/src/scrollbar/mod.rs @@ -277,6 +277,29 @@ pub fn Scrollbar( thumb_status.set_value(Some(ThumbStatus::Enter)); }; + on_cleanup(move || { + x_trumb_mousemove_handle.update_value(|handle| { + if let Some(handle) = handle.take() { + handle.remove(); + } + }); + x_trumb_mouseup_handle.update_value(|handle| { + if let Some(handle) = handle.take() { + handle.remove(); + } + }); + y_trumb_mousemove_handle.update_value(|handle| { + if let Some(handle) = handle.take() { + handle.remove(); + } + }); + y_trumb_mouseup_handle.update_value(|handle| { + if let Some(handle) = handle.take() { + handle.remove(); + } + }); + }); + view! {