forked from motiondivision/motion
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing animating to CSS variables with SVG elements
- Loading branch information
1 parent
bfece69
commit a68a72f
Showing
4 changed files
with
65 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import * as React from "react" | ||
import { motion } from "@framer" | ||
|
||
/** | ||
* An example of providing a MotionValue to an SVG component via its props | ||
*/ | ||
|
||
export const App = () => { | ||
const [state, setState] = React.useState(false) | ||
return ( | ||
<svg | ||
width="250" | ||
height="250" | ||
viewBox="0 0 250 250" | ||
xmlns="http://www.w3.org/2000/svg" | ||
onClick={() => setState(!state)} | ||
style={{ "--color": "#f00" } as any} | ||
> | ||
<motion.circle | ||
initial={false} | ||
cx={125} | ||
cy={125} | ||
r="100" | ||
animate={{ fill: state ? "var(--color)" : "#00f" }} | ||
transition={{ duration: 3, ease: () => 0.5 }} | ||
/> | ||
</svg> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters