I try to implement some javascript functions for my Ipad device. I would like to use some swipe action and click action on my canvas div.
I implemented the horizontal and the vertical swipe function. I have to use the preventDefault on the touchstart event to prevent the full page scrolling, when swiping. It worked well, but after this I noticed that it disabled every click event on this div. When the preventDefault is removed the click event works again.
Is there any solution to solve this problem?
dojo.connect(this.node, "ontouchstart", this, "touchstart");
...
touchstart: function(e){
this.touch = dojo.clone(e.changedTouches[0]);
e.preventDefault();
}
this.node = document.getElementById('aa');
<div id="aa" style="width: 600px; height: 400px;">
<div onclick="alert('asd');" style="width: 100px; height: 100px; background-color: #ff0000; margin: auto;">
</div>
</div>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…