var public = { winwidth: $(window).width(), //初始化 init: function(){ smoothscroll.init({offset:95}); if($('.timer').length>0){ var a = math.round($('.lh-power').offset().top+100); var b = math.round($(window).scrolltop()+$(window).height()); if(a0){ $(window).scroll(function(){ var s= $(this).scrolltop()/3; $('.lh-ban .img').css({ 'background-position':'center '+s+'px' }); }); } //文字效果 /*if($('.tlt').length>=1){ $('.tlt').each(function() { var offsettop = $(this).offset().top; var window_bottom_position = $(document).scrolltop() + $(window).height(); if(offsettop < window_bottom_position){ $(this).textillate(); } }); $(window).scroll(function(){ var _this = $(this); $('.tlt').each(function() { var offsettop = $(this).offset().top; var window_bottom_position = $(document).scrolltop() + $(window).height(); if(offsettop < window_bottom_position){ $(this).textillate(); } }); }); }*/ } //导航 this.nav(); }, //banner banner : function(a){ var a = a || {}; var opt = $.extend({ boxcell : '.lh-banner', stoponlastslide:true, slidesperview:1, spacebetween:0, parallax:true, pagination:'.hd', paginationtype:'bullets', speed:1000, loop:false, clickable:true, grabcursor:false, direction:'horizontal', initialslide:0, effect:'fade', mousewheel:false, scrollbar: { el: 'null', }, slidetoclickedslide:false, nextel:'.next', prevel:'.prev', noswipingclass:'stop-swiping', on:'', renderbullet:null },a); if($(opt.boxcell).find('.next').length>=1){ var nextel = $(opt.boxcell).find('.next'),prevel = $(opt.boxcell).find('.prev'); }else{ var nextel =opt.nextel,prevel =opt.prevel; } var myswiper = new swiper(opt.boxcell, { parallax : opt.parallax,//data-swiper-parallax slidesperview:opt.slidesperview, initialslide :opt.initialslide, slidetoclickedslide:opt.slidetoclickedslide, pagination : { el : opt.pagination, type:opt.paginationtype, clickable :opt.clickable, renderbullet:opt.renderbullet }, speed:opt.speed, loop:opt.loop, paginationclickable :opt.paginationclickable, effect : opt.effect, fadeeffect: { crossfade: true, }, spacebetween:opt.spacebetween, navigation: { nextel: nextel, prevel: prevel, }, grabcursor :opt.grabcursor, direction:opt.direction, mousewheel:opt.mousewheel, scrollbar:opt.scrollbar, noswipingclass:opt.noswipingclass, on:opt.on }); },//banner end //banner1 autoplay banner1 : function(a){ var a = a || {}; var opt = $.extend({ boxcell : '.lh-banner', stoponlastslide:true, parallax:true, pagination:'.hd', renderbullet:null, paginationtype:'bullets', speed:1000, loop:true, clickable:true, grabcursor:false, direction:'horizontal', initialslide:0, effect:'fade', mousewheel:false, scrollbar: { el: 'null', }, slidesperview:1, spacebetween:0, on:'' },a); if($(opt.boxcell).find('.next').length>=1){ var nextel = $(opt.boxcell).find('.next'),prevel = $(opt.boxcell).find('.prev'); }else{ var nextel =opt.nextel,prevel =opt.prevel; } var myswiper1 = new swiper(opt.boxcell, { autoplay:{ delay: 4500, stoponlastslide: false, disableoninteraction: true, }, parallax : opt.parallax,//data-swiper-parallax pagination : { el : opt.pagination, type:opt.paginationtype, clickable :opt.clickable, renderbullet:opt.renderbullet }, spacebetween:opt.spacebetween, speed:opt.speed, loop:opt.loop, paginationclickable :opt.paginationclickable, effect : opt.effect, fadeeffect: { crossfade: true, }, navigation: { nextel: nextel, prevel: prevel, }, slidesperview:opt.slidesperview, grabcursor :opt.grabcursor, direction:opt.direction, mousewheel:opt.mousewheel, scrollbar:opt.scrollbar, on:opt.on }); $(opt.boxcell).mouseenter(function () { myswiper1.autoplay.stop(); }) $(opt.boxcell).mouseleave(function () { myswiper1.autoplay.start(); }) },//banner end //导航 nav : function(){ //视频 if($('.lh-video-btn').length>0){ var video = document.getelementbyid('video'); $('.lh-video-btn').click(function(){ $('body').addclass('video'); video.play(); }); $('.lh-video-close').click(function(){ $('body').removeclass('video'); video.pause(); }); video.onended = function() { $('body').removeclass('video'); }; } //加入我们 if($('.lh-join-item').length>0){ $('.lh-join-h').click(function(){ var _this = $(this).parents('dd'); if(_this.hasclass('on')){ _this.removeclass('on'); _this.find('.lh-join-info').slideup(); }else{ _this.addclass('on').siblings().removeclass('on'); _this.siblings().find('.lh-join-info').slideup(); _this.find('.lh-join-info').slidedown(); } }); } //产品详情 if($('.lh-prodetails-banner').length>0){ this.banner({boxcell:'.lh-prodetails-banner',effect:'slide'}); } //详情 if($('.lh-ones-cont').length>0){ $('.lh-ones-cont').find('p,h1,h2,h3,h4,ul').addclass('wow animated fadeinup'); } //社会责任 if($('.lh-welfare-item li').eq(0).find('img').length>0){ welfaretop(); $(window).resize(function(e) { welfaretop(); }); function welfaretop(){ var height = $('.lh-welfare-item li').eq(0).find('img').eq(0).height(); $('.lh-welfare-item').css({'margin-top':-height}); } } //发展历程 if($('.lh-history-banner').length>0){ var slidesperview=3; if(this.winwidth<=850){ slidesperview=1; } this.banner({boxcell:'.lh-history-banner',effect:'slide',slidesperview:slidesperview}) } //搜索 $('.lh-search-btn').click(function(){ $('body').addclass('search'); }); $('.lh-search-layer a.lh-search-close').click(function(){ $('body').removeclass('search'); }); //导航 $('.lh-nav-btn').on('click',function(){ var _this = $(this); if(_this.hasclass('on')){ _this.removeclass('on'); $('body').removeclass('nav'); }else{ _this.addclass('on'); $('body').addclass('nav'); } }); //首页新闻 $('.lh-news-hd li').eq(0).addclass('on'); $('.lh-news-bd li').eq(0).fadein(); $('.lh-news-hd li').hover(function(){ var _this = $(this),_index = _this.index(); _this.addclass('on').siblings().removeclass('on'); $('.lh-news-bd li').fadeout(); $('.lh-news-bd li').eq(_index).stop(true,true).fadein(); },function(){}); //banner var effect='coverflow'; if(this.winwidth<=850){ effect='slide'; } if (!!window.activexobject || "activexobject" in window){ effect='slide'; } this.banner1({boxcell:'.lh-banner',effect:effect,pagination:'.lh-banner-hd'}); }, //阻止默认行为 preventdefault:function(el){ el.addeventlistener('touchmove',function(e){ e.preventdefault(); }); }, //效果 mouse : function(a){ var a = a || {}; var opt = $.extend({ boxcell : '.lhmouse', boxfun : function(_this,e){ } },a); $(opt.boxcell).on('mousemove',function(e){ var pointx = e.pagex; var pointy = e.pagey; var w = $(window).width()/2; var h = $(window).height()/2; var pianyix = pointx - w ; var pianyiy = pointy - h- $(window).scrolltop(); var jiaodux = (15/w)*pianyix; var jiaoduy = (15/h)*pianyiy; var _this = $(this); opt.boxfun(_this,jiaodux); }) }, returntop : function(){ $('.lhtop').on('click',function(){ $('html,body').animate({scrolltop:'0px'}); }); }, fixednav:function(){ var p=0;t=0; $(window).scroll(function(){ p = $(this).scrolltop(); if(t<=p){ $('body').addclass('fixed'); }else{ $('body').removeclass('fixed'); } t=p; }); } } public.init();