Skip to content

Instantly share code, notes, and snippets.

@zhoumengkang
Created March 3, 2014 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhoumengkang/9327001 to your computer and use it in GitHub Desktop.
Save zhoumengkang/9327001 to your computer and use it in GitHub Desktop.
滚动的bug
var flag = false;
$(window).scroll(function() {
console.log(flag);
if(flag){
return false;
}
if($(window).scrollTop()==0){
//恢复
flag = true;
$(".sign").fadeOut('100',function(){
$("#intro").fadeIn('slow')
});
$("#header").removeClass('fixed_top').animate({
"height": "96px"
}).find(".logo").animate({
"font-size": "40px",
"line-height": "96px"
}).parent().parent().find(".nav").animate({
"line-height": "40px",
"padding":0,
"margin-top":"28px",
"margin-bottom":"28px"
},function(){
flag = false;
});
}else{
flag = true;
if($("#header").hasClass('fixed_top')){
return false;
}
$("#header").addClass('fixed_top').animate({
"height": "46px"
},500).find(".logo").animate({
"font-size": "28px",
"line-height": "46px"
}).parent().parent().find(".nav").animate({
"line-height": "46px",
"padding":0,
"margin-top":0,
"margin-bottom":0
},function(){
flag = false;
});
$("#intro").hide(function(){
$(".sign").css({"padding-top":"15px"}).show();
});
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment