jQuery와 touchSwipe 플러그인을 사용하여 내용을 위아래로 스크롤합니다. 수학에 관련된 몇 가지 문제를 겪고 있으며 지역 사회가 신속하게이를 파악하는 데 도움이되는지 알고 싶었습니다.jQuery touchSwipe 콘텐츠 스크롤 기능
"distance"변수는 0부터 시작하는 양수 값만 반환하므로 사용자가 UP을 스 와이프 한 다음 DOWN을 스 와이프하기로 결정하면 문제가 발생합니다. 거리 값이 ex :(0, 15up, 32up, 20up, 5up, 10down, 40down). 이러한 모든 상황을 파악하기 위해 if 문을 4 개 작성했습니다. "방향 변경"if 문을 어떻게 처리합니까?
touchSwipe : http://labs.skinkers.com/touchSwipe/
슬쩍 위로 및 기능 아래 :
var _scrolling=false;
var _prev=0;
$("#list").swipe({
swipeStatus:function(event, phase, direction, distance, fingerCount) {
if(phase=="end"){return false;}
if(phase=="move" && !_scrolling) {
var t = parseInt($("#list").css("top").split('px')[0]);
var s = 0;
if(direction=="up" && (distance-_prev) > 0){
//still moving up
s = t-(distance-_prev);
_prev=distance;
} else if(direction=="up" && (distance-_prev) < 0){
//direction change - moving down
} else if(direction=="down" && (distance-_prev) > 0){
//still moving down
s = t+(distance-_prev);
_prev=distance;
} else if(direction=="down" && (distance-_prev) < 0){
//direction change - moving up
}
_scrolling=true;
$("#list").animate({ top:s }, 70, function() {_scrolling=false;});
}<!--if end-->
}<!--swipeStatus end-->
});