Skip to content

Replace deprecated $.fn.bind/unbind #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions jquery.ui.touch-punch.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@
touchHandled = false;
};

let _touchStartBound = mouseProto._touchStart.bind(mouseProto),
_touchMoveBound = mouseProto._touchMove.bind(mouseProto),
_touchEndBound = mouseProto._touchEndBound.bind(mouseProto);

/**
* A duck punch of the $.ui.mouse _mouseInit method to support touch events.
* This method extends the widget with bound touch event handlers that
Expand All @@ -210,11 +214,11 @@
}

// Delegate the touch handlers to the widget's element
self.element.bind(
{'touchstart': mouseProto._touchStart},
{'touchmove': mouseProto._touchMove},
{'touchend': mouseProto._touchEnd}
);
self.element.on({
touchstart: _touchStartBound,
touchmove: _touchMoveBound,
touchend: _touchEndBound
});

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

// Delegate the touch handlers to the widget's element
self.element.unbind(
{'touchstart': mouseProto._touchStart},
{'touchmove': mouseProto._touchMove},
{'touchend': mouseProto._touchEnd}
);
self.element.off({
touchstart: _touchStartBound,
touchmove: _touchMoveBound,
touchend: _touchEndBound
});

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