Tiny-slider: Warning about uses of preventDefault calls inside passive listener

Created on 29 Jan 2019  路  21Comments  路  Source: ganlanyuan/tiny-slider

__Issue description__: When swiping slider on mobile, browser leave warning in console:
Unable to preventDefault inside passive event listener invocation.

__Demo link/slider setting__: Default

_Tiny-slider version_: 2.9.1
_Browser name && version_: Chrome
_OS name && version_: Emulator/Android

The warning point to this method

        function onPanMove (e) {
            if (panStart) {
                var $ = getEvent(e);
                lastPosition.x = $.clientX;
                lastPosition.y = $.clientY;

                if (carousel) {
                    if (!rafIndex) { rafIndex = raf(function(){ panUpdate(e); }); }
                } else {
                    if (moveDirectionExpected === '?') { moveDirectionExpected = getMoveDirectionExpected(); }
                    if (moveDirectionExpected) { preventScroll = true; }
                }

                if (preventScroll) { e.preventDefault(); }
            }
        }

Most helpful comment

Adding preventScrollOnTouch: 'auto' to my options when calling tns fixed this issue for me.

All 21 comments

:+1:

+1

It's someone to help?

Came here to check for existing issues as we discovered the errors, too.

There is some initial work in https://github.com/ganlanyuan/tiny-slider/pull/357 to fix this.

+1 over here!

+1

Any update on this issue?

!up still have error in console

+1

+1

+1

+1

Adding preventScrollOnTouch: 'auto' to my options when calling tns fixed this issue for me.

@petertoh thank you savior!

preventScrollOnTouch: 'auto' didn't work for me, but preventScrollOnTouch: 'force' clears up the error. It seem like one of those should resolve the error until there is a permanent fix.

+1

  • 1

+1

+1

Both preventScrollOnTouch: 'auto' and preventScrollOnTouch: 'force' flagged the following issue in Lighthouse.

Does not use passive listeners to improve scrolling performance

jQuery had a similar problem, sadly it was never fixed.

Was this page helpful?
0 / 5 - 0 ratings