I'm using the ionic2 to programing a mobile app.I want to record the whole trail when the finger touch and move on the screeen.first,I used the
document.addEventListener('touchmove',touch,false);
I'm using the ionic2 to programing a mobile app.I want to record the whole trail when the finger touch and move on the screeen.first,I used the
document.addEventListener('touchmove',touch,false);
You can setup event bindings for touchstart and touchmove. These event bindings will call the method when screen will be touched or dragged and return trail of coordinates.
home.html
<ion-content padding>
<div
id="my-div"
(touchstart)="handlestart($event)"
(touchmove)="handlemove($event)">
</div>
</ion-content>
home.ts
export class HomePage {
handlestart(event) {
console.log('start: X:' + event.touches[0].pageX + ', Y:' +event.touches[0].pageY);
}
handlemove(event) {
console.log('move: X:' + event.touches[0].pageX + ', Y:' +event.touches[0].pageY);
}
}
Output