Alternative to react-spring's 'useSpring' hook in Framer Motion
See original GitHub issueHello,
I’m trying to follow the last Joshua Comeau’s tutorial ‘Boop!’ : https://www.joshwcomeau.com/react/boop/
He used react-spring library.
For the #springs-to-the-rescue part I found a workaround :
I remove this :
const style = useSpring({
display: 'inline-block',
transform: isBooped ? `rotate(${rotation}deg)` : `rotate(0deg)`,
});
<animated.span onMouseEnter={trigger} style={style}>
{children}
</animated.span>
And do this :
<motion.span
onMouseEnter={trigger}
style={{ display: "inline-block" }}
animate={{
x: isBooped ? x : 0,
y: isBooped ? y : 0,
rotate: isBooped ? rotation : 0,
scale: isBooped ? scale : 1,
transition: {
type: "spring",
stiffness: 300,
}
}}
>
{children}
</motion.span>
But now I’m stuck in the hook part (#disconnected-boops)
I couldn’t find an alternative to the react-spring’s ‘useSpring’ hook in Framer Motion.
Is there a way to achieve this with Framer Motion?
Issue Analytics
- State:
- Created 3 years ago
- Comments:9
Top Results From Across the Web
Is there a `useSpring()` alternative for framer-motion?
The problem is, that the bottom sheet is powered by react-spring and @use-gestures but i want to use framer-motion for the animation part....
Read more >Best React animation library: Top 7 libraries compared
We will cover the following animation libraries for React: React Spring; Framer Motion; React Transition Group; React Motion; React Move ...
Read more >Top React Animation Library | React Spring vs. Framer motion
Code Repo: https://github.com/ipenywis/best- react -animation-libraries Github: https://github.com/ipenywis Follow me on Twitter: ...
Read more >React-Spring vs Framer Motion: Comparing Examples in Two ...
Framer Motion and react-spring both solve unique animation challenges and execute with high performance. Framer Motion uses the more ...
Read more >Top 7 React Animation Libraries in 2022 | Syncfusion Blogs
Framer Motion is a popular React animation toolkit designed to make ... import { useSpring, animated } from '@react-spring/web'; export ...
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
Ah, I wish I checked Github. I solved it with someone’s help & was just about to post the answer.
Thank you @mattgperry for the
stiffness
&damping
tip. I never would’ve noticed otherwise.Codesandbox is here → https://codesandbox.io/s/react-spring-vs-framer-motion-boop-animation-did6x
And posting it here in case Codesandbox gets deleted.
useBoop.ts
App.tsx
Motion also uses
stiffness
anddamping
instead: https://codesandbox.io/s/react-spring-vs-framer-motion-boop-animation-forked-lk236?file=/src/framer-motion/useBoop.tsx:0-933