jcdiprose Posted April 29, 2015 Share Posted April 29, 2015 Hi, I'm struggling with removing an event in my drag & drop code.. that.pants.once('mousedown', function(mouseData) { that.pants.on('mousemove', function(mouseData) { that.pants.position.x += mouseData.data.originalEvent.movementX; that.pants.position.y += mouseData.data.originalEvent.movementY; that.pants.once('mouseup', function(mouseData) { console.log("how do I remove mouse move event?!") }); }); });I have tried using callbacks but to no success.. If someone knows what would the syntax look like for the prototypal pseudo-classical pattern I am using. Thank you! Quote Link to comment Share on other sites More sharing options...
xerver Posted April 29, 2015 Share Posted April 29, 2015 Use "off". To remove an event use call .off(eventName, functionToRemove). The easiest way to do that is to use named functions for your event handlers so you can just reference the name of the function when you call off. jcdiprose 1 Quote Link to comment Share on other sites More sharing options...
jcdiprose Posted May 1, 2015 Author Share Posted May 1, 2015 Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.