Jump to content
Search Community

combine Draggable and Selectable?

one2gov 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

Here is jquery implementation of Draggable and Selectable working together. Is it possible to do it with greensock? Should I just replace draggable function from jquery to greensock? If not, I think I create new draggable div outside of seelcted divs, and move that div using greensock, but that's not really greate solution..

 

aX0h0SS.png vgOYvCh.png

See the Pen rWJEMQ?editors=0010 by one2gov (@one2gov) on CodePen

Link to comment
Share on other sites

  • Solution

That's not something that's baked into Draggable but it's entirely doable with extra code (at least I don't see why it wouldn't be). I don't have time to wire it all up for you, but the basic idea would be to use an onPress to record the starting x/y of the element and then onDrag, you'd figure out the delta (change) for the current element and just alter all the others by that amount as well, so they all appear to drag together. You could even use a simple TweenLite.set(arrayOfOtherElements, {x:"+=" + deltaX, y:"+=" + deltaY}) to get 'em all in one fell swoop. 

 

And as for the multi-selection thing, you might be able to use the hitTest() function baked into Draggable for some of that logic. 

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