开发者

Scrolling a div with touch events

开发者 https://www.devze.com 2023-02-28 04:46 出处:网络
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:

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

精彩评论

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