#framer-motion exit doesn't work on Next with App Route

5 messages · Page 1 of 1 (latest)

quiet bane
#

Good afternoon folks, I met a problem when I try to use framer-motion on Next with App Route, exit animation would not be played.
(I use only react before, it's work)
I read some article that metioned I need to write template.js to sort all route, but it will affect all page if write motion in template.js. I only want to add exit animation in one page, how can I fix it?

This is a part of my code

      <AnimatePresence>
        <div className="start_scene">
          <motion.div key={pathname} variants={StartPage} initial="initial" animate="animate" exit="exit"
                      style={{width: '100%', position: "relative"}}>
            <ChangeBackground setIndex={setBackgroundIndex}/>
            <motion.div variants={StartScene} initial="initial" animate="animate" exit="exit" className="bg"
                        onClick={nextDialog}
                        style={{backgroundImage: `url(/images/Startbg${backgroundIndex}.webp)`}}/>
            <motion.div variants={StartDialog} initial="initial" animate="animate" exit="exit" onClick={nextDialog}
                        className="dialog_box">
              <Image src="/images/dialog_box.webp" alt="" className="dialog_box_pic" width="1084" height="273"
                     unoptimized/>
              <motion.div initial={{opacity: 0}} animate={{opacity: 1}} exit={{opacity: 0}}
                          className='dialog'>
              </motion.div>
              <motion.button variants={DialogSkipButton} initial="initial" animate="animate" exit="exit"
                             onClick={skipDialog} className="skip_button">
                <Image src="/images/skip_icon.webp" alt="" width="346" height="320" unoptimized/>
              </motion.button>
            </motion.div>
            
          </motion.div>
        </div>
      </AnimatePresence>
odd bridgeBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

tacit olive
# quiet bane Good afternoon folks, I met a problem when I try to use framer-motion on Next wi...
quiet bane