滚动图片视差效果
let Parallax = function(obj){
$(window).scroll(function(){
let hh;
let tt;
let wh = $(window).height();
let wt = $(window).scrollTop();
let num = 0;
obj.each(function(){
hh = $(this).height();
tt = $(this).offset().top;
num = ((wh / 2 + wt) - (hh / 2 + tt)) * 2 / (wh + hh) * 20;
if(wh + wt >= tt && hh + tt > wt){
$(this).find('img').css('transform','translate3d(0, '+ num +'%, 0)')
}
})
})
}
// 图片对象
Parallax($('.images-item'))