From d27fde272ca7f81ba1f5f5db6ac6e09bf26df5da Mon Sep 17 00:00:00 2001 From: Conny Duck Date: Tue, 12 Mar 2024 09:09:02 +0100 Subject: [PATCH] fix bug where sparks were visible on unchecked button --- .../at/connyduck/sparkbutton/compose/SparkButton.kt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/sparkbutton-compose/src/main/kotlin/at/connyduck/sparkbutton/compose/SparkButton.kt b/sparkbutton-compose/src/main/kotlin/at/connyduck/sparkbutton/compose/SparkButton.kt index c5e3f24..878b17c 100644 --- a/sparkbutton-compose/src/main/kotlin/at/connyduck/sparkbutton/compose/SparkButton.kt +++ b/sparkbutton-compose/src/main/kotlin/at/connyduck/sparkbutton/compose/SparkButton.kt @@ -99,6 +99,8 @@ public fun SparkButton( } LaunchedEffect(buttonClicks) { + dotsRadiusProgress.snapTo(0.0f) + if (checked && buttonClicks > 0) { launch { contentScale.snapTo(0.0f) @@ -117,8 +119,7 @@ public fun SparkButton( launch { dotsRadiusProgress.animateTo( targetValue = 1.0f, - animationSpec = - keyframes { + animationSpec = keyframes { 0f at 0 using FastOutSlowInEasing 0.9f at (750 / animationSpeed).toInt() using SlowOutFastInEasing 1.0f at (1000 / animationSpeed).toInt() @@ -131,8 +132,7 @@ public fun SparkButton( launch { largeDotSizeProgress.animateTo( targetValue = 0f, - animationSpec = - keyframes { + animationSpec = keyframes { 0f at 0 using FastOutSlowInEasing 1f at (450 / animationSpeed).toInt() 1f at (650 / animationSpeed).toInt() using SlowOutFastInEasing @@ -145,8 +145,7 @@ public fun SparkButton( launch { smallDotSizeProgress.animateTo( targetValue = 0f, - animationSpec = - keyframes { + animationSpec = keyframes { 0f at 0 using FastOutSlowInEasing 1f at (500 / animationSpeed).toInt() using SlowOutFastInEasing 0.0f at (1000 / animationSpeed).toInt()