$(document).ready(function(){ // header language $('.header_language').find('a').on('click',function(){ $(this).addclass('selected').siblings().removeclass('selected') }) // section1 滚动 var section1_index = 0; $('.index_section1_item').eq(section1_index).siblings().children().css({'opacity': 0,'transition-duration': '0s','transform': 'translatey(100px)'}) $('.section1_btns .section1_btn').on('click',function(){ section1_index = $(this).index() $(this).addclass('select_btn').siblings().removeclass('select_btn') $('.index_section1_items').stop().animate({marginleft: - section1_index * 100 + '%'},1000,function(){ $('.index_section1_item').eq(section1_index).siblings().children().css({'opacity': 0,'transition-duration': '0s','transform': 'translatey(100px)'}) $('.index_section1_item').eq(section1_index).children().css({'opacity': 1,'transition-duration': '0.6s','transform': 'translatey(0)'}) $('.index_section1_item').eq(section1_index).find('.box_hide').css({'opacity': 1,'transition-delay': '1.5s', 'transition-duration': '1s', 'transform': 'scale(1)'}).siblings().css({'opacity':0,'transition-delay': '1.5s','transition-duration':'0'}); $('.index_section1_item').eq(section1_index).siblings().find('.box_hide').css({'opacity': 0,'transition': '0', 'transform': 'scale(0.8)'}).siblings().css({'opacity': 1, 'transition': '0'}); }) }) // section3 滚动 var section3_index = 0; var section3_len = $('.section3_item').length - 1; var section3_onoff = true; var section3_width = $('.section3_item').eq(0).outerwidth() + 50; // 第一张添加到最后一张 $('.section3_items').append($('.section3_item').eq(0).clone()); // 左右点击事件 $('.section3_left').on('click',function(){ if( section3_onoff ){ section3_onoff = false; if( section3_index > 0){ section3_index --; }else{ section3_onoff = true; return; } section3_move() } }) $('.section3_right').on('click',function(){ if( section3_onoff ){ section3_onoff = false; if( section3_index + 3 < section3_len ){ section3_index++; section3_move(); }else{ section3_index++; $('.section3_items').stop().animate({marginleft: - section3_index * section3_width + 'px'},600,function(){ $('.section3_items').css({'margin-left': 0}) section3_index = 0; section3_onoff = true; }) } } }) // 重复动作 function section3_move(){ $('.section3_items').stop().animate({marginleft: - section3_index * section3_width + 'px'},600,function(){ section3_onoff = true; }) } // 滚动事件 var scroll_onoff = true; //滚动开关 var scroll_index = 0; var window_height = $(window).outerheight(); // 调整屏幕宽度 + 函数节流 // 限制函数触发频率 // 函数节流 500ms一次 默认 var throttle = function(fn, interval){ var _self = fn, // 保存需要延迟执行的函数 timer, // 定时器 firsttime = true; // 是否为第一次执行 return function(){ var args = arguments, _me = this; if( firsttime ){ // 第一次执行 _self.apply(_me, args); // 用还行函数执行 并修改this指向 return firsttime = false; } if(timer){ // 定时器存在 return false; } timer = settimeout(function(){ cleartimeout(timer); timer = null; _self.apply(_me, args); },interval || 500) } } $(window).on('resize',throttle(function(){ section3_width = $('.section3_item').eq(0).outerwidth() + 80; window_height = $(window).outerheight(); $('.sections').css({'height': window_height}) })) // 初始加载位置纠正 var up_down = ($(document).scrolltop()/window_height - math.floor( $(document).scrolltop()/window_height))>0.5? 1 : 0; scroll_index = math.floor( $(document).scrolltop()/window_height) + up_down; // console.log(scroll_index) menu_move() window_move() if( $(window).outerwidth() > 1200 ){ $(document).on('mousewheel dommousescroll',function(e){ e = e || window.event; var direction; //滚动方向 // e.originalevent.wheeldelta if( e.originalevent.wheeldelta ){ direction = e.originalevent.wheeldelta > 0 ? 1 : -1; //chrome && ie 1向上 -1向下 }else if( e.originalevent.detail ){ direction = e.originalevent.detail > 0 ? -1 : 1 // firefox 1向上 -1向下 } // console.log(direction) if( scroll_onoff ){ scroll_onoff = false; if( direction == -1){ scroll_index++ scroll_index = math.min(scroll_index,5); }else{ scroll_index-- scroll_index = math.max(scroll_index,0); } // console.log(scroll_index) // 左侧导航栏目动画 menu_move() // 整屏滚动动画 window_move() } return false; }) } // 动画抽简 function menu_move(){ if( scroll_index > 1 && scroll_index < 3){ $('.left_menu').addclass('left_menu_other').removeclass('left_menu_hide left_menu_specia') $('.header_nav').removeclass('header_nav_sec3'); $('.header_nav').removeclass('header_nav_hide'); } if(scroll_index == 4){ $('.left_menu').addclass('left_menu_other').removeclass('left_menu_hide left_menu_specia') $('.header_nav').removeclass('header_nav_sec3'); $('.header_nav').removeclass('header_nav_hide'); } if( scroll_index == 3){ $('.left_menu').addclass('left_menu_specia left_menu_other').removeclass('left_menu_hide') $('.header_nav').addclass('header_nav_sec3'); $('.header_nav').removeclass('header_nav_hide'); } if( scroll_index == 5){ $('.left_menu').addclass('left_menu_hide') $('.header_nav').addclass('header_nav_hide') $('.header_nav').removeclass('header_nav_sec3'); } if( scroll_index == 0){ $('.left_menu').removeclass('left_menu_other').removeclass('left_menu_hide left_menu_specia') $('.header_nav').removeclass('header_nav_sec3'); $('.header_nav').removeclass('header_nav_hide'); } if( scroll_index == 1){ $('.left_menu').addclass('left_menu_other').removeclass('left_menu_hide left_menu_specia') $('.header_nav').removeclass('header_nav_sec3'); $('.header_nav').removeclass('header_nav_hide'); $('.index_section1_item').eq(0).find('.box_hide').css({'opacity': 1,'transition-delay': '1.5s', 'transition-duration': '1s', 'transform': 'scale(1)'}).siblings().css({'opacity':0,'transition-delay': '1.5s','transition-duration':'0'}); } } function window_move(){ $('.left_menus li').eq(scroll_index).addclass('selected').siblings().removeclass('selected') $('html,body').stop().animate({scrolltop: scroll_index* window_height},1000,function(){ scroll_onoff = true; }) } // 左侧导航条点击事件 $('.left_menus li').on('click',function(){ scroll_onoff = false; scroll_index = $(this).index() menu_move() window_move() }) // 视频按钮点击 $('.openvideo').on('click',function(){ if( $(this).attr('data-open') === 'false' ){ $(this).attr('data-open','true'); $('.openvideobox').css({'transform': 'scale(1)'}); var video_src = $(this).attr('data-video'); if( !$('.openvideobox').find('video').attr('src') ){ $('.openvideobox').find('video').attr('src', video_src); }; document.getelementbyid('opendvideo').play(); } }) // 关闭视频 $('.openvideobox').on('click',function(e){ if(e.target.classname === 'openvideobox'){ $('.openvideobox').css({'transform': 'scale(0)'}); document.getelementbyid('opendvideo').pause(); $('.openvideo').attr('data-open','false'); } }) // menu $('.header_menu').click(function(){ if( !$(this).data('open') ){ $(this).find('.header_menu_b span').addclass('header_menu_bopen'); $(this).find('.header_menunav').stop().fadein(); $(this).find('.header_menulay').stop().fadein(); }else{ $(this).find('.header_menu_b span').removeclass('header_menu_bopen'); $(this).find('.header_menunav').stop().fadeout(0); $(this).find('.header_menulay').stop().fadeout(0); } $(this).data('open', !$(this).data('open') ); }); })