滑动窗口滚动条触发事件

$(window).on("scroll", function() {
if (timer) {
clearTimeout(timer);
timer = null;
}

timer = setTimeout(function() {
var st = $(window).scrollTop();
$("#imgbox").css('top',st+"px"); //弹出窗
if(st>240){
$(".infoimg").each(function(i){var src =$(this).attr("_src"); $(this).attr('src',src); $(this).removeAttr("_src");});
}

var offsetTop = st - scrollTop;
if (offsetTop > 0 && st > topBarHeight) {
topBar.css("top", -topBarHeight);
} else {
topBar.css("top", 0);
}

scrollTop = st;

timer = null;
}, 300);

});

 

posted @ 2017-01-16 13:23  明月照亮天涯  阅读(884)  评论(0编辑  收藏  举报