From 2412fb90eeb069fb831c8aa1903a9fe7a6b1f269 Mon Sep 17 00:00:00 2001 From: Sophie Herold Date: Wed, 4 Sep 2024 20:33:06 +0200 Subject: [PATCH] slidingView: Set current page before starting animation If animations are disabled, the animation ends when calling play returns. Therefore, everything has to be set before calling play when animations can be disabled. Closes #368 --- .../fixed-avoid-flickering-when-reloading-image | 0 .../47.0/fixed-wrong-image-shown-with-animations-disabled | 1 + src/widgets/sliding_view.rs | 7 ++++++- 3 files changed, 7 insertions(+), 1 deletion(-) rename news.d/{47.rc => 47.0}/fixed-avoid-flickering-when-reloading-image (100%) create mode 100644 news.d/47.0/fixed-wrong-image-shown-with-animations-disabled diff --git a/news.d/47.rc/fixed-avoid-flickering-when-reloading-image b/news.d/47.0/fixed-avoid-flickering-when-reloading-image similarity index 100% rename from news.d/47.rc/fixed-avoid-flickering-when-reloading-image rename to news.d/47.0/fixed-avoid-flickering-when-reloading-image diff --git a/news.d/47.0/fixed-wrong-image-shown-with-animations-disabled b/news.d/47.0/fixed-wrong-image-shown-with-animations-disabled new file mode 100644 index 0000000..a50107b --- /dev/null +++ b/news.d/47.0/fixed-wrong-image-shown-with-animations-disabled @@ -0,0 +1 @@ +When disabling animations in the OS and using the buttons to change the image, the wrong image was shown, disabling features like zoom. diff --git a/src/widgets/sliding_view.rs b/src/widgets/sliding_view.rs index 583de20..c83e829 100644 --- a/src/widgets/sliding_view.rs +++ b/src/widgets/sliding_view.rs @@ -356,6 +356,9 @@ mod imp { let position_shift = self.position_shift.get() as f32; let page_position = page_index as f32; + // Reset from potential stacked cards animation + page.set_opacity(1.); + // reverse page order for RTL languages let direction_sign = if self.is_rtl() { -1. } else { 1. }; @@ -617,6 +620,8 @@ impl LpSlidingView { *self.imp().position_tracking.borrow_mut() = PositionTracking::StackedCards(StackedCards::new(prev_page, backward)); + // Set current page here as well, to make sure it's set when animation completes for disabled animations + self.set_current_page(Some(page)); animation.play(); } } @@ -631,8 +636,8 @@ impl LpSlidingView { animation.set_value_from(self.position()); animation.set_value_to(index as f64 - self.position_shift()); animation.set_initial_velocity(initial_velocity); - animation.play(); self.set_current_page(Some(page)); + animation.play(); } else { log::error!("Page not in LpSlidingView {}", page.file().uri()); }