jquery.nicescroll icon indicating copy to clipboard operation
jquery.nicescroll copied to clipboard

[Chrome] Unable to preventDefault inside passive event listener due to target being treated as passive.

Open justmedanny opened this issue 5 years ago • 55 comments

I get this error in Chrome Console and a the same error will continuously generate as I scroll:

nicescroll.js:1 [Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive. See https://www.chromestatus.com/features/6662647093133312

justmedanny avatar Mar 29 '19 16:03 justmedanny

Same

louisiscoding avatar Apr 01 '19 17:04 louisiscoding

same

serkanhursgunel avatar Apr 02 '19 14:04 serkanhursgunel

Same. Also, in addition to displaying the error, the page scroll mode has unwanted jumps. for example see this page: https://www.hamyarit.com/

fgafarshad avatar Apr 06 '19 11:04 fgafarshad

Same

helen-flynn avatar Apr 09 '19 10:04 helen-flynn

I also discovered same issue, Hope it should be solved soon.

anandaitwadekar avatar Apr 09 '19 13:04 anandaitwadekar

Same issue

altairbow avatar Apr 10 '19 02:04 altairbow

not a solution.

But you can download previous Chrome versions to test this problem.

  • All OS: https://storage.googleapis.com/chromium-browser-snapshots/index.html
  • Win 64: https://storage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Win_x64/
  • Or: http://crportable.sourceforge.net/releases.html

vikyd avatar Apr 11 '19 12:04 vikyd

Fixed it!

As stated by Google, they've changed the behavior of passive event listeners only for window, document or body elements.

The fix is simply to force the listeners to be active for those elements. So replacing this https://github.com/inuyaksa/jquery.nicescroll/blob/347d35e29404904c84ca5ae720a962f290b8d564/jquery.nicescroll.js#L2555 with this https://github.com/Tolc/jquery.nicescroll/blob/6876279cb895bc6ad892c71f8a327dce85e18e9b/jquery.nicescroll.js#L2555 (passiveSupported && (active || el == window.document || el == window.document.body || el == window)) ? el.addEventListener(name, fn, { passive: false, capture: bubble }) : el.addEventListener(name, fn, bubble || false);

I've created a pull request #802

Tolc avatar Apr 11 '19 16:04 Tolc

Paging @inuyaksa because this is breaking on Chrome...

Tolc avatar Apr 15 '19 09:04 Tolc

@Tolc u save ma lyf dude, bunch of thx 👍

Fq2112 avatar Apr 21 '19 15:04 Fq2112

Fixed it!

As stated by Google, they've changed the behavior of passive event listeners only for window, document or body elements.

The fix is simply to force the listeners to be active for those elements. So replacing this jquery.nicescroll/jquery.nicescroll.js

Line 2555 in 347d35e

(passiveSupported && active) ? el.addEventListener(name, fn, { passive: false, capture: bubble }) : el.addEventListener(name, fn, bubble || false);

with this https://github.com/Tolc/jquery.nicescroll/blob/6876279cb895bc6ad892c71f8a327dce85e18e9b/jquery.nicescroll.js#L2555 (passiveSupported && (active || el == window.document || el == window.document.body || el == window)) ? el.addEventListener(name, fn, { passive: false, capture: bubble }) : el.addEventListener(name, fn, bubble || false);

I've created a pull request #802

İt Worked. Thanx..

serkanhursgunel avatar Apr 21 '19 15:04 serkanhursgunel

@Tolc I have repalced Line 2555 in 347d35e,İt Worked. The new problem is that the scroll bar is stuck and cannot be pulled to the bottom.Unless the page is reset.

Owen2008 avatar Apr 29 '19 10:04 Owen2008

@Owen2008 seems like it is an unrelated issue.

Tolc avatar Apr 29 '19 16:04 Tolc

Am facing same issue. Please suggest me appropriate solution for this error. I have bridge wordpress theme. i had already check but in my theme there is no nicescroll.js file.

rajukaushik94 avatar Jun 14 '19 05:06 rajukaushik94

same

roniahmadi avatar Jul 03 '19 04:07 roniahmadi

The fix works but if you want the fix for the minified file then find the following...

}), Y && i ? e.addEventListener(o, t, {

Or pretty print the min.js and goto line 1082, and replace with the following....

}), Y && (i || e == l || e == l.body || e == a) ? e.addEventListener(o, t, {

Hope this is helpful. Rich

rljdavies avatar Jul 23 '19 09:07 rljdavies

Fixed it!

As stated by Google, they've changed the behavior of passive event listeners only for window, document or body elements.

The fix is simply to force the listeners to be active for those elements. So replacing this https://github.com/inuyaksa/jquery.nicescroll/blob/347d35e29404904c84ca5ae720a962f290b8d564/jquery.nicescroll.js#L2555

with this https://github.com/Tolc/jquery.nicescroll/blob/6876279cb895bc6ad892c71f8a327dce85e18e9b/jquery.nicescroll.js#L2555 (passiveSupported && (active || el == window.document || el == window.document.body || el == window)) ? el.addEventListener(name, fn, { passive: false, capture: bubble }) : el.addEventListener(name, fn, bubble || false);

I've created a pull request #802

thanks! works fine

Alecto avatar Jul 26 '19 08:07 Alecto

A simple fix: document.addEventListener('touchstart', function(){}, {passive: false}) The third parameter of addEventListener is the configuration parameters

{
    capture: Boolean,  // listener will be triggered when event propagates to this event target in its capture phase
    once: Boolean, // whether or not you wish to call the handler only once
    passive: Boolean  // whether this listener will never call `preventDefault`
}

gyao96 avatar Aug 17 '19 22:08 gyao96

A simple fix: document.addEventListener('touchstart', function(){}, {passive: false}) The third parameter of addEventListener is the configuration parameters

{
    capture: Boolean,  // listener will be triggered when event propagates to this event target in its capture phase
    once: Boolean, // whether or not you wish to call the handler only once
    passive: Boolean  // whether this listener will never call `preventDefault`
}

it solved my problem. (Y)

hiraanwer95 avatar Aug 21 '19 11:08 hiraanwer95

same

MehdiKhoshnevisz avatar Aug 29 '19 09:08 MehdiKhoshnevisz

Just Add below CSS. it will solve your issue. :)

.owl-carousel { -ms-touch-action: pan-y; touch-action: pan-y; } or .owl-carousel { -ms-touch-action: none; touch-action: none; }

ghost avatar Aug 29 '19 10:08 ghost

Just Add below CSS. it will solve your issue. :)

.owl-carousel { -ms-touch-action: pan-y; touch-action: pan-y; } or .owl-carousel { -ms-touch-action: none; touch-action: none; }

I needed it, thanks!

DiegoArayaLobos avatar Aug 31 '19 22:08 DiegoArayaLobos

the second styling worked for me! Thanks!

jabbarn avatar Sep 03 '19 16:09 jabbarn

The fix works but if you want the fix for the minified file then find the following...

}), Y && i ? e.addEventListener(o, t, {

Or pretty print the min.js and goto line 1082, and replace with the following....

}), Y && (i || e == l || e == l.body || e == a) ? e.addEventListener(o, t, {

Hope this is helpful. Rich

It works for me! Thanks

vitordm avatar Sep 04 '19 18:09 vitordm

I am having the same error message but with a different JS file.

smoothPageScroll.min.js?ver=5.2.3:1 [Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive. See https://www.chromestatus.com/features/6662647093133312 wheel @ smoothPageScroll.min.js?ver=5.2.3:1 smoothPageScroll.min.js.zip

karimlo avatar Sep 05 '19 12:09 karimlo

Fixed it!

As stated by Google, they've changed the behavior of passive event listeners only for window, document or body elements.

The fix is simply to force the listeners to be active for those elements. So replacing this https://github.com/inuyaksa/jquery.nicescroll/blob/347d35e29404904c84ca5ae720a962f290b8d564/jquery.nicescroll.js#L2555

with this https://github.com/Tolc/jquery.nicescroll/blob/6876279cb895bc6ad892c71f8a327dce85e18e9b/jquery.nicescroll.js#L2555 (passiveSupported && (active || el == window.document || el == window.document.body || el == window)) ? el.addEventListener(name, fn, { passive: false, capture: bubble }) : el.addEventListener(name, fn, bubble || false);

I've created a pull request #802

Thanks man!! Great!

eversonv avatar Sep 07 '19 03:09 eversonv

Just Add below CSS. it will solve your issue. :)

.owl-carousel { -ms-touch-action: pan-y; touch-action: pan-y; } or .owl-carousel { -ms-touch-action: none; touch-action: none; }

Both worked. Thanks!

walterwing avatar Sep 09 '19 22:09 walterwing

Thanks a lot @Tolc ... Smooth Scroll is working fine now.. :)

Chetan-Goyal avatar Nov 10 '19 20:11 Chetan-Goyal

Just Add below CSS. it will solve your issue. :)

.owl-carousel { -ms-touch-action: pan-y; touch-action: pan-y; } or .owl-carousel { -ms-touch-action: none; touch-action: none; }

Worked for me

saurabh5986 avatar Nov 28 '19 06:11 saurabh5986

Thanks a lot @Tolc ... Smooth Scroll is working fine now.. :)

@Chetan-Goyal How do you fix it with Smooth-scroll? As there's no passiveSupported inside the code? Or we just simply input the variable? I use Smooth Scroll version 1.2.1

nntadotzip avatar Dec 03 '19 04:12 nntadotzip