开发者

Scrolling a div with touch events

How can I scroll a div with touch events? I have a DIV with overflow set to hidden. I know I can scroll a DIV with javascript, here is an example for using the mousewheel:

function mousewheelScroll(event, delta) {
    var $t = $(this);
    var change = delta * 8;
    var top = $t.scrollTop();
    top = top - change;
    if (top < 0)
        top = 0;
    if (top > ($t.attr("scrollHeight") - $t.innerHeight()))
        top = ($t.attr("scrollHeight") - $t.innerHeight());
    $t.scrollTop(top);
}

But i haven't found an exam开发者_JS百科ple that will work with touch events for iOS devices.


Check out this plugin, it seems like it's just what you're looking for

http://plugins.jquery.com/project/touch-scroll

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜