motiondivision / motiondivision/motion

[BUG] SVG elements using animate() do not receive CSS animations

Open
#2,450 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
33.7k
Forks
1.4k
Avg merge
1d 10h
Merged PRs (30d)
14

Description

1. Read the FAQs 👇

2. Describe the bug

SVG elements transformed by animate() or useAnimate() do not seem to receive CSS-derived transforms.
From what I can tell, transforms are only copied into their renderState's style if the dimensions are defined.
However, unlike SVG elements created under the motion package, SVG elements fetched by animate() do
not seem to receive dimensions, resulting in transforms never being copied over to the style.

3. IMPORTANT: Provide a CodeSandbox reproduction of the bug

https://codesandbox.io/p/sandbox/framer-motion-enter-animation-forked-8fzrpg

4. Steps to reproduce

Steps to reproduce the behavior:

  1. Create an SVG with children elements
  2. Use animate() or useAnimate() to animate those elements via some sort of transform (e.g. x, y, translateX, etc.)

5. Expected behavior

The CSS transform should be animated and applied to the element in the same way the same element would
behave if generated by the motion package.

6. Video or screenshots

N/A

7. Environment details

Chrome, Firefox

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing packages/framer-motion/src/render/svg/utils/build-attrs.ts with packages/framer-motion/src/render/svg/config-motion.ts, then reproduce the behavior in the linked CodeSandbox using animate() or useAnimate() on SVG children. Verify the finished change by confirming transform values are copied into the element style and animate as they do for motion-generated SVG elements.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.