From de291390d78c2a33efe09b4ab481824d60f756b2 Mon Sep 17 00:00:00 2001 From: Agustin Bonilla Date: Thu, 22 Feb 2024 18:16:51 -0300 Subject: [PATCH] Fix the issue with taps over a Card that is inside a ScrollView --- MaterialDesignControls.nuspec | 2 +- .../Animations/TouchAndPressAnimation.cs | 7 ++++++- .../ControlsMaterial3/MaterialCard.cs | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/MaterialDesignControls.nuspec b/MaterialDesignControls.nuspec index 459f1ba6..1a38b6d8 100755 --- a/MaterialDesignControls.nuspec +++ b/MaterialDesignControls.nuspec @@ -2,7 +2,7 @@ Plugin.MaterialDesignControls - 3.1.3 + 3.1.4 MaterialDesignControls Plugin for Xamarin Forms Horus AgustinBonillaHorus diff --git a/src/MaterialDesignControls/Animations/TouchAndPressAnimation.cs b/src/MaterialDesignControls/Animations/TouchAndPressAnimation.cs index 4afea503..210c30da 100644 --- a/src/MaterialDesignControls/Animations/TouchAndPressAnimation.cs +++ b/src/MaterialDesignControls/Animations/TouchAndPressAnimation.cs @@ -6,7 +6,7 @@ namespace Plugin.MaterialDesignControls.Animations { public static class TouchAndPressAnimation { - public static void Animate(View view, EventType gestureType) + public static void Animate(View view, EventType gestureType, bool cancelExecuteAction = true) { var touchAndPressEffectConsumer = view as ITouchAndPressEffectConsumer; @@ -16,6 +16,11 @@ public static void Animate(View view, EventType gestureType) SetAnimation(view, touchAndPressEffectConsumer); break; case EventType.Cancelled: + if (cancelExecuteAction) + touchAndPressEffectConsumer.ExecuteAction(); + + RestoreAnimation(view, touchAndPressEffectConsumer); + break; case EventType.Released: touchAndPressEffectConsumer.ExecuteAction(); RestoreAnimation(view, touchAndPressEffectConsumer); diff --git a/src/MaterialDesignControls/ControlsMaterial3/MaterialCard.cs b/src/MaterialDesignControls/ControlsMaterial3/MaterialCard.cs index ecdaf5ad..67079f1a 100644 --- a/src/MaterialDesignControls/ControlsMaterial3/MaterialCard.cs +++ b/src/MaterialDesignControls/ControlsMaterial3/MaterialCard.cs @@ -230,7 +230,7 @@ protected override void OnPropertyChanged([CallerMemberName] string propertyName public virtual void ConsumeEvent(EventType gestureType) { if (IsEnabled && (_clickedEvent != null || (Command != null && Command.CanExecute(CommandParameter)))) - TouchAndPressAnimation.Animate(this, gestureType); + TouchAndPressAnimation.Animate(this, gestureType, cancelExecuteAction: false); } public virtual void ExecuteAction()