Jump to content


Draggable basic question

Go to solution Solved by GreenSock,

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



Continue my learning process im planning to do some tests with the draggable option.


My first question is: without being yet a memeber of the Green Sock Club, i can use draggable options except some more advanced right?


In case that i can... i want to be able to select any visible Dom element (or most common like divs, images, etc) on my page and drag it to a different place on the document or just to select that visible Dom element..


How can achieve that? Right now i am using a class to make object selectable to drag, if i use * instead, it selects the document also.

Maybe there is another more efficient way, in fact i don't know if using Draggable.create(".mobil");  inside the function is a good coding standard, but if i don't do it it does not works.



Any idea will be welcome.






See the Pen pJBmLX by Cormack (@Cormack) on CodePen

Link to comment
Share on other sites

  • Solution

I think you meant to do something like this:

Draggable.create(".class1", {
  onPress:function() {
  onRelease: function() {



And yes, you can use Draggable without being a Club GreenSock member. You just don't get the throwProps functionality (smooth momentum-based deceleration when flicking). 



  • Like 2
Link to comment
Share on other sites



Just one question: will this work if latter i add a new element with class "class1"?

Will this works for elements added at runtime to the Dom?

Link to comment
Share on other sites

No, you'd need to create() a Draggable for that new element that gets added. Draggable doesn't constantly watch for changes to the DOM and automatically create new instances for you (that'd be bad for performance)

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.