Permalink
Browse files

Handle touch cleanup when widget is destroyed

  • Loading branch information...
1 parent 72d67b6 commit 8f7559b6e65cdc3ee3648d5fe76d38c653f87ff5 HUGE | furf committed Feb 10, 2014
Showing with 30 additions and 10 deletions.
  1. +26 −6 jquery.ui.touch-punch.js
  2. +4 −4 jquery.ui.touch-punch.min.js
View
@@ -1,7 +1,7 @@
/*!
- * jQuery UI Touch Punch 0.2.2
+ * jQuery UI Touch Punch 0.2.3
*
- * Copyright 2011, Dave Furfero
+ * Copyright 2011–2014, Dave Furfero
* Dual licensed under the MIT or GPL Version 2 licenses.
*
* Depends:
@@ -20,6 +20,7 @@
var mouseProto = $.ui.mouse.prototype,
_mouseInit = mouseProto._mouseInit,
+ _mouseDestroy = mouseProto._mouseDestroy,
touchHandled;
/**
@@ -148,13 +149,32 @@
var self = this;
// Delegate the touch handlers to the widget's element
- self.element
- .bind('touchstart', $.proxy(self, '_touchStart'))
- .bind('touchmove', $.proxy(self, '_touchMove'))
- .bind('touchend', $.proxy(self, '_touchEnd'));
+ self.element.bind({
+ touchstart: $.proxy(self, '_touchStart'),
+ touchmove: $.proxy(self, '_touchMove'),
+ touchend: $.proxy(self, '_touchEnd')
+ });
// Call the original $.ui.mouse init method
_mouseInit.call(self);
};
+ /**
+ * Remove the touch event handlers
+ */
+ mouseProto._mouseDestroy = function () {
+
+ var self = this;
+
+ // Delegate the touch handlers to the widget's element
+ self.element.unbind({
+ touchstart: $.proxy(self, '_touchStart'),
+ touchmove: $.proxy(self, '_touchMove'),
+ touchend: $.proxy(self, '_touchEnd')
+ });
+
+ // Call the original $.ui.mouse destroy method
+ _mouseDestroy.call(self);
+ };
+
})(jQuery);

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit 8f7559b

Please sign in to comment.