Skip to content

Commit ed60e6d

Browse files
authored
Merge pull request #36 from smartexcan/master
Replace deprecated $.fn.bind/unbind
2 parents f847786 + 9efd7e1 commit ed60e6d

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

jquery.ui.touch-punch.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@
194194
touchHandled = false;
195195
};
196196

197+
let _touchStartBound = mouseProto._touchStart.bind(mouseProto),
198+
_touchMoveBound = mouseProto._touchMove.bind(mouseProto),
199+
_touchEndBound = mouseProto._touchEndBound.bind(mouseProto);
200+
197201
/**
198202
* A duck punch of the $.ui.mouse _mouseInit method to support touch events.
199203
* This method extends the widget with bound touch event handlers that
@@ -210,11 +214,11 @@
210214
}
211215

212216
// Delegate the touch handlers to the widget's element
213-
self.element.bind(
214-
{'touchstart': mouseProto._touchStart},
215-
{'touchmove': mouseProto._touchMove},
216-
{'touchend': mouseProto._touchEnd}
217-
);
217+
self.element.on({
218+
touchstart: _touchStartBound,
219+
touchmove: _touchMoveBound,
220+
touchend: _touchEndBound
221+
});
218222

219223
// Call the original $.ui.mouse init method
220224
_mouseInit.call(self);
@@ -228,11 +232,11 @@
228232
let self = this;
229233

230234
// Delegate the touch handlers to the widget's element
231-
self.element.unbind(
232-
{'touchstart': mouseProto._touchStart},
233-
{'touchmove': mouseProto._touchMove},
234-
{'touchend': mouseProto._touchEnd}
235-
);
235+
self.element.off({
236+
touchstart: _touchStartBound,
237+
touchmove: _touchMoveBound,
238+
touchend: _touchEndBound
239+
});
236240

237241
// Call the original $.ui.mouse destroy method
238242
_mouseDestroy.call(self);

0 commit comments

Comments
 (0)