I have a #wrapper
div wrap a #pane
div, the #wrapper, overflow-x:scroll.
What I want to do is while I touch the #wrapper
,the #pane
should follow my finger moving.
my code is
$('#wrapper').on('touchmove',function(event){
var touch = event.originalEvent.targetTouches[0];
var move_x = touch.pageX;
$('#wrapper').scrollLeft(move_x);
})
The result is : Yes the #pane is following my finger just in reverse direction, but when my finger leave and touch again, the #pane scroll location jump to my finger x position instantly, that's not what I want. The #pane shouldn't move when I touch it until I drag around it.
如果您不希望它跳到手指位置,则必须存储当前位置,并根据您触摸的原始位置与停止触摸的结束位置之间的差异来移动它。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.