Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] SVG viewBox animate not working when wrapping a component with motion() #1177

Open
jagreehal opened this issue Jun 2, 2021 · 1 comment · May be fixed by #1866
Open

[BUG] SVG viewBox animate not working when wrapping a component with motion() #1177

jagreehal opened this issue Jun 2, 2021 · 1 comment · May be fixed by #1866
Labels
bug Something isn't working

Comments

@jagreehal
Copy link

jagreehal commented Jun 2, 2021

Description

I'm trying to animate the viewBox for an SVG component wrapped using motion(), but it doesn't seem to work e.g

import { motion } from "framer-motion";
import { forwardRef } from "react";


const SvgComponent = forwardRef((props, ref) => (
    <svg {...props} ref={ref} viewBox="0 0 100 100" width="400" height="400">
        ....
    </svg>
));

export default function App() {
    const MotionSvgComponent = motion(SvgComponent);

    return (
        <div>
            <MotionSvgComponent
                animate={{
                    viewBox: [
                        "0 0 100 100",
                        "0 0 50 50",
                        "50 0 50 50",
                        "0 50 50 50",
                        "50 50 50 50",
                        "0 0 100 100"
                    ]
                }}
                transition={{
                    duration: 10
                }}
            />

        </div>
    );
}

Other animation properties work fine e.g

<MotionSvgComponent
  animate={{
    x: 50,
  }}
/>

Sandbox

https://codesandbox.io/s/agitated-wilbur-wmzhf

Steps to reproduce the behavior

The sandbox shows both a wrapped component and an example that shows the viewBox is animated when using motion.svg.

What should happen

Both components should animate the same way.

@jagreehal jagreehal added the bug Something isn't working label Jun 2, 2021
@EliavYair1
Copy link

I have the same issue with my website logo it animate the inside path of the logo but ignores the outside path of the svg.
Following.
P.a: if I’ll solve the issue I’ll let you know.

@mattgperry mattgperry linked a pull request Jan 3, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants