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

Chrome Warning

Open knoxcard opened this issue 7 years ago • 11 comments

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)

knoxcard avatar Oct 21 '17 07:10 knoxcard

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

dpmango avatar Nov 09 '17 19:11 dpmango

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...

mattbryson avatar Nov 09 '17 21:11 mattbryson

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"

voxelmator avatar Nov 19 '17 22:11 voxelmator

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.

knoxcard avatar Jan 09 '18 16:01 knoxcard

Any update on this? +1

mgerasimchuk avatar Apr 27 '18 04:04 mgerasimchuk

Anyone?

Gonzo2O28 avatar Sep 13 '18 10:09 Gonzo2O28

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 avatar Sep 14 '18 02:09 knoxcard

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 avatar Sep 14 '18 02:09 knoxcard

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

knoxcard avatar Sep 14 '18 03:09 knoxcard

@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 :)

mattbryson avatar Sep 17 '18 10:09 mattbryson

Sounds good, thanks @mattbryson

knoxcard avatar Sep 17 '18 10:09 knoxcard