From fb19f9b3f31404b91a9b80a78d8bcadcfdb116e3 Mon Sep 17 00:00:00 2001 From: Tsanie Lily Date: Sun, 17 May 2020 11:51:51 +0800 Subject: [PATCH] optimize: keep filter opened while scrolling --- Pixiview/Illust/IllustCollectionPage.cs | 2 +- Pixiview/Illust/RankingPage.xaml.cs | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Pixiview/Illust/IllustCollectionPage.cs b/Pixiview/Illust/IllustCollectionPage.cs index f90ef0a..81b2a8a 100644 --- a/Pixiview/Illust/IllustCollectionPage.cs +++ b/Pixiview/Illust/IllustCollectionPage.cs @@ -614,7 +614,7 @@ namespace Pixiview.Illust private double lastRefreshY = double.MinValue; private double offset; - protected bool ScrollingDown(double y) + protected bool IsScrollingDown(double y) { return y > lastScrollY; } diff --git a/Pixiview/Illust/RankingPage.xaml.cs b/Pixiview/Illust/RankingPage.xaml.cs index 6ab2307..4268f96 100644 --- a/Pixiview/Illust/RankingPage.xaml.cs +++ b/Pixiview/Illust/RankingPage.xaml.cs @@ -86,6 +86,7 @@ namespace Pixiview.Illust private bool previousEnabled; private bool dateEnabled; private bool nextEnabled; + private ScrollDirection scrollDirection = ScrollDirection.Stop; private bool isFilterVisible; private string lastQueryKey; @@ -229,6 +230,11 @@ namespace Pixiview.Illust if (flag) { isFilterVisible = true; + if (scrollDirection == ScrollDirection.Down) + { + // stop the scrolling + await scrollView.ScrollToAsync(0, scrollView.ScrollY, false); + } await Task.WhenAll( labelCaret.RotateTo(180, easing: Easing.CubicOut), gridFilter.TranslateTo(0, 0, easing: Easing.CubicOut), @@ -324,14 +330,25 @@ namespace Pixiview.Illust private void ScrollView_Scrolled(object sender, ScrolledEventArgs e) { var y = e.ScrollY; - if (ScrollingDown(y)) + if (IsScrollingDown(y)) { + if (scrollDirection != ScrollDirection.Down) + { + scrollDirection = ScrollDirection.Down; + } // down if (isFilterVisible) { ToggleFilterPanel(false); } } + else + { + if (scrollDirection != ScrollDirection.Up) + { + scrollDirection = ScrollDirection.Up; + } + } OnScrolled(y); }