[英]How to add Touch Events [Swipe Left/ Right] to a image gallery
I have been working on image gallery [html5] and its working fine in desktop version i would like to add touch based events for Ipad/Tablet devices. 我一直在研究图片库[html5],并且在桌面版本中可以正常使用,我想为Ipad /平板电脑设备添加基于触摸的事件。
Can you please suggest how to add touch based events using javascript/jquery. 您能否建议如何使用javascript / jquery添加基于触摸的事件。
Thanks, Srinivas 谢谢,斯里尼瓦斯
You can use this function 您可以使用此功能
swiperight or another direction 向右滑动或其他方向
// jquery mobile
$("#id").swiperight(function() {
//do some with $.mobile.changePage function
});
$("#id").swipeleft(function() {
//do some $.mobile.changePage function
});
// javascript
document.ontouchmove = function(e) {
var target = e.currentTarget;
while(target) {
if(checkIfElementShouldScroll(target))
return;
target = target.parentNode;
}
e.preventDefault();
};
This jQuery plugin works well. 这个jQuery插件效果很好。 http://www.netcu.de/jquery-touchwipe-iphone-ipad-library Easy to use.
http://www.netcu.de/jquery-touchwipe-iphone-ipad-library易于使用。 Ex:
例如:
$('.slideshow').touchwipe({
wipeLeft: function() {$('.slideshow').cycle('next');},
wipeRight: function() { $('.slideshow').cycle('prev');},
min_move_x: 60
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.