I'm getting the following error in the console referencing my mobile swipe script.
Error: [Violation]
Added non-passive event listener to a scroll-blocking 'touchstart' event.
Consider marking event handler as 'passive' to make the page more responsive.
Below is the code snippet:
class Swipe {
constructor(element) {
this.xDown = null;
this.yDown = null;
this.element = typeof(element) === 'string' ? document.querySelector(element) : element;
this.element.addEventListener('touchstart', function(evt) {
this.xDown = evt.touches[0].clientX;
this.yDown = evt.touches[0].clientY;
}.bind(this), false);
}
I ran across another article on this site that said to add the following:
document.addEventListener('touchstart', handler, {passive: true});
I've tried every possible way to implement this code into what I have with no success. When I try to add this statement it breaks my slider.
How would I go about adding this or inserting it into what I have already?
from Javascript error - Touchstart - [Violation] Added non-passive event listener to a scroll-blocking 'touchstart' event
No comments:
Post a Comment