Skip to content

Commit 6604f2e

Browse files
https://github.com/AndreiMisiukevich/CardView/issues/335
1 parent 1fbadd6 commit 6604f2e

File tree

1 file changed

+30
-18
lines changed

1 file changed

+30
-18
lines changed

PanCardView/CardsView.cs

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ public bool IsViewReusingEnabled
383383

384384
public int UserInteractionDelay
385385
{
386-
get =>(int)GetValue(UserInteractionDelayProperty);
386+
get => (int)GetValue(UserInteractionDelayProperty);
387387
set => SetValue(UserInteractionDelayProperty, value);
388388
}
389389

@@ -552,7 +552,7 @@ public void OnPanUpdated(PanUpdatedEventArgs e)
552552

553553
var diff = e.TotalX;
554554
var oppositeDirectionDiff = e.TotalY;
555-
if(!IsHorizontalOrientation)
555+
if (!IsHorizontalOrientation)
556556
{
557557
var tempDiff = diff;
558558
diff = oppositeDirectionDiff;
@@ -626,7 +626,7 @@ public virtual async void ForceRedrawViews()
626626
//https://github.com/AndreiMisiukevich/CardView/issues/313
627627
(BackViewsDepth > 1 && (IsAutoInteractionRunning || IsUserInteractionRunning));
628628

629-
if(isHardSet)
629+
if (isHardSet)
630630
{
631631
await HardSetAsync();
632632
return;
@@ -803,21 +803,33 @@ protected virtual async Task<bool> TryAutoNavigate()
803803
SwapViews(realDirection);
804804
CurrentView = newView;
805805

806-
807806
var views = CurrentBackViews
808807
.Union(CurrentInactiveBackViews)
809808
.Union(Enumerable.Repeat(CurrentView, 1))
810809
.Where(x => x != null);
811810

812811
var animationId = Guid.NewGuid();
813812
StartAutoNavigation(views, animationId, animationDirection);
813+
814+
//https://github.com/AndreiMisiukevich/CardView/issues/335
815+
if (Device.RuntimePlatform == Device.UWP)
816+
{
817+
FrontViewProcessor.HandlePanChanged(Enumerable.Repeat(CurrentView, 1), this, CurrentView.TranslationX, realDirection, Enumerable.Empty<View>());
818+
}
819+
814820
await Task.Delay(5);
815821
var autoNavigationTask = Task.WhenAll(
816822
BackViewProcessor.HandleAutoNavigate(CurrentBackViews, this, realDirection, CurrentInactiveBackViews),
817823
FrontViewProcessor.HandleAutoNavigate(Enumerable.Repeat(CurrentView, 1), this, realDirection, Enumerable.Empty<View>()));
818824

819825
await (_animationTask = autoNavigationTask);
820826

827+
//https://github.com/AndreiMisiukevich/CardView/issues/335
828+
if (Device.RuntimePlatform == Device.UWP)
829+
{
830+
FrontViewProcessor.HandlePanChanged(Enumerable.Repeat(CurrentView, 1), this, 0, realDirection, Enumerable.Empty<View>());
831+
}
832+
821833
EndAutoNavigation(views, animationId, animationDirection);
822834

823835
return true;
@@ -940,7 +952,7 @@ private IEnumerable<View> SetupPrevView(int index, IEnumerable<View> bookedViews
940952
}
941953

942954
private void StoreParentSize(double width, double height)
943-
=> _parentSize = new Size(width, height);
955+
=> _parentSize = new Size(width, height);
944956

945957
private void SetPanGesture(bool isForceRemoving = false)
946958
{
@@ -1130,7 +1142,7 @@ private void OnTouchChanged(double diff, double oppositeDirectionDiff, bool isTo
11301142
CurrentDiff = diff;
11311143
SetupDiffItems(diff);
11321144

1133-
if(isTouchCompleted)
1145+
if (isTouchCompleted)
11341146
{
11351147
return;
11361148
}
@@ -1392,7 +1404,7 @@ private void SwapViews(bool isNext)
13921404
}
13931405

13941406
private void SwapViews(AnimationDirection animationDirection)
1395-
=> SwapViews(animationDirection == AnimationDirection.Next);
1407+
=> SwapViews(animationDirection == AnimationDirection.Next);
13961408

13971409
private IEnumerable<View> InitViews(ICardProcessor processor, AnimationDirection animationDirection, IEnumerable<View> bookedViews, params int[] indeces)
13981410
{
@@ -1475,13 +1487,13 @@ private View CreateRetrieveView(object context, DataTemplate template, IEnumerab
14751487

14761488
var notUsingViews = viewsCollection.Where(v => !_viewsInUseSet.Contains(v) && !bookedViews.Contains(v));
14771489
var view = notUsingViews.FirstOrDefault(v => Equals(v.BindingContext, context) || v == context);
1478-
if(IsViewReusingEnabled)
1490+
if (IsViewReusingEnabled)
14791491
{
14801492
view = view ?? notUsingViews.FirstOrDefault(v => v.BindingContext == null)
14811493
?? notUsingViews.FirstOrDefault(v => !CheckIsProcessingView(v));
14821494
}
14831495

1484-
if(ShouldShareViewAmongSameItems)
1496+
if (ShouldShareViewAmongSameItems)
14851497
{
14861498
view = bookedViews.FirstOrDefault(v => Equals(v.BindingContext, context)) ?? view;
14871499
}
@@ -1531,7 +1543,7 @@ private object GetContext(int index, bool isCurrent)
15311543

15321544
private void RemoveRangeViewsPool(View[] views)
15331545
{
1534-
foreach(var view in views)
1546+
foreach (var view in views)
15351547
{
15361548
foreach (var viewsCollection in _viewsPool.Values)
15371549
{
@@ -1541,12 +1553,12 @@ private void RemoveRangeViewsPool(View[] views)
15411553
}
15421554

15431555
private bool CheckContextAssigned(View view)
1544-
=> view?.Behaviors.Contains(_contextAssignedBehavior) ?? false;
1556+
=> view?.Behaviors.Contains(_contextAssignedBehavior) ?? false;
15451557

15461558
private object GetItem(View view)
1547-
=> CheckContextAssigned(view)
1548-
? view.BindingContext
1549-
: view;
1559+
=> CheckContextAssigned(view)
1560+
? view.BindingContext
1561+
: view;
15501562

15511563
private object GetItem(int index)
15521564
{
@@ -1737,15 +1749,15 @@ private void RemoveChildren(View[] views)
17371749
CleanView(view);
17381750
}
17391751

1740-
if(!IsViewReusingEnabled)
1752+
if (!IsViewReusingEnabled)
17411753
{
17421754
RemoveRangeViewsPool(views);
17431755
}
17441756
}
17451757

17461758
private void InvokeOnMainThreadIfNeeded(Action action)
17471759
{
1748-
if(Device.IsInvokeRequired)
1760+
if (Device.IsInvokeRequired)
17491761
{
17501762
Device.BeginInvokeOnMainThread(action);
17511763
return;
@@ -1788,10 +1800,10 @@ private Page FindParentPage()
17881800
}
17891801

17901802
private bool CheckIsProcessingView(View view)
1791-
=> view == CurrentView || NextViews.Contains(view) || PrevViews.Contains(view);
1803+
=> view == CurrentView || NextViews.Contains(view) || PrevViews.Contains(view);
17921804

17931805
private bool CheckIndexValid(int index)
1794-
=> index >= 0 && index < ItemsCount;
1806+
=> index >= 0 && index < ItemsCount;
17951807

17961808
private void AddRangeViewsInUse(Guid gestureId)
17971809
{

0 commit comments

Comments
 (0)