artpolikarpov / fotorama

A simple, stunning, powerful jQuery gallery.
http://fotorama.io
Other
1.58k stars 379 forks source link

Chrome throwing 'non-passive event listener' warnings in console #529

Open frankludriks opened 7 years ago

frankludriks commented 7 years ago

When viewing pages with Fotorama plugin installed Chrome gives the following warnings:

[Violation] Added non-passive event listener to a scroll-blocking 'wheel' event. Consider marking event handler as 'passive' to make the page more responsive. fotorama.js:4

[Violation] Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event handler as 'passive' to make the page more responsive. fotorama.js:4

[Violation] Added non-passive event listener to a scroll-blocking 'touchmove' event. Consider marking event handler as 'passive' to make the page more responsive. fotorama.js:4

Using

Triloworld commented 6 years ago

Line 1137: el.addEventListener ? el.addEventListener(e, fn, !!bool) : el.attachEvent('on' + e, fn);

Replace to: el.addEventListener ? el.addEventListener(e, fn, {passive: true}) : el.attachEvent('on' + e, fn); and all events will get passive listener. This need pull request.

beyz commented 4 years ago

Hi, I cannot find the exact line but {b&&(a.addEventListener?a.addEventListener(b,c,!!d):a.attachEvent("on"+b,c))} chaging it to following seems to work but not quite sure if was correct solutions, {b&&(a.addEventListener?a.addEventListener(b,c,{passive: true}):a.attachEvent("on"+b,c))} Could you please advise?