Jump to content
Search Community

How to properly remove/disable any specific function from Draggable (gsap3) ?

nep test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

var myDraggable = Draggable.create('#someID', {
  type: 'x,y',
  bounds: '#container',
  onPress: function(){ 
    //some codes
  },
  onDrag: function(){
    //some codes
  }
});

How do I properly remove/disable onPress function from myDraggable?

 

Link to comment
Share on other sites

11 hours ago, nep said:

How do I properly remove/disable onPress function from myDraggable?

I'm a bit confused - is there a reason you wouldn't just not set an onPress to begin with? Can you please give a little more context - like why are you trying to disable onPress to begin with? 

 

If you can't just not set one to begin with, you could definitely add some logic in your onPress to skip under certain conditions (like use a variable). 

 

Once we see a minimal demo, I'm sure we'll be able to offer more advice. 

  • Like 2
Link to comment
Share on other sites

I am just checking if there is a simple/cleaner way to remove a certain function that was already created Draggable without re-creating it or adding conditions to it.

for example:

myDraggable.removeEventListener('onPress');
myDraggable.disable('onPress');
myDraggable.off('onPress')
myDraggable.remove('onPress');

 

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