datetimepicker icon indicating copy to clipboard operation
datetimepicker copied to clipboard

Non-passive event listener warnings

Open mlarsson opened this issue 7 years ago • 4 comments

When using datetimepicker in my Angular2 app I get a lot of warnings in the console in Chrome:

VM1152:15 [Violation] Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952 VM1152:15 [Violation] Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952 VM1152:15 [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 VM1152:15 [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 VM1152:15 [Violation] Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952 ...

Im using v. 2.5.18.

mlarsson avatar Mar 05 '18 09:03 mlarsson

same

kevinchugh avatar Jun 07 '18 13:06 kevinchugh

also same 2.5.20

cytech avatar Nov 15 '18 14:11 cytech

also same 2.5.20

emveeoh avatar Nov 21 '18 14:11 emveeoh

I had the same issue and got the warnings to go away with the following:

$.event.special.touchstart = {
  setup: function (_, ns, handle) {
    if (ns.includes('noPreventDefault')) {
      this.addEventListener('touchstart', handle, { passive: false })
    } else {
      this.addEventListener('touchstart', handle, { passive: true })
    }
  }
}
$.event.special.touchmove = {
  setup: function (_, ns, handle) {
    if (ns.includes('noPreventDefault')) {
      this.addEventListener('touchmove', handle, { passive: false })
    } else {
      this.addEventListener('touchmove', handle, { passive: true })
    }
  }
}
$.event.special.mousewheel = {
  setup: function (_, ns, handle) {
    if (ns.includes('noPreventDefault')) {
      this.addEventListener('mousewheel', handle, { passive: false })
    } else {
      this.addEventListener('mousewheel', handle, { passive: true })
    }
  }
}

source: https://stackoverflow.com/questions/46094912/added-non-passive-event-listener-to-a-scroll-blocking-touchstart-event

attack68 avatar Jun 05 '19 11:06 attack68