Beingenious Posted October 27, 2020 Share Posted October 27, 2020 Hello, I would like to reproduce the iOS spring animations with tweenmax. The idea is to get as close as possible to the rendering by passing a duration and a damping ratio. UIView.animate(withDuration: duration, delay: delay, usingSpringWithDamping: dampingRatio, initialSpringVelocity: 0, options: [], animations: { layerA.frame.origin.x = 300 }, completion: nil) How can I proceed? Thank you very much for your help. Link to comment Share on other sites More sharing options...
GreenSock Posted October 27, 2020 Share Posted October 27, 2020 I'm not sure I understand your question but I will mention: There is no more TweenMax - that's the old syntax. The modern GSAP 3 has all that stuff neatly consolidated into a single "gsap" object. Much cleaner and easier. Same functionality. See: GSAP doesn't do "springs" like that. You can use Elastic easing, create your own custom easing, or... There's an InertiaPlugin that can make literally any property naturally glide to a stop and you can even set a specific end value or a range as well as the initial velocity (or it can track the velocity for you). See https://greensock.com/docs/v3/Plugins/InertiaPlugin 1 Link to comment Share on other sites More sharing options...
Beingenious Posted October 28, 2020 Author Share Posted October 28, 2020 Thanks Jack. It's true that it's much simpler / clearer to use the new GSAP 3. To answer my own question, I found a library that could help me make spring animations with GSAP. https://github.com/tannerlinsley/springer I can then convert dampingRatio and duration to normal tension and friction to use it. https://stackoverflow.com/questions/50029666/determine-springwithdamping-and-initialspringvelocity-based-off-from-friction-an Have a great day 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now