Skip to content

Add support for 'Passive event listeners' to improve page scroll performance #16

@evolve2k

Description

@evolve2k

Implementing a horizontal swipe using touch events with this library started producing this warning in our console:

Main.elm:8830 [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

Further research brought us to this explanation on caniuse:

Event listeners created with the passive: true option cannot cancel (preventDefault()) the events they receive. Primarily intended to be used with touch events and wheel events. Since they cannot prevent scrolls, passive event listeners allow the browser to perform optimizations that result in smoother scrolling.

ref: https://caniuse.com/#feat=passive-event-listener

Our use case is that of having a scrollable list of items on a mobile device and that each item is the full width of the screen and is swipable. Here's an example (in JS) for illustration: http://jsfiddle.net/evolve2k/afkdtjh9/14/

We're interested in how we can utilise passive event listeners with this library.
Can you see a way of doing this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions