[英]How to add Touch Events [Swipe Left/ Right] to a image gallery
我一直在研究图片库[html5],并且在桌面版本中可以正常使用,我想为Ipad /平板电脑设备添加基于触摸的事件。
您能否建议如何使用javascript / jquery添加基于触摸的事件。
谢谢,斯里尼瓦斯
您可以使用此功能
向右滑动或其他方向
// 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();
};
这个jQuery插件效果很好。 http://www.netcu.de/jquery-touchwipe-iphone-ipad-library易于使用。 例如:
$('.slideshow').touchwipe({
wipeLeft: function() {$('.slideshow').cycle('next');},
wipeRight: function() { $('.slideshow').cycle('prev');},
min_move_x: 60
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.