Skip to content

Commit

Permalink
Fixing initial -> animate animation when variant is the same
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgperry authored and mergatron[bot] committed Dec 5, 2023
1 parent 64e2a39 commit 0e6d1cb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,22 @@ describe("Animation state - Initiating props", () => {
expect(animate).not.toBeCalled()
})

test("Initial animation with prop as variant when initial === animate", () => {
const { state } = createTest()

const animate = mockAnimate(state)
state.update({
initial: "test",
animate: "test",
variants: {
test: { opacity: 1 },
},
})

expect(state.getState()["animate"].protectedKeys).toEqual({})
expect(animate).not.toBeCalled()
})

test("Initial animation with prop as variant list with initial=false", () => {
const { state } = createTest()

Expand Down
3 changes: 1 addition & 2 deletions packages/framer-motion/src/render/utils/animation-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,13 @@ export function createAnimationState(

if (
isInitialRender &&
props.initial === false &&
(props.initial === false || props.initial === props.animate) &&
!visualElement.manuallyAnimateOnMount
) {
shouldAnimate = false
}

isInitialRender = false

return shouldAnimate ? animate(animations) : Promise.resolve()
}

Expand Down

0 comments on commit 0e6d1cb

Please sign in to comment.