Jump to content
Search Community

Trigger Draggable onDrag Event

Joe Hakooz test
Moderator Tag

Go to solution Solved by Diaco,

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

I've got a draggable that uses the onDrag event. 

 

Is it possible to "trigger" the onDrag event from another DOM element? I can do it but inside the event this.x returns NaN. 

I think onDragScope might be helpful but not sure how. 

 

For example...

var draggables = Draggable.create(mydraggable, {type: "x", onDrag: updateDraggable });
function updateDraggable(){
    console.log(this.x) // should show a number. Doesn't work when triggered by my button.
}

$('#mybutton').click(function(){
    updateDraggable(draggables[0]); // yeah I know, lame attempt by using a parameter.
});

Thanks for any suggestions!

 

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