// JavaScript Document var data={ win_w:$(window).width(), win_h:$(window).height(), Tpage:0, choosePage:null, isAni:false, isApp:(window.innerWidth<900) }; var init=function(){ }; $(document).ready(function(){ new alan.scrollAnimate(); init(); indexFn.water(); indexFn.pic_slider(); indexFn.new_list(); indexFn.new_box(); // indexFn.pro_box(); if($('#cooperate').length>0){ coopFn.init(); } }); window.onload=function () { $('[data-hei]').each(function(index,e){ var wid=$(this).width(), hei=parseInt(wid*($(this).attr('data-hei'))); $(this).css('height',hei+"px"); }); } $(window).resize(function() { $('[data-hei]').each(function(){ var wid=$(this).width(), hei=parseInt(wid*($(this).attr('data-hei'))); $(this).css('height',hei+"px"); }); }); var indexFn = { water : function () { var cv = document.getElementById('water'); var ctx = cv.getContext('2d'); window.requestAnimFrame = (function(){ return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function( callback ){ window.setTimeout(callback, 1000 / 60); }; })(); var step =0; var bowidth = cv.width/5; var poswidth = cv.width/1.2; var a = ctx.createLinearGradient(0,0,0,cv.height); a.addColorStop(0,'#79bd28'); a.addColorStop(1,'#00653b'); function loop () { ctx.clearRect(0,0,cv.width,cv.height); step++; ctx.fillStyle = a; var angle = step*Math.PI/180; var deltaHeight = Math.sin(angle) * bowidth; var deltaHeightRight = Math.cos(angle) * bowidth; ctx.beginPath(); ctx.moveTo(poswidth,0); ctx.bezierCurveTo(poswidth+deltaHeight,cv.height/2,poswidth+deltaHeightRight,cv.height/2,poswidth,cv.height); ctx.lineTo(0, cv.height); ctx.lineTo(0, 0); ctx.lineTo(poswidth,0); ctx.closePath(); ctx.fill(); requestAnimFrame(loop); } loop(); }, pic_slider : function () { var slider = function (opts) { var box = opts.parent, list = box.find('li'), txt_box = opts.txt_box, txt_list = txt_box.find('li'), page_box = opts.page_box, page_list = page_box.find('li'), isAni = false, cur = 0; page_list.on('click',function () { if(isAni) return false; isAni = true; var _this = $(this), index = _this.index(); if(index == cur){ isAni = false; return false; } list.eq(cur).addClass('move').removeClass('on'); list.eq(index).addClass('cur_move'); txt_list.eq(index).addClass('move').siblings().removeClass('on'); setTimeout(function () { list.eq(cur).removeClass('move'); list.eq(index).addClass('on').removeClass('cur_move'); for(var n =1;n<=(page_list.length-1);n++){ var num = index+n; var rang = num - page_list.length; num = num < page_list.length - 1 ? num : (0+rang); if(n==1){ list.eq(num).addClass('n1').siblings().removeClass('n1'); } if(n==2){ list.eq(num).addClass('n2').siblings().removeClass('n2'); } } cur = index; },700); setTimeout(function () { txt_list.eq(index).addClass('on').removeClass('move'); isAni = false; },1200); _this.addClass('on').siblings().removeClass('on'); }); }; $('.pro-slider').each(function () { var _this = $(this), txt = _this.parents('.home-pro-list').find('.msg-box'), page = $('#'+$(this).attr('data-slide')); new slider({ parent:_this, page_box: page, txt_box : txt }) }); }, new_list :function () { var slider = function (opts) { var box = opts.parent, item = opts.items, pic_item = opts.pic_item; item.find('li').on('mouseenter',function () { var _this = $(this), index = _this.index(); pic_item.find('.pic-list').eq(index).addClass('on').siblings().removeClass('on'); }); }; $('.new-list').each(function () { var el = $(this), item = el.find('.new-item'), pic_item = el.find('.pic-item'); new slider({ parent : el, items : item, pic_item : pic_item }); }); }, new_box : function () { var tab = function (opts) { var box = opts.box, isAni = false, _tab = box.find('.new-tab'), item = box.find('.new-list'), list = _tab.find('li'), prev = _tab.find('.n-prev'), next = _tab.find('.n-next'), cur = 0, length = list.length - 1; prev.addClass('v-hide'); prev.on('click',function () { swiper_go(cur,'prev'); }); next.on('click',function () { swiper_go(cur,'next'); }); list.on('click',function () { var num = $(this).attr('data-cur'); swiper_go(num,'num'); }); function swiper_go(index,type) { if(isAni) return false; isAni = true; var left = 0; if(type == 'prev'){ cur = index>0 ? (index-1) : length; } if(type == 'next'){ cur = index0 ? (index-1) : length; } if(type == 'next'){ cur = index900){ var treeEl = document.querySelector('.un_r0'); var top_ = getTop(treeEl) - ($('header .bg_layer').height()+$('header .bg_layer').offset().top); scrolly.init({ wrapper: '#bloc', targets : '.scr-el', bgParallax : false, wrapperSpeed: 0.12, callback:function (e){ var dir = (e-top_)>0?(e-top_):0; treeEl.style.transform = 'translate3d(' + 0 + ',' + dir + 'px ,' + 0 + ')'; treeFn(e) } }); $(".tree").on("click",function (){ var num = $(this).index(); $("html, body").animate({ scrollTop: arr[num]+10+'px' }, 300); }); } function getTop(element){ var top; while (element.offsetTop === void 0) { element = element.parentNode; } top = element.offsetTop; while (element = element.offsetParent) { top += element.offsetTop; } return top; } function treeFn(top){ for (let i = (arr.length-1); i>=0 ; i--) { if(top>arr[i]){ if(cur !== i){ tree.eq(i).addClass('on').siblings().removeClass('on'); name_.text(tree.eq(i).text()); cur = i; } break; } } } $('.sw_2').each(function (){ var _this = $(this)[0]; var num=data.isApp?[-1,0,1,2]:[0,1,2,3]; var lists = $(this).find('.swiper-slide'); var sw_2 = new Swiper(_this, { slideActiveClass: 'active', slidesPerView: data.isApp?"auto":4, spaceBetween: data.isApp?20:32, centeredSlides: data.isApp, initialSlide: data.isApp?1:0, navigation: { nextEl: '.next-2', prevEl: '.prev-2', }, observer: true, observeParents: true, on:{ init: function(swiper){ lists.removeClass('on'); for (let i = 0; i < num.length; i++) { lists.eq(num[i]).addClass('on'); } }, slideChange: function(){ lists.removeClass('on'); for (let i = 0; i < num.length; i++) { lists.eq((num[i]+this.realIndex)).addClass('on'); } }, }, }); }); if(data.isApp){ $('.sw_app').each(function (){ var _this = $(this)[0]; var sw_app = new Swiper(_this, { slideActiveClass: 'active', slidesPerView: "auto", spaceBetween: 20, slideToClickedSlide: true, observer: true, observeParents: true, }); }); $('.sw_r1_app').each(function (){ var _this = $(this)[0]; var sw_r1_app = new Swiper(_this, { slideActiveClass: 'active', slidesPerView: "auto", centeredSlides:true, initialSlide: 1, spaceBetween: 20, observer: true, observeParents: true, }); }); } $('.swList').each(function (){ var _this = $(this)[0]; var num=data.isApp?[-1,0,1,2]:[0,1,2,3]; var lists = $(this).find('.swiper-slide'); new Swiper(_this, { slideActiveClass: 'active', slidesPerView: data.isApp?"auto":4, spaceBetween: 20, observer: true, observeParents: true, on:{ init: function(swiper){ lists.removeClass('on'); for (let i = 0; i < num.length; i++) { lists.eq(num[i]).addClass('on'); } }, slideChange: function(){ lists.removeClass('on'); for (let i = 0; i < num.length; i++) { lists.eq((num[i]+this.realIndex)).addClass('on'); } }, }, }); }); $('.sw_r3').each(function (){ var _this = $(this)[0]; var num=data.isApp?[-1,0,1]:[0,1]; var lists = $(this).find('.swiper-slide'); var msg_ = $('.sw3List'); var sw_3 = new Swiper(_this, { slideActiveClass: 'active', slidesPerView: 1, spaceBetween: data.isApp?10:(window.innerWidth*0.04), navigation: { nextEl: '.next-3', prevEl: '.prev-3', }, observer: true, observeParents: true, on:{ init: function(swiper){ lists.removeClass('on'); for (let i = 0; i < num.length; i++) { lists.eq(num[i]).addClass('on'); } }, slideChange: function(){ lists.removeClass('on'); for (let i = 0; i < num.length; i++) { lists.eq((num[i]+this.realIndex)).addClass('on'); } msg_.eq(this.realIndex).addClass('on').siblings().removeClass('on') }, }, }); }); $('.sw_r5').each(function (){ var _this = $(this)[0]; var sw_5 = new Swiper(_this, { slideActiveClass: 'active', slidesPerView: 1, effect: 'fade', pagination: { el: ".swiper-pagination", clickable: true, renderBullet: function (index, className) { return '0' + (index + 1) + ""; }, }, navigation: { nextEl: '.next-5', prevEl: '.prev-5', }, observer: true, observeParents: true, }); }); $("[data-tab]").each(function (){ var that = $(this), box_ = $("."+that.attr("data-tab")), lists = that.find('.lists'); lists.on("click",function (){ var num = $(this).index(); $(this).find('.layer-cir').addClass('on') $(this).siblings().find('.layer-cir').removeClass('on'); box_.eq(num).addClass('on').siblings().removeClass('on'); }) }); var sw_pop = new Swiper(".popSw", { slideActiveClass: 'active', slidesPerView: "auto", init: false, slideToClickedSlide: true, observer: true, observeParents: true, }); $('.mapIcon').each(function (){ var that = $(this), par = that.parents('.mapItem'); var w = par.width(); var realWidth=0; $("").attr("src", that.attr("src")).on("load",function() { realWidth = this.width; that.css('width',(realWidth/1266*w)+"px"); }); if(that.hasClass('on')){ that.on("click",function (){ pop_.addClass('on'); sw_pop.init(); }); } }) pClose.on("click",function (){ pop_.removeClass('on'); }) } }