question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[FEATURE] Headless animations

See original GitHub issue

Is your feature request related to a problem? Please describe. Currently animations require a motion component. Being able to drive these independently would be useful for a number of reasons, like animating non motion components, animate with custom interpolators like flubber, etc.

Describe the solution you’d like Something along the lines of:

useAnimation(
  ({ height }) => {
    // Freedom to do:
    heightMotionValue.set(height)
    // Or:
    setHeightState(height)
    // Or:
    componentCallback(height)
  },
  isOpen ? { height: 100 } : { height: 0 }
)

Describe alternatives you’ve considered We have a useAnimatedState experimental hook but it’s limited to just React state. Hopefully this feature will superceed this. We have useSpring but it’s just a single MotionValue. This feature shouldn’t rely on anything else, offering a function to deal with the output with motionvalues, states, anything.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
wr9commented, Jul 10, 2020

@cloudratha Thanks a lot, I couldn’t wrap my head around this problem.

I had some issues with the transform(value, [0, 1], [0, 1]) part of your solution -> I assumed here you meant useTransform(value, [0, 1], [0, 1]), maybe I was wrong.

Instead of it I just did:

const pathPos = useSpring(0, {
    damping: 100,
  });

const path = useTransform(pathPos, (value) => interpolator(value));

The rest is the same. Thanks, again!

Also, I completely agree with your suggestion of useTween and I don’t like the lack of support for this issue, and other similar ones (https://github.com/framer/motion/issues/218, https://github.com/framer/motion/issues/329).

1reaction
cloudrathacommented, Nov 3, 2019

I’ve just run into needing this feature. I was able to use existing hooks to integrate with flubber.

  const pathPos = useSpring(0, springConfig)
  const path = useTransform(pathPos, value =>
    interpolator(transform(value, [0, 1], [0, 1]))
  )
  useEffect(() => {
    pathPos.set(open ? 1 : 0)
  }, [open])
  
  return (
    <svg>
      <motion.path d={path} />
    </svg>
  )

It would be much easier to have a useTween for this example as i need to clamp the values with transform. Also having access to duration wouldn’t hurt either.

With useAnimation do you get access to the individual MotionValue’s for each entry, to better control the above?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Headless Studio
Headless Productions is a small independent animation studio founded by Adrian Garcia, Victor Maldonado and Alfredo Torres ...
Read more >
140 HEADLESS PRODUCTIONS ideas | character design, ...
May 1, 2018 - Explore PatCompa's board "HEADLESS PRODUCTIONS", ... Flooby Nooby: Visual Development from the animated feature “My Family and the Wolf” ......
Read more >
headless-ui-theme-animated
CodeSandbox is an online editor tailored for web applications.
Read more >
52 Headless Lottie Animations - Free in JSON, LOTTIE, GIF
Download 52 Headless Lottie Animations for free or premium in JSON, LOTTIE, GIF, AEP or MP4 formats. Bring motion to your designs or...
Read more >
"Headless Over Heels" by Anna Choi, Cynthia Ma | CGMeetup
CGI 3D Animated Short Film: Headless Over Heels Animated Short Film by ... We feature a wide variety of CGI content including behind-the- ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found