jquery-waypoints
jquery-waypoints copied to clipboard
Fix jQuery Migrate issues
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch [email protected]
for the project I'm working on.
This is because of jQuery Migrate showing a lot of console logs of issues which need to be fixed because of jQuery planning to remove functions.
Here is the diff that solved my problem:
diff --git a/node_modules/jquery-waypoints/waypoints.js b/node_modules/jquery-waypoints/waypoints.js
index 81da414..b6f7c45 100644
--- a/node_modules/jquery-waypoints/waypoints.js
+++ b/node_modules/jquery-waypoints/waypoints.js
@@ -56,7 +56,7 @@ https://github.com/imakewebthings/jquery-waypoints/blob/master/licenses.txt
};
$element.data(contextKey, this.id);
contexts[this.id] = this;
- $element.bind(scrollEvent, function() {
+ $element.on(scrollEvent, function() {
var scrollHandler;
if (!(_this.didScroll || isTouch)) {
@@ -68,7 +68,7 @@ https://github.com/imakewebthings/jquery-waypoints/blob/master/licenses.txt
return window.setTimeout(scrollHandler, $[wps].settings.scrollThrottle);
}
});
- $element.bind(resizeEvent, function() {
+ $element.on(resizeEvent, function() {
var resizeHandler;
if (!_this.didResize) {
@@ -140,8 +140,17 @@ https://github.com/imakewebthings/jquery-waypoints/blob/master/licenses.txt
var axes, cOffset, isWin,
_this = this;
- isWin = $.isWindow(this.element);
- cOffset = this.$element.offset();
+ isWin = this.element != null && this.element === this.element.window;
+ if (
+ this.element !== null
+ && typeof this.element === "object"
+ && typeof this.$element.getClientRects === "function"
+ && this.$element.getClientRects().length
+ ) {
+ cOffset = this.$element.offset();
+ } else {
+ cOffset = { top: 0, left: 0 };
+ }
this.doScroll();
axes = {
horizontal: {
@@ -169,8 +178,8 @@ https://github.com/imakewebthings/jquery-waypoints/blob/master/licenses.txt
adjustment = waypoint.options.offset;
oldOffset = waypoint.offset;
- elementOffset = $.isWindow(waypoint.element) ? 0 : waypoint.$element.offset()[axis.offsetProp];
- if ($.isFunction(adjustment)) {
+ elementOffset = waypoint.element != null && waypoint.element === waypoint.element.window ? 0 : waypoint.$element.offset()[axis.offsetProp];
+ if (typeof adjustment === "function") {
adjustment = adjustment.apply(waypoint.element);
} else if (typeof adjustment === 'string') {
adjustment = parseFloat(adjustment);
@@ -213,7 +222,7 @@ https://github.com/imakewebthings/jquery-waypoints/blob/master/licenses.txt
var contextHeight;
contextHeight = $[wps]('viewportHeight');
- if (!$.isWindow(context.element)) {
+ if (!(context.element != null && context.element === context.element.window)) {
contextHeight = context.$element.height();
}
return contextHeight - $(this).outerHeight();
@@ -293,7 +302,7 @@ https://github.com/imakewebthings/jquery-waypoints/blob/master/licenses.txt
$this = $(this);
contextElement = (_ref1 = options.context) != null ? _ref1 : $.fn[wp].defaults.context;
- if (!$.isWindow(contextElement)) {
+ if (!(contextElement != null && contextElement === contextElement.window)) {
contextElement = $this.closest(contextElement);
}
contextElement = $(contextElement);
@@ -367,7 +376,7 @@ https://github.com/imakewebthings/jquery-waypoints/blob/master/licenses.txt
method = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
if (methods[method]) {
return methods[method].apply(this, args);
- } else if ($.isFunction(method)) {
+ } else if (typeof method === "function") {
return methods.init.apply(this, arguments);
} else if ($.isPlainObject(method)) {
return methods.init.apply(this, [null, method]);
@@ -512,7 +521,7 @@ https://github.com/imakewebthings/jquery-waypoints/blob/master/licenses.txt
resizeThrottle: 100,
scrollThrottle: 30
};
- return $w.load(function() {
+ return $w.on('load', function() {
return $[wps]('refresh');
});
});
This issue body was partially generated by patch-package.