[BUG] Trying to manipulate SVG "d" values causes error
See original GitHub issueI am wanting to use the same functionality to Poses SVG morphing, I try something like:
const boxVariants = {
initial: {
fill: "pink",
d:
"M510,255c0-20.4-17.85-38.25-38.25-38.25H331.5L204,12.75h-51l63.75,204H76.5l-38.25-51H0L25.5,255L0,344.25h38.25 l38.25-51h140.25l-63.75,204h51l127.5-204h140.25C492.15,293.25,510,275.4,510,255z",
},
hover: {
fill: "pink",
d:
"M255,0C114.75,0,0,114.75,0,255s114.75,255,255,255s255-114.75,255-255S395.25,0,255,0z",
},
}
And I get an error saying: Error: Complex values 'M255,0C114.75,0,0,114.75,0,255s114.75,255,255,255s255-114.75,255-255S395.25,0,255,0z' and 'M510,255c0-20.4-17.85-38.25-38.25-38.25H331.5L204,12.75h-51l63.75,204H76.5l-38.25-51H0L25.5,255L0,344.25h38.25 l38.25-51h140.25l-63.75,204h51l127.5-204h140.25C492.15,293.25,510,275.4,510,255z' too different to mix. Ensure all colors are of the same type. at invariant (hey-listen.es.js:11)
Can Framer Motion support SVG morphing yet?
Cheers!
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:6
Top Results From Across the Web
Here's How I Solved a Weird Bug Using Tried and True ...
At first, this looks like a CSS issue. Some styles might be applied on a hover event that breaks the layout or the...
Read more >Python svgwrite Drawing Error "not a valid value for attribute 'd ...
I try to extract one path from a SVG ...
Read more >5 Most Common Problems Faced by SVG Users - Vecta.io
Your SVG namespace is not declared properly causing the SVG image to be displayed incorrectly. Quick fix: Check and fix your SVG namespaces....
Read more >svg arc path command parsing error on sweep flag
This means that if the user is trying to understand what is wrong with a path by experimentation, and the path has a...
Read more >Fills and Strokes - SVG: Scalable Vector Graphics | MDN
Using fill sets the color inside the object and stroke sets the color of the line drawn around the object. You can use...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I created a custom hook to solve this by using
flubber
,useMotionValue
andanimate
. Check it out:You can just pass the desired
d
as the first argument and other options (like duration) as the second parameter, here is an example:And a demo sandbox
As far as I understand, it doesn’t morph the SVG, it just manipulate its positions. So, maybe when one of the variants has different paths it doesn’t know what to do.
In my case, I’ve changed every
h
inside my SVG tol
and it’s working now.This is just one line of a hamburger menu, so it’s quite easy to change it by hand. Don’t know about more complex SVGs. Illustrator, figma, xd and sketch each exported it a little bit different.
Here are the svg path properties for reference: