Skip to content

[BUG] whileInView transition values override the other transition values #2636

Description

@OSAMA263

im trying to animate whileHover on a div opacity :[0,1]

what i want:

if i hover on the div the opacity goes from 0 to 1 it works if i hoverd and stayed on the div but..

what happens:

if i ran the mouse on the div fast the delay:3 works but i dont want the whileInView delay value to work if i hoverd on the div

import { motion} from "framer-motion";

export const App= () => {
  return (
    <>
      <motion.div
        style={{ background: "black", marginTop: 10 }}
        initial={{ opacity: 0 }}
        whileInView={{ opacity: 1, transition: { duration: 0.4, delay: 3 } }}
        whileHover={{
          opacity: [0, 1],
          transition: { duration: 0.3, delay: 0 },
        }}
      >
        text
      </motion.div>
    </>
  );
};

https://codesandbox.io/p/devbox/crazy-euler-4flt8c

Activity

  1. n-ii-ma commented on Oct 22, 2024

    @n-ii-ma

    Having the same issue but managed to fix it by moving the whileHover to a parent div of the whileInView component:

    import { motion} from "framer-motion";
    
    export const App= () => {
      return (
        <motion.div whileHover={{
          opacity: [0, 1],
          transition: { duration: 0.3, delay: 0 },
        }}>
          <motion.div
            style={{ background: "black", marginTop: 10 }}
            initial={{ opacity: 0 }}
            whileInView={{ opacity: 1, transition: { duration: 0.4, delay: 3 } }}
          >
            text
          </motion.div>
        </motion.div>
      );
    };
    
  2. mattgperry commented on Oct 5, 2026

    @mattgperry
    Collaborator

    Closing as intended behaviour. When a gesture ends, Motion animates back to the next active state using that state's transition. In your code the next state is whileInView, whose transition has delay: 3, so after a quick hover the opacity waits 3 seconds before returning to 1. I confirmed this on framer-motion 11.0.25 and on current main (React 18 and 19): the hover animation itself starts with no delay, and the return to whileInView holds for 3s. To avoid it, keep the delay off the whileInView transition, or move whileHover to a parent element as @n-ii-ma suggested.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions