From 97212d7fda5ff2a68a264eb7f0837a5a817ed382 Mon Sep 17 00:00:00 2001 From: luoxiaozero <48741584+luoxiaozero@users.noreply.github.com> Date: Fri, 23 Aug 2024 23:17:47 +0800 Subject: [PATCH] fix: Scrollbar nested update value (#238) --- thaw/src/scrollbar/mod.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/thaw/src/scrollbar/mod.rs b/thaw/src/scrollbar/mod.rs index 6d4b37b..958aa6d 100644 --- a/thaw/src/scrollbar/mod.rs +++ b/thaw/src/scrollbar/mod.rs @@ -198,14 +198,14 @@ pub fn Scrollbar( handle.remove(); } }); - thumb_status.update_value(|thumb_status| { - if let Some(status) = thumb_status.take() { - if status == ThumbStatus::DelayLeave { - is_show_x_thumb.set(false); - is_show_y_thumb.set(false); - } + if let Some(Some(status)) = + thumb_status.try_update_value(|thumb_status| thumb_status.take()) + { + if status == ThumbStatus::DelayLeave { + is_show_x_thumb.set(false); + is_show_y_thumb.set(false); } - }); + } }); x_trumb_mouseup_handle.set_value(Some(handle)); memo_x_left.set_value(container_scroll_left.get()); @@ -251,14 +251,14 @@ pub fn Scrollbar( handle.remove(); } }); - thumb_status.update_value(|thumb_status| { - if let Some(status) = thumb_status.take() { - if status == ThumbStatus::DelayLeave { - is_show_x_thumb.set(false); - is_show_y_thumb.set(false); - } + if let Some(Some(status)) = + thumb_status.try_update_value(|thumb_status| thumb_status.take()) + { + if status == ThumbStatus::DelayLeave { + is_show_x_thumb.set(false); + is_show_y_thumb.set(false); } - }); + } }); y_trumb_mouseup_handle.set_value(Some(handle)); memo_y_top.set_value(container_scroll_top.get());