I want to calculate the distance between the initial value of the touchstart and the actual value on touchmove.
for exemple :
I touch the screen : startX = 100; Then, I move my finger on the screen : moveX = 150;
The distance from startX and moveX is (moveX - startX) = 50;
CODE UPDATED :
function touch(event) {
var moveX = event.pageX;
var totalMoved = Math.abs(document.startX - moveX);
shipX = totalMoved;
consoleLog(totalMoved);
};
function touchStart(event) {
touch(event.touches[0]);
document.startX = event.pageX;
};
function touchMove(event) {
event.preventDefault();
touch(event.touches[0]);
};
function touchEnd(event) {
touch(event.touches[0]);
var totalMoved = 0;
};