Skip to content

Commit 11b0acd

Browse files
https://github.com/AndreiMisiukevich/CardView/issues/337
1 parent a351588 commit 11b0acd

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

PanCardView/CardsView.cs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -812,11 +812,9 @@ protected virtual async Task<bool> TryAutoNavigate()
812812
StartAutoNavigation(views, animationId, animationDirection);
813813

814814
//https://github.com/AndreiMisiukevich/CardView/issues/335
815-
Action<double> handlePanChanged = null;
816-
if (Device.RuntimePlatform == Device.UWP)
815+
if (Device.RuntimePlatform == Device.UWP && ItemTemplate == null)
817816
{
818-
handlePanChanged = value => FrontViewProcessor.HandlePanChanged(Enumerable.Repeat(CurrentView, 1), this, value, realDirection, Enumerable.Empty<View>());
819-
handlePanChanged?.Invoke(Size);
817+
FrontViewProcessor.HandlePanChanged(Enumerable.Repeat(CurrentView, 1), this, Size, realDirection, Enumerable.Empty<View>());
820818
}
821819

822820
await Task.Delay(5);
@@ -826,8 +824,6 @@ protected virtual async Task<bool> TryAutoNavigate()
826824

827825
await (_animationTask = autoNavigationTask);
828826

829-
handlePanChanged?.Invoke(0);
830-
831827
EndAutoNavigation(views, animationId, animationDirection);
832828

833829
return true;
@@ -1137,17 +1133,26 @@ private void OnTouchChanged(double diff, double oppositeDirectionDiff, bool isTo
11371133

11381134
interactionItem.IsInvolved = true;
11391135
ResetActiveInactiveBackViews(diff);
1136+
var prevDiff = CurrentDiff;
11401137
CurrentDiff = diff;
11411138
SetupDiffItems(diff);
11421139

11431140
if (isTouchCompleted)
11441141
{
1145-
return;
1142+
diff = prevDiff;
11461143
}
11471144

1148-
FireUserInteracted(UserInteractionStatus.Running, CurrentDiff, SelectedIndex);
1149-
FrontViewProcessor.HandlePanChanged(Enumerable.Repeat(CurrentView, 1), this, diff, _currentBackAnimationDirection, Enumerable.Empty<View>());
1150-
BackViewProcessor.HandlePanChanged(CurrentBackViews, this, diff, _currentBackAnimationDirection, CurrentInactiveBackViews);
1145+
FireUserInteracted(UserInteractionStatus.Running, diff, SelectedIndex);
1146+
try
1147+
{
1148+
BatchBegin();
1149+
FrontViewProcessor.HandlePanChanged(Enumerable.Repeat(CurrentView, 1), this, diff, _currentBackAnimationDirection, Enumerable.Empty<View>());
1150+
BackViewProcessor.HandlePanChanged(CurrentBackViews, this, diff, _currentBackAnimationDirection, CurrentInactiveBackViews);
1151+
}
1152+
finally
1153+
{
1154+
BatchCommit();
1155+
}
11511156
}
11521157

11531158
private async void OnTouchEnded()

0 commit comments

Comments
 (0)