Jquery向右滑动

时间:2013-02-14 14:18:59

标签: jquery slide

我有以下jquery。当我向下滚动导航栏时,它会粘到页面顶部。当它到达粘贴点时,我还希望一个小徽标从左向右滑入视图。

$(function() {

// grab the initial top offset of the navigation 
var sticky_navigation_offset_top = $('.topnav').offset().top;

// our function that decides weather the navigation bar should have "fixed" css  position or not.
var sticky_navigation = function(){
    var scroll_top = $(window).scrollTop(); // our current vertical position from the top

// if we've scrolled more than the navigation, change its position to fixed to stick to top, otherwise change it back to relative
if (scroll_top > sticky_navigation_offset_top) { 
    $('.topnav').css({ 'position': 'fixed', 'top':0,});
    $('.fixme').css({ 'display': 'block' });
    function slidelogo(){
        $('.navlogo').show('slide',{direction:'right'},1000);
    }slidelogo();
} else {
    $('.topnav').css({ 'position': 'relative' }); 
    $('.navlogo').css({ 'display': 'none' });
    $('.fixme').css({ 'display': 'none' });
}   
};

// run our function on load
sticky_navigation();

// and run it again every time you scroll
$(window).scroll(function() {
     sticky_navigation();
});

// NOT required:
// for this demo disable all links that point to "#"
$('a[href="#"]').click(function(event){ 
    event.preventDefault(); 
});

});
当我向下滚动页面时,

.navlogo是我想要滑入的内容。这是上面显示的整个代码的关键部分。我错了什么因为它让我发疯了!

if (scroll_top > sticky_navigation_offset_top) { 
$('.topnav').css({ 'position': 'fixed', 'top':0,});
$('.fixme').css({ 'display': 'block' });
function slidelogo(){
    $('.navlogo').show('slide',{direction:'right'},1000);
}slidelogo();
} else {
$('.topnav').css({ 'position': 'relative' }); 
$('.navlogo').css({ 'display': 'none' });
$('.fixme').css({ 'display': 'none' });
}   
};

0 个答案:

没有答案