admin管理员组文章数量:1278690
Issue:
I have a problem where in the whole application where click event is used. The app will be used on both mobile and web. I am using Angular 6.
Every time you click on a button or link on the browser on my desktop it works on first click, but on mobile the click doesn't work sometimes. correct me if I'm wrong, but I believe people refer this as the ghost click.
I thought that this was the 300ms delay, but I have tried using hammerjs's tap and tried fastclick instead and it seems like its not the issue.
I have tried using touchstart in html instead of click/tap and it seems to get rid of the issue.
Is there a way to bind mousedown and touchstart to each other?
is there a way to use just click/mousedown on desktop and touchstart on mobile?
What other ways can I go about fixing this?
Issue:
I have a problem where in the whole application where click event is used. The app will be used on both mobile and web. I am using Angular 6.
Every time you click on a button or link on the browser on my desktop it works on first click, but on mobile the click doesn't work sometimes. correct me if I'm wrong, but I believe people refer this as the ghost click.
I thought that this was the 300ms delay, but I have tried using hammerjs's tap and tried fastclick instead and it seems like its not the issue.
I have tried using touchstart in html instead of click/tap and it seems to get rid of the issue.
Is there a way to bind mousedown and touchstart to each other?
is there a way to use just click/mousedown on desktop and touchstart on mobile?
What other ways can I go about fixing this?
3 Answers
Reset to default 5Try in your template:
<div
(touchmove)="touchMoving($event)"
(touchstart)="touchStart($event)"
(touchend)="touchEnd($event)"
>
In your ponent you can now use the $event data:
touchMoving($event) {
console.log($event);
}
If you are using Angular 6, Be default it internally uses hammerjs library to handle touch gesture events. Also it removes 300ms delay for double tap. Here is the URL that explains more on Touch Gesture in Angular. https://blog.angularindepth./gestures-in-an-angular-application-dde71804c0d0
I have found that you should ALWAYS use (mousedown) instead of (click) for buttons in Angular if its a mobile app. With click the event sometimes will not register due to DOM issues. For best performance just use mousedown.
本文标签: javascriptUsing touchstart andor click (mousedown) Angular 6Stack Overflow
版权声明:本文标题:javascript - Using touchstart andor click (mousedown) Angular 6 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741280623a2369985.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论