Photoswipe捕获滑动事件

时间:2014-07-05 23:41:19

标签: jquery photoswipe

如何在photoswipe中捕捉滑动事件?

我尝试了以下内容......

var pSwipe = window.Code.PhotoSwipe.attach($(arrGallery), options);
pSwipe.show(0);
pSwipe.addEventHandler(window.Code.PhotoSwipe.ActionTypes.swipeLeft, function (e) {
    alert('swipe left');
});

但它没有抓住这个事件?

1 个答案:

答案 0 :(得分:0)

以下是解决方案:

var pSwipe = window.Code.PhotoSwipe.attach($(arrGallery), options);
pSwipe.show(0);
pSwipe.addEventHandler(window.Code.PhotoSwipe.EventTypes.onTouch, function (e) {
    switch (e.action) {
        case 'swipeDown':
            alert('you swiped down');
            break;
        case 'swipeUp':
            alert('you swiped up');
            break;
     }
});