ganlanyuan / tiny-slider

Vanilla javascript slider for all purposes.
MIT License
5.25k stars 786 forks source link

Warning about uses of preventDefault calls inside passive listener #370

Open tungtrinh opened 5 years ago

tungtrinh commented 5 years ago

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(); }
            }
        }
Eduruiz commented 5 years ago

:+1:

karneaud commented 5 years ago

+1

kriss145 commented 5 years ago

It's someone to help?

leomelzer commented 5 years ago

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.

SuperSchek commented 5 years ago

+1 over here!

jarod022 commented 5 years ago

+1

drjgray commented 5 years ago

Any update on this issue?

lirfaum commented 5 years ago

!up still have error in console

jblacas commented 5 years ago

+1

demyan1411 commented 5 years ago

+1

amydepalma commented 5 years ago

+1

savchukm commented 5 years ago

+1

petertoh commented 5 years ago

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

hmmhmmhm commented 4 years ago

@petertoh thank you savior!

TheBeardNerd commented 4 years ago

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.

mark-at-tusksoft commented 4 years ago

Possibly related?

pdoreau commented 4 years ago

+1

Preen commented 4 years ago
craigdg commented 4 years ago

+1

polikashina commented 4 years ago

+1

JosephWesker commented 3 years ago

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.

97Fakhreddine commented 3 years ago

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.

Its helpful, thanks :)