Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

in some instances the funfact emoji button doesnt animate out when its been clicked on #47

Open
Tracked by #44
tangway opened this issue May 6, 2024 · 1 comment

Comments

@tangway
Copy link
Owner

tangway commented May 6, 2024

it has inconsistent behaviour even within the same round of questions

@tangway
Copy link
Owner Author

tangway commented May 6, 2024

fixed this when i read the docs for enabling exit animation more thoroughly at https://www.framer.com/motion/animate-presence/

it is important to wrap motion elements with AnimatePresence and add mode="wait" prop so that the entering animation will wait for the exiting animation to finish.
adding these parameters to all the motion elements that needs exit animation solved most entry/exit animation issues
this also solved issue #48

<AnimatePresence mode="wait">
            {showEndModal === false ? (
              <motion.button
                key={`next-button-${showEndModal}`}
                type="button"
                className="next-button"
                onClick={nextButtonFunc}
                initial={{ scale: 0 }}
                animate={{ scale: 1 }}
                transition={{ duration: 1.2, ease: 'easeInOut' }}
                exit={{ scale: 0, transition: { duration: 0.8, ease: 'easeInOut' } }}
              >
                {currentQuestionNumber === questions.length - 1
                  ? 'GAME OVER'
                  : 'Next'}
              </motion.button>
            ) : gameHasEnded === true ? (
              <motion.button
                key={`emoji-button-${showEndModal}`}
                className="emoji-button"
                type="button"
                onClick={showEndModalFunc}
                initial={{ scale: 0 }}
                animate={controls}
                exit={{ scale: 0, transition: { duration: 0.8, ease: 'easeInOut' } }}
              >
                🎁
              </motion.button>
            ) : null}
</AnimatePresence>

@tangway tangway changed the title in some instances the funfact emoji button doesnt disappear once its been clicked on in some instances the funfact emoji button doesnt animate out when its been clicked on May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant