Jump to content


Delete a draggable object

Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Once you have declared a draggable object is there away to delete it again?


The reason I ask is that I have page that works really well controlling multiple tweens as you drag the container. The problem comes if the browser is resized and I get all sorts of odd results.


if you hit refresh then it works fine. So my thinking is the easiest way to get around this would be to redelclare everything after a resize. I've done this for the timeline animations but i can't seem to find a way to get rid of the "draggable" once it has been set. There is a "disable" but what I would like to do is completely remove it.

Link to comment
Share on other sites

Yep, disable() is all you need. Is that not working for you or something?


Also, could you provide a very simple codpen or jsfiddle that demonstrates the odd behavior after a window resize? 

Link to comment
Share on other sites

its a little complicated to produce a demo but essetially what happens after a resize is that the animation is all out of sync which kind of expect. I have no way of resetting the progress.


If however you drag on the container a function is called on update and does the following




var X = -this.x;
 if (X <0 ){
        X = 0    




I thought I could trigger this function after resize but it only works if you physically drag on the container.

Link to comment
Share on other sites

I read your response a few times and I'm still pretty confused. Not sure what's going on, what this.x represents exactly, or data.w3, etc. If you need help, we'd be happy to take a peek at a reduced test case in a codepen or something. Otherwise I don't think there's much we can do. 

Link to comment
Share on other sites

Its ok.. I faked a click by calling startDrag after a screen resize this seems to sort everything out. So all good.

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.