Skip to content

Commit

Permalink
Fix isAnimating for confetti animation (#82)
Browse files Browse the repository at this point in the history
Co-authored-by: jakub.szewczyk <jakub.szewczyk@tivix.com>
  • Loading branch information
thedevelobear and jakub.szewczyk authored Mar 28, 2022
1 parent 5295eb3 commit 669e6c0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-rewards",
"version": "2.0.0",
"version": "2.0.2",
"description": "This package lets you easily add micro-interactions to your app and reward users with the rain of confetti, emoji or balloons.",
"author": "thedevelobear",
"license": "MIT",
Expand Down
7 changes: 6 additions & 1 deletion src/components/Confetti/Confetti.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ const updateParticle = (
}
};

export const confetti = (root: Element, config?: ConfettiConfig) => {
export const confetti = (
root: Element,
internalAnimatingCallback: () => void,
config?: ConfettiConfig
) => {
const options = config || {};
const {
elementCount = 50,
Expand Down Expand Up @@ -101,6 +105,7 @@ export const confetti = (root: Element, config?: ConfettiConfig) => {
if (typeof onAnimationComplete === 'function') {
onAnimationComplete();
}
internalAnimatingCallback();
};

animate({
Expand Down
3 changes: 1 addition & 2 deletions src/hooks/useReward.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ export const useReward: UseRewardType = (id, type, config) => {
case 'confetti': {
reward = () => {
setIsAnimating(true);
confetti(container, config);
setIsAnimating(false);
confetti(container, internalAnimatingCallback, config);
};
break;
}
Expand Down

0 comments on commit 669e6c0

Please sign in to comment.