Events: Implement proper source event binding/unbinding #7881
Description
Currently, we attach event handlers for the purposes of computing our touch events using something as simple as .bind( "touchmove", function() { /* .... */ });
during setup()
which we then remove with .unbind( "touchmove" );
during teardown()
. This is really bad! What if the developer has separately hooked up their own touchmove
event handler? When she removes the custom event handler, our teardown()
will also remove their event handler!
So, in an event's setup()
we basically need to store the functions which we pass to .bind()
so we can later pass them to .unbind()
inside teardown()
, removing exactly those event handlers we have attached.
This is already implemented for swipe, but we should make sure to implement it for all our events when we review the events (perhaps as part of pointer event adoption).