var istouch = modernizr.touch, ismobile = false, //区分移动端与pc端 mobile = false, //区分手机端与平板 w_width = 0, w_height = 0, bannerimgh = 638, navitem = 0, h_height = 0, roll = 0, stop = 150, produs = 0, st = 0; var _mousemove; var _click; var _mousedown; var _mouseup; //移动端事件和pc事件的切换 if (modernizr.touch) { _mousemove = "touchmove"; _click = "touchend"; _mousedown = "touchstart"; _mouseup = "touchend"; } else { _mousemove = "mousemove"; _click = "click"; _mousedown = "mousedown"; _mouseup = "mouseup"; }; function pagebox() { w_width = jquery(window).width(); w_height = jquery(window).height(); //设置移动端参数 if (w_width <= 1024) { ismobile = true; } else if (w_width > 1024) { ismobile = false; }; //区分手机端和平板 if (w_width <= 640) { mobile = true; } else if (w_width > 640) { mobile = false; }; $(".pbanners figure").height(w_height); setimgmax($('.pbanners figure img'), 1920, 960, w_width, w_height); } pagebox(); jquery(window).resize(function() { pagebox(); }); var pagefn = { init: function(){ this.getscrollcolor(); this.getnavs(); this.cursorfollow(); this.setinnerbanner(); this.gethash(); this.getscrolltop(); this.loader(); }, loader: function(){ $(window).ready(function(){ if($(".loader").length > 0){ settimeout(function(){ $(".loader").addclass("active") },0); var demo = {score:0}, scoredisplay = document.getelementbyid("scoredisplay"); var tween = tweenlite.to(demo,4,{ score:100, onupdate:showscore }) function showscore() { scoredisplay.innerhtml = demo.score.tofixed(0); } settimeout(function() { tweenlite.to($(".loader"), 0.6, {opacity:0,display: "none"}); },4000) } }); }, getnavs: function(){ $(".menubtn").click(function(){ $(this).stop().toggleclass("active"); $(".navs__pop").stop().toggleclass("show"); }); $(".navs,.header__menus").hover(function(){ $(".header__menus").stop().slidedown(); },function(){ $(".header__menus").stop().slideup(); }); }, getscrollcolor: function() { function a(){ var s = $(window).scrolltop(); s > 30 ? $(".header").addclass('scroll'): $(".header").removeclass('scroll'); } $(window).scroll(a); a(); }, cursorfollow: function(e) { if ($(window).width() > 1024) { $(".navs__pop").on('mousemove', function(e) { var clientx = e.clientx, clienty = e.clienty; var scrollleft = $(this).scrollleft(), scrolltop = $(this).scrolltop(); var left = clientx + scrollleft, top = clienty + scrolltop; mytween = tweenlite.to($('.circles-circle'), 1, { x: left, y: top }); }) } }, setinnerbanner: function() { $("img.lazy").lazyload({ effect: "fadein", threshold: 10, placeholder: "images/loading.gif" }); jquery(window).scroll(function () { var windowtop = jquery(window).scrolltop(); if (windowtop < w_height) { jquery('.pbanner figure img').css('transform', "translate(0px," + (windowtop) / 3 + "px)"); }; }); if($(".ptext").length> 0){ pban1 = new splittext($('.ptext strong,.ptext p'), {type: "chars"}); pban2 = new splittext($('.ptext small'), {type: "chars"}); var s1 = new timelinemax(); s1.fromto(".pbanner figure", 5, {scale: 1.1},{scale: 1}); s1.staggerfrom(pban2.chars, 0.4, {autoalpha:0, scale:4, force3d:true}, 0.01, 1); s1.staggerfrom(pban1.chars, 0.8, {y: 260, ease: expo.easeout},0.05, 0.8); } }, gethash: function() { var hash = location.hash; jquery(".laval-menu-list li a").click(function(e){ var hash=jquery(this).attr("href").split("#")[1]; if(hash && jquery("#"+hash).length==1){ setscroll("#"+hash); } }); function gethashs(){ if(hash){ setscroll(hash); } }; var scnum=0; function setscroll(anchorcur){ if($(".manage").length > 0){ return; } scnum=$('.header').outerheight(); jquery("html,body").animate({ scrolltop: parseint(jquery(anchorcur).offset().top) -scnum},800); }; gethashs(); settimeout(function(){ gethashs(); },50) }, getscrolltop: function(){ $(".news-scolltop").click(function(){ jquery("html,body").animate({ scrolltop: 0},800); }); $(".pbanner__text .nmore").click(function(){ jquery("html,body").animate({ scrolltop: w_height},800); }); } } pagefn.init(); jquery(window).load(function() { jquery('.article-block').delay(300).scrollclass(); }); (function(jquery) { $.fn.scrollclass = function(config) { var defaults = {}; var config = jquery.extend(defaults, config); var target = this; function addaction() { var length = target.length; for (var i = 0; i < length; i++) { if (target.eq(i).hasclass('articleshow')) continue; var in_position = target.eq(i).offset().top + 100; var window_bottom_position = jquery(window).scrolltop() + jquery(window).height(); if (in_position < window_bottom_position) { target.eq(i).addclass('articleshow'); } } } addaction(); jquery(window).on('scroll', function() { addaction(); }); return target; }; })(jquery); function setimgmax(img, imgw, imgh, tw, th) { var twidth = tw || w_width; var theight = th || w_height; var coe = imgh / imgw; var coe2 = theight / twidth; if (coe < coe2) { var imgwidth = theight / coe; img.css({ height: theight, width: imgwidth, left: -(imgwidth - twidth) / 2, top: 0 }); } else { var imgheight = twidth * coe; img.css({ height: imgheight, width: twidth, left: 0, top: -(imgheight - theight) / 2 }); }; };