var isfirstinit = true; var canwheelprev = true; var fullpageprevindex = 1; var fullpagecurrindex = 1; $(function() { if (!checkletie9()) { animate(); } // 全屏组件 $('#fullpage').fullpage({ autoscrolling: true, scrollhorizontally: true, onleave: function(previndex, nextindex, direction) { fullpageprevindex = previndex; }, afterrender: function() { if (!checkletie9()) { initallanimcustome(); // 这里加动画 settimeout(function() { var slidediv = $("#fullpage .section").eq(fullpagecurrindex - 1);; $(slidediv).find(".anim_custome").each(function(idx, el) { var ocss = json.parse($(el).attr("ocss")); var ecss = json.parse($(el).attr("ecss")); var rtime = parsefloat($(el).attr("rtime")); var dtime = parsefloat($(el).attr("dtime")); console.log(ocss, ecss, rtime); inittweenanim($(el), ocss, ecss, rtime, dtime); }); $(slidediv).find("video").each(function(idx, el) { try { $(el)[0].play(); } catch (e) { } }); }, 1000); } bindpanel00swiper(); }, afterload: function(anchorlink, currindex) { console.log("afterload"); // 非ie9及以下才执行动画效果 if (!checkletie9()) { // if(isfirstinit){ // isfirstinit = false; // initallanimcustome(); // } fullpagecurrindex = currindex; // 初始动画 var prevdiv = $("#fullpage .section").eq(fullpageprevindex - 1); $(prevdiv).find(".anim_custome").each(function(idx, el) { var ocss = json.parse($(el).attr("ocss")); setcss($(el), ocss); }); // 这里加动画 var slidediv = $("#fullpage .section").eq(currindex - 1);; $(slidediv).find(".anim_custome").each(function(idx, el) { var ocss = json.parse($(el).attr("ocss")); var ecss = json.parse($(el).attr("ecss")); var rtime = parsefloat($(el).attr("rtime")); var dtime = parsefloat($(el).attr("dtime")); console.log(ocss, ecss, rtime); inittweenanim($(el), ocss, ecss, rtime, dtime); }); $(slidediv).find("video").each(function(idx, el) { try { $(el)[0].play(); } catch (e) { } }); $.fn.fullpage.setmousewheelscrolling(false); settimeout(function() { $.fn.fullpage.setmousewheelscrolling(true); }, 1000); } if (currindex > 1) { $("#nav").show(); } else { $("#nav").hide(); } } }); $("#nav .btn-top").click(function() { $.fn.fullpage.moveto(1); }); $(".panel_4_box").bind("mousewheel", function(event) { if (!canwheelprev) return false; $.fn.fullpage.setmousewheelscrolling(false); if (event.originalevent.wheeldelta > 0) { console.log('向下滚动'); var scrolltop = $(".panel_4_box").scrolltop(); if (scrolltop <= 0) { $.fn.fullpage.setmousewheelscrolling(true); canwheelprev = false; $.fn.fullpage.movesectionup(); settimeout(function() { canwheelprev = true; }, 500); } } else { console.log('向上滚动'); } }); }); function bindpanel00swiper() { $.getjson(base_url + "/index/getkv", {}, function(res) { console.log(res); var html = ''; for (var k in res.data) { if (res.data[k].type == 1) { html += '
'; if (res.data[k].url && res.data[k].url.length > 0) { html += ' '; } else { html += ' '; } html += '
'; } } $(".panel_00 .swiper-container .swiper-wrapper").append(html); settimeout(function() { var myswiper00 = new swiper('.panel_00 .swiper-container', { autoplay : 5000, pagination: '.panel_00 .pagination', grabcursor: true, paginationclickable: true, loop: true, onslidechangestart: function() { }, onslidechangeend: function(swiper) { } }) }, 100); }); } function initallanimcustome() { $(document.body).find(".anim_custome").each(function(idx, el) { var ocss = json.parse($(el).attr("ocss")); setcss($(el), ocss); }); } function setcss(el, ocss) { var transform = ""; if (typeof ocss.translatex != 'undefined') { transform += " translatex(" + ocss.translatex + "px) "; } if (typeof ocss.translatey != 'undefined') { transform += " translatey(" + ocss.translatey + "px) "; } if (typeof ocss.scalex != 'undefined') { transform += " scalex(" + ocss.scalex + ") "; } if (typeof ocss.scaley != 'undefined') { transform += " scaley(" + ocss.scaley + ") "; } if (typeof ocss.rotatex != 'undefined') { transform += " rotatex(" + ocss.rotatex + "deg) "; } if (typeof ocss.rotatey != 'undefined') { transform += " rotatey(" + ocss.rotatey + "deg) "; } if (typeof ocss.rotatez != 'undefined') { transform += " rotatez(" + ocss.rotatez + "deg) "; } if (transform != "") { $(el).css({ "transform": transform }); } if (typeof ocss.left != 'undefined') { $(el).css({ "left": ocss.left }); } if (typeof ocss.top != 'undefined') { $(el).css({ "top": ocss.top }); } if (typeof ocss.right != 'undefined') { $(el).css({ "top": ocss.right }); } if (typeof ocss.bottom != 'undefined') { $(el).css({ "top": ocss.bottom }); } if (typeof ocss.opacity != 'undefined') { $(el).css({ "opacity": ocss.opacity }); } } function inittweenanim(el, ocss, ecss, rtime, dtime) { new tween.tween(ocss) .to(ecss, rtime) .delay(dtime) .easing(tween.easing.linear.none) .onupdate(function() { setcss(el, ocss); }) .start(); } function animate() { tween.update(); window.requestanimationframe(animate); }