2012-07-31 150 views
1

我“一直在追捕的文档和似乎无法找到一种方法,使在jQuery Mobile的滚动导航栏横在jQuery Mobile的水平滚动,有没有人做到了这一点了吗?随着安卓

看到我想要的东西像valums.com/files/2009/menu/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; 
    });   
}); 

但没有能够得到它有人可以帮我...谢谢

回答

0

什么你要找的是一个旋转木马。我在jQuery Mobile中找不到任何官方支持。 Sencha touch确实有一个实现。

如果你看http://forum.jquery.com/topic/jquery-mobile-carousel-sencha-style有人试图制作一个库来复制这个。在这里看到他们的演示http://jsfiddle.net/blackdynamo/yxhzU/

或者,你可以尝试使用现有的jquery/javascript轮播及让它在jQuery手机上工作。我知道sequence.js(http://www.sequencejs.com/themes/modern-slide-in/)支持触摸事件,并且非常适合任何你想要的,无论你想要什么样的过渡。所以这可能是一个很好的尝试。

编辑:

我用Google搜索了一下,发现:http://tympanus.net/Development/Elastislide/index2.html这似乎是同一类型的,你链接的一件事,虽然这一个支持触摸事件