簡體   English   中英

如何將觸摸事件[向左/向右滑動]添加到圖像庫

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM