simibac / ConfettiSwiftUI

SwiftUI Package for Configurable Confetti Animation 🎉
MIT License
1.71k stars 117 forks source link

Add option to skip animation when the counter decreases #10

Closed stonko1994 closed 2 years ago

stonko1994 commented 2 years ago

Description

This PR adds the possibility to skip the confetti animation when the $counter value decreases compared to the previous value.

Imagine one has bound the $counter to the current score of a 'player' in any game where the score can in- and decrease. However, the animation should only be shown when the score increases. Having such a convenient configuration option to skip the animation might be helpful.

I created the PR against master as the develop branch is behind the master branch.

Related Issues

No Issue created

Checklist

simibac commented 2 years ago

Thanks for the PR. I believe that such logic should be resolved outside of the package as this is very specific to your usecase. IMO the score for a player should be maintained as a separate variable in your application. Your app should decide whether it wants to trigger the animation or not. Imagine some other app might want to trigger the animation only on odd counters etc. Such specific logic is difficult to abstract and thus, should be handled outside of a package.

Let me know if you disagree or if I understood the usecase wrong :)

stonko1994 commented 2 years ago

That's a good point 🤔 If you start adding such convenience configurations to the package there might be a lot of other coming as well 😅

Totally agree that this should be resolved outside 🙂