Jump to content
Search Community

convert draggable demo provided in greensock site from gsap1 to gsap3

Sublimio test
Moderator Tag

Recommended Posts

The changes needed to update the demo to the new gsap version are :


- Update all src to newest

https://unpkg.co/gsap@3/dist/gsap.min.js

https://assets.codepen.io/16327/InertiaPlugin.min.js // ThrowPropsPlugin now is InertiaPlugin
https://unpkg.com/gsap@3/dist/Draggable.min.js
 

- Change the default props

TweenLite.defaultEase = Linear.easeNone;

to 

gsap.defaults({
  ease: "none", 
});

- Change all TweenMax to gsap

- Remove throwProps and add inertia to Draggable 

- Use the wrap function to update the animation progress 

const wrap = gsap.utils.wrap(0, 1);
function updateProgress() {  
  animation.progress(wrap(this.x / wrapWidth));
}

 

Hope this helps 🙌

 

  • Like 3
Link to comment
Share on other sites

If you want to reference a function in a callback, you just provide the name...

 

gsap.to(animation, 1, {
    progress: cellStep * ix,
    ease: Back.easeOut,
  
    // BAD - immediately calls function
    onComplete: completeAnimation()
  });


gsap.to(animation, 1, {
    progress: cellStep * ix,
    ease: Back.easeOut,
  
    // GOOD
    onComplete: completeAnimation
  });

 

But that won't fix the problem. The issue is that when you animate the progress like that, the proxy is going to out of sync, so you will need to reset the proxy's x values to match the animation's progress. Notice what I'm doing in the onPress.

 

See the Pen jOaadbq by GreenSock (@GreenSock) on CodePen

 

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...