function scrollanimation(ele) { $(ele).each(function() { var _this = $(this); if (_this.offset().top > $(window).scrolltop() + $(window).height() || _this.offset().top < $(window).scrolltop() - _this.outerheight()) { // _this.removeclass('animate'); } else if ($(window).scrolltop() > _this.offset().top - $(window).height() * 0.7) { //预先加载图片begin var arrayimg2 = []; arrayimg2.push(_this.find('img').attr('src')); _preloadimg(arrayimg2,function(){ // 执行函数 _this.addclass('animate'); // _this.find(".k10 .ul").addclass('animate'); _this.find(".loading-sw").remove(); }) //预先加载图片end } }); $(window).scroll(function() { $(ele).each(function() { var _this = $(this); if (_this.offset().top > $(window).scrolltop() + $(window).height() || _this.offset().top < $(window).scrolltop() - _this.outerheight()) { // _this.removeclass('animate'); } else if ($(window).scrolltop() > _this.offset().top - $(window).height() * 0.7) { _this.addclass('animate'); // _this.find(".k10 .ul").addclass('animate'); _this.find(".loading-sw").remove(); } }); }); } function scrollanimation2(ele) { $(ele).each(function() { var _this = $(this); if (_this.offset().top > $(window).scrolltop() + $(window).height() || _this.offset().top < $(window).scrolltop() - _this.outerheight()) { // _this.removeclass('animate'); } else if ($(window).scrolltop() >= _this.offset().top - $(window).height() * 0.8) { _this.addclass('animate'); // _this.find(".k10 .ul").addclass('animate'); _this.find(".loading-sw").remove(); } }); $(window).scroll(function(){ $(ele).each(function() { var _this = $(this); if (_this.offset().top > $(window).scrolltop() + $(window).height() || _this.offset().top < $(window).scrolltop() - _this.outerheight()) { // _this.removeclass('animate'); } else if ($(window).scrolltop() >= _this.offset().top - $(window).height() * 0.8) { // console.log($(window).scrolltop() ,_this.offset().top - $(window).height() * 0.8) _this.addclass('animate'); // _this.find(".k10 .ul").addclass('animate'); _this.find(".loading-sw").remove(); } }); }); } scrollanimation2($('.section')); scrollanimation2($('.section2')); // $(window).scroll(function(){ // scrollanimation2($('.section')); // }) $(window).scroll(function() { var top = ($(window).scrolltop() / 3); $(".conbanner").css("background-position-y"); $(".conbanner").css({'background-position-y': top,'background-size':"cover"}); });