-2

我有一个大问题,我制作的网站适用于台式电脑,但不适用于手机(触摸屏)和 iPhone 和 iPad。在该站点中,我在向上/向下方向上滚动鼠标滚轮,并且在所有四个方向(左/右/上/下)上都有按键,如何使滑动命令也在这里工作?

我有类似http://socketstudios.com/的网站!

4

2 回答 2

0

您可以使用此插件绑定滑动事件: http: //labs.skinkers.com/touchSwipe/

示例: http: //labs.skinkers.com/touchSwipe/demo/Basic_swipe.html 示例代码:

$("#test").swipe( {
    //Generic swipe handler for all directions
    swipeLeft:function(event, direction, distance, duration, fingerCount) {
       alert("Swiped 50px left")
    },
    threshold:50
  });

上面的代码不会直接移动你的页面!在那里你可以使用该物业swipeStatus

$("#test4").swipe( { swipeStatus:swipe2, allowPageScroll:"vertical"} );

尝试这个:

$("body").swipe( {
 swipeUp:function(event, direction, distance, duration, fingerCount) {
       scroll_up();
    },
    swipeDown:function(event, direction, distance, duration, fingerCount) {
       scroll_down();
    },
    swipeLeft:function(event, direction, distance, duration, fingerCount) {
       scroll_left();
    },
    swipeRight:function(event, direction, distance, duration, fingerCount) {
       scroll_right();
    }
});
于 2013-02-06T18:10:59.670 回答
0

您可能想查看为此类功能构建的 JQuery Mobile 事件。

例如: http ://stephband.info/jquery.event.swipe/

于 2013-02-06T18:21:04.570 回答