Last active
October 16, 2021 23:42
-
-
Save nkajic/727ae5ff874894f96356b44eece9fd6a to your computer and use it in GitHub Desktop.
Remove passive listeners warning p1 and p2 patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- lib/web/jquery/patches/jquery.js | |
+++ lib/web/jquery/patches/jquery.js | |
@@ -19,6 +19,33 @@ define([], function () { | |
}); | |
} | |
+ /** | |
+ * Does not use passive listeners to improve scrolling performance | |
+ * https://stackoverflow.com/questions/60357083/does-not-use-passive-listeners-to-improve-scrolling-performance-lighthouse-repo | |
+ */ | |
+ function removePassiveListeners(jQuery) { | |
+ jQuery.event.special.touchstart = { | |
+ setup: function( _, ns, handle ) { | |
+ this.addEventListener("touchstart", handle, { passive: !ns.includes("noPreventDefault") }); | |
+ } | |
+ }; | |
+ jQuery.event.special.touchmove = { | |
+ setup: function( _, ns, handle ) { | |
+ this.addEventListener("touchmove", handle, { passive: !ns.includes("noPreventDefault") }); | |
+ } | |
+ }; | |
+ jQuery.event.special.wheel = { | |
+ setup: function( _, ns, handle ){ | |
+ this.addEventListener("wheel", handle, { passive: true }); | |
+ } | |
+ }; | |
+ jQuery.event.special.mousewheel = { | |
+ setup: function( _, ns, handle ){ | |
+ this.addEventListener("mousewheel", handle, { passive: true }); | |
+ } | |
+ }; | |
+ } | |
+ | |
return function ($) { | |
var majorVersion = $.fn.jquery.split('.')[0]; | |
@@ -27,6 +54,7 @@ define([], function () { | |
} | |
ajaxResponsePatch($); | |
+ removePassiveListeners($); | |
return $; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- lib/web/magnifier/magnify.js | |
+++ lib/web/magnifier/magnify.js | |
@@ -505,7 +505,7 @@ define([ | |
if (!$fotoramaStage.hasClass('magnify-wheel-loaded')) { | |
if (fotoramaStage && fotoramaStage.addEventListener) { | |
if ('onwheel' in document) { | |
- fotoramaStage.addEventListener('wheel', onWheel); | |
+ fotoramaStage.addEventListener('wheel', onWheel, { passive: true }); | |
} else if ('onmousewheel' in document) { | |
fotoramaStage.addEventListener('mousewheel', onWheel); | |
} else { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment