2012-07-17 125 views
0

我的网站垂直滑动内容。但是会发生什么:如果我在主屏幕上,并想点击最后一个菜单项(简报)..滑动显示所有内容在到达目的地链接(简报)之前..逐个滑动内容,否则显示全部内容

所以..我想要要知道,我需要做的只是滑动我点击的菜单项,否则所有的内容。

这是我的工作地点这个问题:http://www.alsite.com.br/luxxx

这是我的滑脚本:

$(document).ready(function() { 

     //get all link with class panel 
     $('a.panel').click(function() { 

        //reset and highlight the clicked link 
      $('a.panel').removeClass('selected'); 
      $(this).addClass('selected'); 

      //grab the current item, to be used in resize function 
      current = $(this); 

        //scroll it to the destination 
      $('#wrapper').scrollTo($(this).attr('href'), 800);  

        //cancel the link default behavior 
      return false; 
     }); 


     //resize all the items according to the new browser size 
     $(window).resize(function() { 

      //call the resizePanel function 
      resizePanel(); 
     }); 

     function resizePanel() { 

    //get the browser width and height 
    width = $(window).width(); 
    height = $(window).height(); 

    //get the mask height: height * total of items 
    mask_height = height * $('.item').length; 

    //set the dimension  
    $('#wrapper, .item').css({width: width, height: height}); 
    $('#mask').css({width: width, height: mask_height}); 

    //if the item is displayed incorrectly, set it to the corrent pos 
    $('#wrapper').scrollTo($('a.selected').attr('href'), 0); 

} 


    }); 

感谢您的帮助!

回答

0

当然,只要隐藏除当前显示的屏幕和要显示并滑动的屏幕之外的所有其他屏幕即可。如果你可以把.current类你目前正在观察的一个,这里是你如何能做到这一点:

$('.item').hide(); 
$((this).attr('href')).add('.current').show(); 
$('#wrapper').scrollTo($(this).attr('href'), 800); 
+0

要展开:将所有其他的div显示:无(或我想.hide() )来折叠它们。除了CURRENT div和要滚动的div。 – DaiYoukai 2012-07-17 18:37:26

+0

哼哼..我现在试试吧! – Preston 2012-07-17 18:39:11

+0

我不知道我是否做得对,但不工作。 '$(this).addClass('selected current');'我把你提供给我的代码 – Preston 2012-07-17 18:46:38