TouchSwipe-Jquery-Plugin icon indicating copy to clipboard operation
TouchSwipe-Jquery-Plugin copied to clipboard

Uses Passive Event Listeners to Improve Scrolling Performance

Open zwantE opened this issue 6 years ago • 4 comments

Google Chrome Audits returns an Error: "Uses Passive Event Listeners to Improve Scrolling Performance"

More Information -> https://developers.google.com/web/tools/lighthouse/audits/passive-event-listeners

zwantE avatar Jan 16 '19 18:01 zwantE

I have found also that this leads to console errors as such:

[Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive. See https://www.chromestatus.com/features/6662647093133312

Scrolling performance, using this plugin on desktop devices, is laggy and leaves the UI feeling at times unresponsive and glitchy as the scroll fights the wheel steps down the page.

Commenting out the following function improves scrolling performance and dramatically smooths out the scrolling:-

function wheel(event) {
    if (!initDone) {
        init();
    }
	// This is the problematic section of code
    // var target = event.target;
    // var overflowing = overflowingAncestor(target);
    // if (!overflowing || event.defaultPrevented || isNodeName(activeElement, "embed") || (isNodeName(target, "embed") && /\.pdf/i.test(target.src))) {
    //     return true;
    // }
    // var deltaX = event.wheelDeltaX || 0;
    // var deltaY = event.wheelDeltaY || 0;
    // if (!deltaX && !deltaY) {
    //     deltaY = event.wheelDelta || 0;
    // }
    // if (!options.touchpadSupport && isTouchpad(deltaY)) {
    //     return true;
    // }
    // if (Math.abs(deltaX) > 1.2) {
    //     deltaX *= options.stepSize / 120;
    // }
    // if (Math.abs(deltaY) > 1.2) {
    //     deltaY *= options.stepSize / 120;
    // }
    // scrollArray(overflowing, -deltaX, -deltaY);
    //event.preventDefault();
    }

I am unsure at this stage what effect this will have on mobile devices scrolling abilities.

I may opt to implement a device type test before allowing this particular section of code to run, therefore reclaiming scroll performance on Desktop whilst preserving functionality on touch devices.

YenHub avatar Aug 06 '19 08:08 YenHub

I've noticed this is still an issue. Will this be fixed in a future version? Thanks!

rsmith4321 avatar Mar 24 '21 22:03 rsmith4321

Yeah, I'm going to carve out some time next week to do an overhaul and clean up alot of issues like this.

On Wed, 24 Mar 2021, 22:37 rsmith4321, @.***> wrote:

I've noticed this is still an issue. Will this be fixed in a future version? Thanks!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mattbryson/TouchSwipe-Jquery-Plugin/issues/350#issuecomment-806229256, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEGAVCLPTU5TXDZNKLA5KDTFJSRBANCNFSM4GQO3YDQ .

mattbryson avatar Mar 26 '21 01:03 mattbryson

Is this issue fixed?

holoduke avatar Sep 22 '23 15:09 holoduke