给同事写的侧边栏滚动动画,后来又说不需要了,在这里做个笔记,省得到时候再让我加上。
$(window).scroll(function(){
if($("#date").offset().top - $(document).scrollTop() < 0){
let pos = $(document).scrollTop()
$("#date").stop().animate({top: pos+"px"}, "fast");
}else if($(window).height()-[$("#date").offset().top - $(document).scrollTop()]-$("#date").height() < 0){
let pos = $(document).scrollTop()
$("#date").stop().animate({top: pos+"px"}, "fast");
}
}