nep Posted May 24, 2021 Share Posted May 24, 2021 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 More sharing options...
GreenSock Posted May 24, 2021 Share Posted May 24, 2021 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. 2 Link to comment Share on other sites More sharing options...
nep Posted May 24, 2021 Author Share Posted May 24, 2021 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 More sharing options...
Solution GreenSock Posted May 24, 2021 Solution Share Posted May 24, 2021 Ah, okay. Not for a callback, but you should be able to do that with an event listener. Like using addEventListener("press", yourFunc) and then removeEventListener("press", yourFunc). Does that answer your question? 2 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now