Skip to content

Commit

Permalink
Merge pull request #2037 from framer/fix/duration-zero
Browse files Browse the repository at this point in the history
Fixing `duration: 0` animations
  • Loading branch information
mergetron[bot] authored Mar 21, 2023
2 parents 7f85448 + d3d1bb0 commit e14ecc3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1231,4 +1231,15 @@ describe("animate", () => {

expect(output).toEqual([0, 20, 40, 20, 0])
})

test("Correctly ends animations with duration: 0", async () => {
const animation = animateValue({
keyframes: [0, 100],
driver: syncDriver(20),
duration: 0,
ease: linear,
})

await animation
})
})
2 changes: 1 addition & 1 deletion packages/framer-motion/src/animation/animators/js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export function animateValue<V = number>({
let resolvedDuration = Infinity
let totalDuration = Infinity

if (calculatedDuration) {
if (calculatedDuration !== null) {
resolvedDuration = calculatedDuration + repeatDelay
totalDuration = resolvedDuration * (repeat + 1) - repeatDelay
}
Expand Down

0 comments on commit e14ecc3

Please sign in to comment.