Jump to content
GreenSock

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

draggable on a child to move a parent?

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

Is there an example of how you could use draggable on a child element to move its parent element (and the child element)?

Link to comment
Share on other sites

Hi sitherikb  :)

 

you can use : trigger 

 

as you can read in Draggable Doc. :

trigger : Element | String | Object - if you want only a certain area to trigger the dragging (like the top bar of a window) instead of the entire element, you can define a child element as the trigger, liketrigger:yourElement or trigger:"#topBar" or trigger:$("#yourID"). You may define the trigger as an element or a selector string (which gets fed to whatever TweenLite.selector is), or a jQuery object.

 

like this :

Draggable.create(Parent,{
type:"x,y",
trigger:Child
});

by the way , you can set another elements position with onDrag & onThrowUpdate , something like this :

Draggable.create(myElem,{
type:"x,y",
onDrag:Update ,
onThrowUpdate:Update
});

function Update(){
TweenMax.set( "#anotherElem" , { x:this.x , y:this.y } )
};
  • 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.
×