Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...

Andrew Harris

Members
  • Content Count

    3
  • Joined

  • Last visited

Community Reputation

0 Newbie

About Andrew Harris

  • Rank
    Newbie
  1. Hi Rodrigo, Thanks for the reply! Haha, I wouldn't want our lord and saviour Dan Abramov to suffer a stroke 😂 Sorry for not being clear, i want to have a component that displays a number value that is animated up or down whenever the value changes. My actual use case is for a pricing calculator, whereby the price will animate up and down whenever a user changes parameters on other components. So yes the object values are related to the component's state, the object is merely there so GSAP can tween the value between the previous state and current state. Does that make sense? I'd done this before when i was working with JQuery & GSAP, i used a similar technique of having an object in a closure that GSAP would tween the value of and then apply the value on each update to the DOM element. Same technique as the below thread. So that's what i thought would be easiest to use again, although yes it's not the React way of doing things. As now GSAP is in control of the rendered value. I'm also not sure how you'd get GSAP to tween a React hook state value, as i thought we shouldn't ever mutate the state value directly, so would need GSAP to call a setter method. Thanks again for helping me out! Hope i'm not being confusing.
  2. Hi there! I would like to add a scalar tween to a component in React using GSAP, the component is a functional component. I've whipped up a quick example of how i think that could be implemented in React using GSAP in the attached codepen. (Type in some number values into the input and watch GSAP tween the number below the input) It's a bit dirty as i need to add a global object to the window on the first mount of the component, so that GSAP has an object it can freely mutate without React resetting it on each render. Is there are better way of allowing GSAP to perform a scalar transition within React? Thanks for any help you can give!
  3. I keep getting the error "uncaught exception: Cannot tween a null target." when hovering one of the buttons in this codepen demo i've created, the animation is applied to a pseudoelement, and it looks all correct to me. The second button in the demo works, but the first doesn't for some reason. Originally the two buttons were different, one with the styling i wanted to apply alongside the animation, but i kept getting this exception, so i chipped away at all the additional styling and animations until i was left with this bug. The markup, js and styling is practically identical, except with a different classname and id for the elements. Does anyone know why this would be happening? Thank you!
×