Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nekooee opened this issue Nov 16, 2021 · 0 comments

Comments

@nekooee
Copy link

nekooee commented Nov 16, 2021

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.

@nekooee nekooee changed the title how to add {passive: true} for "touchstart" event?? please add {passive: true} for "touchstart" add "touchmove" event. Nov 16, 2021
@nekooee nekooee changed the title please add {passive: true} for "touchstart" add "touchmove" event. please add {passive: true} for "touchstart" and "touchmove" event. Nov 16, 2021
@nekooee nekooee changed the title please add {passive: true} for "touchstart" and "touchmove" event. please add {passive: true} for "touchstart" and "touchmove" and "touchend" events. Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant