optimize animation
This commit is contained in:
		| @@ -17,7 +17,7 @@ | ||||
|         <ScrollView x:Name="scrollView" Scrolled="ScrollView_Scrolled" | ||||
|                     HorizontalOptions="Fill" HorizontalScrollBarVisibility="Never"> | ||||
|             <StackLayout> | ||||
|                 <ActivityIndicator x:Name="activityLoading" Margin="0, 16, 0, 0" | ||||
|                 <ActivityIndicator x:Name="activityLoading" Margin="0, -40, 0, 0" | ||||
|                                    HeightRequest="40" | ||||
|                                    IsRunning="{Binding IsLoading}" | ||||
|                                    IsVisible="{Binding IsLoading}"/> | ||||
|   | ||||
| @@ -12,7 +12,7 @@ namespace Pixiview.Illust | ||||
| { | ||||
|     public partial class FavoritesPage : FavoriteIllustCollectionPage | ||||
|     { | ||||
|         private const int STEP = 24; | ||||
|         private const int STEP = 20; | ||||
|  | ||||
|         private int startIndex; | ||||
|         private int nextIndex; | ||||
|   | ||||
| @@ -200,7 +200,7 @@ namespace Pixiview.Illust | ||||
|                 lastUpdated = LastUpdated; | ||||
|  | ||||
|                 var indicator = LoadingIndicator; | ||||
|                 if (indicator == null) | ||||
|                 if (indicator == null || isBottom) | ||||
|                 { | ||||
|                     if (isBottom) | ||||
|                     { | ||||
| @@ -212,35 +212,28 @@ namespace Pixiview.Illust | ||||
|                         IsLoading = true; | ||||
|                     } | ||||
| #if __IOS__ | ||||
|                     Task.Run(() => DoLoadIllusts(force, isBottom)); | ||||
|                     Device.StartTimer(TimeSpan.FromMilliseconds(48), () => | ||||
| #else | ||||
|                     Device.StartTimer(TimeSpan.FromMilliseconds(150), () => | ||||
| #endif | ||||
|                     { | ||||
|                         Task.Run(() => DoLoadIllusts(force, isBottom)); | ||||
|                         return false; | ||||
|                     }); | ||||
| #endif | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     InvalidateCollection(); | ||||
|                     IsLoading = true; | ||||
|  | ||||
|                     var offset = 16 - IndicatorMarginTop; | ||||
|                     indicator.Margin = new Thickness(0, loadingOffset - offset, 0, offset); | ||||
|                     if (isBottom) | ||||
|                     { | ||||
|                         IsBottomLoading = true; | ||||
|                     } | ||||
|                     else | ||||
|                     { | ||||
|                         InvalidateCollection(); | ||||
|                         IsLoading = true; | ||||
|                     } | ||||
|                     indicator.Animate("margin", top => | ||||
|                     { | ||||
|                         indicator.Margin = new Thickness(0, top, 0, offset); | ||||
|                     }, | ||||
|                     loadingOffset - offset, 16 - offset, easing: Easing.CubicOut, finished: (v, r) => | ||||
|                     { | ||||
|                         Task.Run(() => DoLoadIllusts(force, isBottom)); | ||||
|                         _ = Task.Run(() => DoLoadIllusts(force, isBottom)); | ||||
|                     }); | ||||
|                 } | ||||
|             } | ||||
| @@ -253,9 +246,17 @@ namespace Pixiview.Illust | ||||
|             var indicator = LoadingIndicator; | ||||
|             if (indicator == null || bottom) | ||||
|             { | ||||
|                 Illusts = collection; | ||||
|                 IsLoading = false; | ||||
|                 IsBottomLoading = false; | ||||
| #if __IOS__ | ||||
|                 Device.StartTimer(TimeSpan.FromMilliseconds(48), () => | ||||
| #else | ||||
|                 Device.StartTimer(TimeSpan.FromMilliseconds(150), () => | ||||
| #endif | ||||
|                 { | ||||
|                     Illusts = collection; | ||||
|                     return false; | ||||
|                 }); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
| @@ -266,17 +267,18 @@ namespace Pixiview.Illust | ||||
|                 }, | ||||
|                 16 - offset, loadingOffset - offset, easing: Easing.CubicIn, finished: (v, r) => | ||||
|                 { | ||||
|                     indicator.Margin = new Thickness(0, v, 0, offset); | ||||
|                     IsLoading = false; | ||||
|                     IsBottomLoading = false; | ||||
| #if __IOS__ | ||||
|                     Illusts = collection; | ||||
|                     Device.StartTimer(TimeSpan.FromMilliseconds(48), () => | ||||
| #else | ||||
|                     Device.StartTimer(TimeSpan.FromMilliseconds(150), () => | ||||
| #endif | ||||
|                     { | ||||
|                         Illusts = collection; | ||||
|                         return false; | ||||
|                     }); | ||||
| #endif | ||||
|                 }); | ||||
|             } | ||||
|         } | ||||
|   | ||||
| @@ -15,7 +15,7 @@ | ||||
|         <ScrollView x:Name="scrollView" Scrolled="ScrollView_Scrolled" | ||||
|                     HorizontalOptions="Fill" HorizontalScrollBarVisibility="Never"> | ||||
|             <StackLayout> | ||||
|                 <ActivityIndicator x:Name="activityLoading" Margin="0, 66, 0, 0" | ||||
|                 <ActivityIndicator x:Name="activityLoading" Margin="0, 10, 0, 0" | ||||
|                                    HeightRequest="40" | ||||
|                                    IsRunning="{Binding IsLoading}" | ||||
|                                    IsVisible="{Binding IsLoading}"/> | ||||
|   | ||||
| @@ -49,7 +49,7 @@ | ||||
|         <ScrollView x:Name="scrollView" Scrolled="ScrollView_Scrolled" | ||||
|                     HorizontalOptions="Fill" HorizontalScrollBarVisibility="Never"> | ||||
|             <StackLayout> | ||||
|                 <ActivityIndicator x:Name="activityLoading" Margin="0, 16, 0, 0" | ||||
|                 <ActivityIndicator x:Name="activityLoading" Margin="0, -40, 0, 0" | ||||
|                                    HeightRequest="40" | ||||
|                                    IsRunning="{Binding IsLoading}" | ||||
|                                    IsVisible="{Binding IsLoading}"/> | ||||
|   | ||||
| @@ -14,7 +14,7 @@ | ||||
|     <Grid> | ||||
|         <ScrollView x:Name="scrollView" HorizontalOptions="Fill" HorizontalScrollBarVisibility="Never"> | ||||
|             <StackLayout> | ||||
|                 <ActivityIndicator x:Name="activityLoading" Margin="0, 16, 0, 0" | ||||
|                 <ActivityIndicator x:Name="activityLoading" Margin="0, -40, 0, 0" | ||||
|                                    HeightRequest="40" | ||||
|                                    IsRunning="{Binding IsLoading}" | ||||
|                                    IsVisible="{Binding IsLoading}"/> | ||||
|   | ||||
| @@ -286,16 +286,15 @@ namespace Pixiview.Illust | ||||
|                 IsLoading = false; | ||||
|                 UserRecommendsVisible = list.Count > 0; | ||||
| #if __IOS__ | ||||
|                 Users = list; | ||||
|                 Illusts = IllustCollection; | ||||
|                 Device.StartTimer(TimeSpan.FromMilliseconds(48), () => | ||||
| #else | ||||
|                 Device.StartTimer(TimeSpan.FromMilliseconds(150), () => | ||||
| #endif | ||||
|                 { | ||||
|                     Users = list; | ||||
|                     Illusts = IllustCollection; | ||||
|                     return false; | ||||
|                 }); | ||||
| #endif | ||||
|             }); | ||||
|  | ||||
|             DoLoadUserRecommendsImages(list); | ||||
|   | ||||
| @@ -15,7 +15,7 @@ | ||||
|         <ScrollView x:Name="scrollView" Scrolled="ScrollView_Scrolled" | ||||
|                     HorizontalOptions="Fill" HorizontalScrollBarVisibility="Never"> | ||||
|             <StackLayout> | ||||
|                 <ActivityIndicator x:Name="activityLoading" Margin="0, 16, 0, 0" | ||||
|                 <ActivityIndicator x:Name="activityLoading" Margin="0, -40, 0, 0" | ||||
|                                    HeightRequest="40" | ||||
|                                    IsRunning="{Binding IsLoading}" | ||||
|                                    IsVisible="{Binding IsLoading}"/> | ||||
|   | ||||
| @@ -27,7 +27,7 @@ | ||||
|         <ScrollView x:Name="scrollView" Scrolled="ScrollView_Scrolled" | ||||
|                     HorizontalOptions="Fill" HorizontalScrollBarVisibility="Never"> | ||||
|             <StackLayout> | ||||
|                 <ActivityIndicator x:Name="activityLoading" Margin="0, 16, 0, 0" | ||||
|                 <ActivityIndicator x:Name="activityLoading" Margin="0, -40, 0, 0" | ||||
|                                    HeightRequest="40" | ||||
|                                    IsRunning="{Binding IsLoading}" | ||||
|                                    IsVisible="{Binding IsLoading}"/> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user