mattbryson / TouchSwipe-Jquery-Plugin

TouchSwipe is a jquery plugin to be used with jQuery on touch input devices such as iPad, iPhone etc.
http://labs.rampinteractive.co.uk/touchSwipe/
Other
4.05k stars 1.68k forks source link

Uses Passive Event Listeners to Improve Scrolling Performance #350

Open zwantE opened 5 years ago

zwantE commented 5 years ago

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

YenHub commented 5 years ago

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.

rsmith4321 commented 3 years ago

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

mattbryson commented 3 years ago

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 .

holoduke commented 11 months ago

Is this issue fixed?