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

Chrome Warning #333

Open knoxcard opened 6 years ago

knoxcard commented 6 years ago

Enable verbose output in the Chrome Inspector...

jquery.min.js:3 [Violation] Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952

Chrome Version: Version 62.0.3202.62 (Official Build) (64-bit)

dpmango commented 6 years ago

same issue, And seems to be normal page scroll is blocked with touchswipe enabled

mattbryson commented 6 years ago

I'm working on a new branch that totally re works the event model, and will hopefully sort these sort of issues. Will update the ticket as I go...

voxelmator commented 6 years ago

Exactly the same issue. Tap and DoubleTap are not working anymore.

"jquery-3.2.1.min.js:3 [Violation] Added non-passive event listener to a scroll-blocking 'touchmove' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952"

knoxcard commented 6 years ago

Any update on this? We need another version release push bad! Thanks for all the great work put into this.

**When I get some free time I'd like to contribute to improving the codebase.

mgerasimchuk commented 6 years ago

Any update on this? +1

Gonzo2O28 commented 5 years ago

Anyone?

knoxcard commented 5 years ago

to suppress this warning you can... addEventListener('touchstart', this.callPassedFuntion, { passive: false })

https://stackoverflow.com/questions/39152877/consider-marking-event-handler-as-passive-to-make-the-page-more-responsive

knoxcard commented 5 years ago

Even better?...

     $(document).ready(function() {
          document.addEventListener('touchstart', onTouchStart, {passive: true})
          .../ the rest of your code..
     })

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

knoxcard commented 5 years ago

https://github.com/mattbryson/TouchSwipe-Jquery-Plugin/pull/345

mattbryson commented 5 years ago

@knoxcard There are a few things to consider here.

TouchSwipe does not use passive listeners, it does need to call preventDefault() during the touch move to stop the page scrolling inadvertently.

If you a swiping a carousel left / right, this prevents the page from moving slightly up and down as you do so.

I cant see anyway with chrome to flag the listener as active, or {passive:false} - it will always show that warning.

Also JQ doesn't support the new event options, so even if we did set it on all the bind / on calls it wouldn't make any difference.

If you did set it, your right, it would suppress the warning when the event is bound, but it would then error when the handler tries to call e.preventDefault

Ill try to get some time this week to finish off re working the event model that I started months ago :)

knoxcard commented 5 years ago

Sounds good, thanks @mattbryson