在安卓系统中使用jquery Mobile中的水平滚动

With horizontal scroll in jquery Mobile in android

本文关键字:Mobile 水平 滚动 jquery 系统      更新时间:2024-06-13

我一直在寻找文档,似乎找不到在jQuery mobile中制作可滚动水平导航条的方法。有人做到了吗?

看,我想要类似valums.com/files/2009/enu/final.htm的东西,但只是一个导航,这样你就可以向左或向右滑动以访问更多菜单项

我猜这就是你想要的。

HTML。

<div class="categories">                
        <ul>                    
            <li><span><a href="">ABC</a></span></li>
            <li><span><a href="">DEF</a></span></li>
            <li><span><a href="">GHI</a></span></li>
            <li><span><a href="">JKL</a></span></li>
        </ul>               
    </div>

JQuery

$(function(){           
    var step = 1;
    var current = 0;
    var maximum = $(".categories ul li").size();
    var visible = 2;
    var speed = 500;
    var liSize = 120;
    var height = 60;    
    var ulSize = liSize * maximum;
    var divSize = liSize * visible; 
    $('.categories').css("width", "auto").css("height", height+"px").css("visibility", "visible").css("overflow", "hidden").css("position", "relative");
    $(".categories ul li").css("list-style","none").css("display","inline");
    $(".categories ul").css("width", ulSize+"px").css("left", -(current * liSize)).css("position", "absolute").css("white-space","nowrap").css("margin","0px").css("padding","5px");
    $(".categories").swipeleft(function(event){
        if(current + step < 0 || current + step > maximum - visible) {return; }
        else {
            current = current + step;
            $('.categories ul').animate({left: -(liSize * current)}, speed, null);
        }
        return false;
    });
    $(".categories").swiperight(function(){
        if(current - step < 0 || current - step > maximum - visible) {return; }
        else {
            current = current - step;
            $('.categories ul').animate({left: -(liSize * current)}, speed, null);
        }
        return false;
    });         
});

但无法获得它,有人能帮我吗…谢谢

您要找的是一个旋转木马。我在jquery mobile中找不到任何官方支持。Sencha touch确实有一个实现。

如果你看http://forum.jquery.com/topic/jquery-mobile-carousel-sencha-style有人试图建立一个图书馆来复制这一点。在此处查看他们的演示http://jsfiddle.net/blackdynamo/yxhzU/

或者,您可以尝试使用现有的jquery/javascript转盘,并使其在jquery-mobile上工作。我知道sequence.js(http://www.sequencejs.com/themes/modern-slide-in/)支持触摸事件,并且非常适合您想要的任何内容,以及您想要的任意转换。所以这可能是一个很好的尝试。

编辑:

我在谷歌上搜索了一下,发现:http://tympanus.net/Development/Elastislide/index2.html这似乎与您链接的是同一类型的东西,尽管这个支持触摸事件