Wlada / vue-carousel-3d

Vue Carousel 3D - Beautiful, flexible and touch supported 3D Carousel for Vue.js
MIT License
969 stars 203 forks source link

please add {passive: true} for "touchstart" and "touchmove" and "touchend" events. #181

Open nekooee opened 2 years ago

nekooee commented 2 years ago

Hi, Google says "Does not use passive listeners to improve scrolling performance". I need to add {passive: true} to "touchstart" and "touchmove" event.

this code :

  if ('ontouchstart' in window) {
        this.$el.addEventListener('touchstart', this.handleMousedown);
        this.$el.addEventListener('touchend', this.handleMouseup);
        this.$el.addEventListener('touchmove', this.handleMousemove);
      } else {
        this.$el.addEventListener('mousedown', this.handleMousedown);
        this.$el.addEventListener('mouseup', this.handleMouseup);
        this.$el.addEventListener('mousemove', this.handleMousemove);
      }

must be replaced with below code:

  if ('ontouchstart' in window) {
        this.$el.addEventListener('touchstart', this.handleMousedown,{passive: true});
        this.$el.addEventListener('touchend', this.handleMouseup,{passive: true});
        this.$el.addEventListener('touchmove', this.handleMousemove,{passive: true});
      } else {
        this.$el.addEventListener('mousedown', this.handleMousedown);
        this.$el.addEventListener('mouseup', this.handleMouseup);
        this.$el.addEventListener('mousemove', this.handleMousemove);
      }

please help me Thank you.