验证是向上滚动还是向下滚动

/*scroll begin*/

jQuery(document).ready(function(){

var p=0,t=0;

jQuery(window).scroll(function(e){

var headerLine =jQuery('.header-container.sticky-header .header-line')

var headerWraper =jQuery('.header-container.sticky-header .header-wrapper')

p =jQuery(this).scrollTop();

if(t<=p){

headerWraper.css({'position':'static'});

headerLine.css({'position':'static'});

}

else{

if (t <100){   //这里是判断滚动到一定高度让fixed的改成static

jQuery('.header-newskin .header-line').css({'position':'static'});

jQuery('.header-newskin .header-wrapper').css({'position':'static'});;

}

else {

headerLine.css({'position':'fixed','left':0,'top':'0','zIndex':200,'background':'#ffffff','margin':'0 !important','padding':'7px 0','boxShadow':'5px 5px 5px rgba(0,0,0,0.1)','width':'100%'})

headerWraper.css({'position':'fixed','left':0,'top':'73px','zIndex':200,'background':'#ffffff','margin':'0 !important','padding':'7px 0','width':'100%'})

}

}

setTimeout(function(){t =p;},0);

});

});

/*scroll end*/

你可能感兴趣的:(验证是向上滚动还是向下滚动)