Skip to content

Commit

Permalink
Adding default animation type (#1857)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgperry committed Jan 2, 2023
1 parent 8f920ac commit 3fa692e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Expand Up @@ -73,7 +73,8 @@ export function animate<V = number>({

let interpolateFromNumber: (t: number) => V

const animator = types[keyframes.length > 2 ? "keyframes" : type]
const animator =
types[keyframes.length > 2 ? "keyframes" : type] || keyframeAnimation

const origin = keyframes[0]
const target = keyframes[keyframes.length - 1]
Expand Down
13 changes: 13 additions & 0 deletions packages/framer-motion/src/motion/__tests__/animate-prop.test.tsx
Expand Up @@ -676,4 +676,17 @@ describe("animate prop as object", () => {

return expect(testFn).toHaveBeenCalled()
})

test("doesn't error when provided unknown animation type", async () => {
const Component = () => {
return (
<motion.div
animate={{ x: 100 }}
transition={{ type: "test" } as any}
/>
)
}
const { rerender } = render(<Component />)
rerender(<Component />)
})
})

0 comments on commit 3fa692e

Please sign in to comment.