diff --git a/app/code/Magento/Theme/view/base/requirejs-config.js b/app/code/Magento/Theme/view/base/requirejs-config.js index 28495b628cd32..7e4b2da8b7579 100644 --- a/app/code/Magento/Theme/view/base/requirejs-config.js +++ b/app/code/Magento/Theme/view/base/requirejs-config.js @@ -85,6 +85,11 @@ var config = { 'headers': { 'X-Requested-With': 'XMLHttpRequest' } + }, + mixins: { + 'jquery': { + 'jquery/jquery-scroll-passive-patch': true + } } } }; diff --git a/lib/web/jquery/jquery-scroll-passive-patch.js b/lib/web/jquery/jquery-scroll-passive-patch.js new file mode 100644 index 0000000000000..5106232123a4b --- /dev/null +++ b/lib/web/jquery/jquery-scroll-passive-patch.js @@ -0,0 +1,40 @@ +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +define([], function () { + 'use strict'; + + function addPassiveListeners(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 ($) { + addPassiveListeners($); /* patch for jquery 3.6.0 for improve performance */ + + return $; + }; +});