. havnt 그래도 그것을 테스트,
//add to the decleration:
var defaults = {
threshold: {
x: 30,
y: 10
},
swipeLeft: function() { alert('swiped left') },
swipeRight: function() { alert('swiped right') },
//THIS:
swipeMove: function(distance) { alert('swiped moved: '+distance.x+' horizontally and '+distance.y+' vertically') },
preventDefaultEvents: true
};
//add this to the init vars section
var lastpoint = {x:0, y:0}
//add an init to the lastpoint at start of swipe
function touchStart(event) {
console.log('Starting swipe gesture...')
originalCoord.x = lastpoint.x = event.targetTouches[0].pageX
originalCoord.y = lastpoint.y = event.targetTouches[0].pageY
}
//this is where you do your calculation
function touchMove(event) {
if (defaults.preventDefaultEvents)
event.preventDefault();
var difference = {
x:event.targetTouches[0].pageX - lastpoint.x,
y:event.targetTouches[0].pageY - lastpoint.y
}
//call the function
defaults.swipeMove(difference);
finalCoord.x = lastpoint.x = event.targetTouches[0].pageX
finalCoord.y = lastpoint.y = event.targetTouches[0].pageY
}
어쨌든 그런 일해야한다 : 기본적으로는 하나의 이벤트로 "슬쩍"가 저장되어 무엇을, 당신은 이런 식으로하는 TouchMove 이벤트 뭔가를 캡처 할 필요가있다.
이것이 작동하지 않는 것을 확인할 수 있습니다. – Xavier
위의 코드를 수정해야합니다.이 코드는 전체 코드가 아닙니다. 당신은 약간의 일을해야만합니다.) – longstaff
코드에 대해 언급 한 내용을 토대로 변경을했습니다 ... – Xavier