xdan / datetimepicker

jQuery Plugin Date and Time Picker
https://xdsoft.net/jqplugins/datetimepicker/
MIT License
3.5k stars 1.52k forks source link

Non-passive event listener warnings #647

Open mlarsson opened 6 years ago

mlarsson commented 6 years ago

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.

kevinchugh commented 6 years ago

same

cytech commented 5 years ago

also same 2.5.20

emveeoh commented 5 years ago

also same 2.5.20

attack68 commented 5 years ago

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