Jump to content
Search Community

Draggable basic question

cormack test
Moderator Tag

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

Hi,

 

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.

 

Thanks

 

 

 

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() {
    $(this.target).addClass("mobil");
  },
  onRelease: function() {
    $(this.target).removeClass("mobil");
  }
});

Right?

 

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). 

 

Enjoy!

  • Like 2
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...