Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
JesusTheHun

Collection of draggable, trigger on child

Go to solution Solved by Cassie,

Recommended Posts

I'm using Draggable.create(arrayOfElements, {...}) to make a set of SVG g elements draggable.

The trigger of each element is a child of said element. One trigger is supposed to drag one element.

 

So I tried { trigger: ".draggable" }. When I do that, any .draggable trigger the drag of all elements (from arrayOfElements) instead of its parent only.
I could of course create the drag on the children directly, but then I have to move everything else manually.

 

Should I do an instance of Draggable for each element instead of for the entire array ? Does that bring any performance issue ?

Link to comment
Share on other sites

Yes something like this.

I didn't want to loop because I was concerned about performance, thinking one draggable is better than many. I may have a few hundred elements.

Link to comment
Share on other sites

  • Solution

No, that won't make any difference. Don't worry!

Link to comment
Share on other sites

6 hours ago, JesusTheHun said:

I didn't want to loop because I was concerned about performance, thinking one draggable is better than many.

Well it creates a new Draggable instance for every element in your arrayOfElements anyway - there's no way around that because all of those elements we have to be tracked separately :) Draggable.create() would do an internal loop. So you're not getting any performance gain by avoiding the external loop. 

  • 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.
×