henrygd / bigger-picture

JavaScript lightbox gallery for images, video, audio, iframes, html. Zoomable, responsive, accessible, lightweight.
https://biggerpicture.henrygd.me
MIT License
231 stars 17 forks source link

chrome warns of non-passive event listeners #40

Closed ellemenno closed 9 months ago

ellemenno commented 9 months ago

when navigating through a gallery, each image load prompts the following log message in Chrome:

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

this can be seen by opening the javascript console on the demo page, and setting the log filter to include 'Verbose'.

henrygd commented 9 months ago

This is intentional to stop background scrolling when zooming in / out. The listener is removed when the gallery is closed so there shouldn't be any actual impact to scroll performance.

If someone knows a better way to do this, let me know. But I experimented back when I first made the library and this seemed like the best approach at the time.