//-------------------- 菜单事件------------------// //2017-6-5/lly $(function () { // menu subtitle var pathname = location.pathname; if (pathname && !pathname.match('/index') && pathname !== '/') { var subTitle = $('#menuSubTitle'); subTitle.text($('head title').text()) subTitle.css({opacity: 0}); } $('.hamburger-module').click(function () { $('body').toggleClass('menu-open'); if ($('.menu-open').length == 1) { $('.container').css('position', 'fixed'); $('.container').click(function () { $('.cycle-prev').off('click'); $('body').removeClass('menu-open'); $('.container').css('position', ''); }); } if ($('.menu-open').length == 0) { $('.container').css('position', ''); } }); $('.menu-down-li').find('a').click(function () { $(this).next($('.main-li-menu')).slideToggle(); }) }) //----------------nav滚动事件------------------// //2017-6-5/lly $(window).scroll(function () { var before = $(window).scrollTop(); $(window).unbind('scroll').scroll(function () { var after = $(window).scrollTop(); if (before < after) { $('.top-nav').css('position', 'absolute'); // $('.banner-drown-icon').hide(); //banner图上向下图标 before = after; } ; if (before > after) { $('.top-nav').css({ 'position': 'fixed', 'background': 'rgba(255,255,255,0.7)' }); before = after; } ; var scWidth = window.screen.width; if (before == 0) { $('.top-nav').css({ 'background': 'none' }); // if (scWidth > 768) $('.banner-drown-icon').show(); } }); }); //------------------ nav滚动事件------------------// //2017-6-5/lly $(function () { $(".look-detail").click(function () { $(this).parents('.item-li').next().slideToggle(); }) }) //-----------------移动端把文字排在图片后面------------------// //2017-6-5/ch $(function () { var changePosition = function () { //移动端 是把文字排在图片后面 var $imgBox = $(".banner-img-box"); if ($(window).width() > 768) { $imgBox.each(function () { var index = $(this).parents(".au-banner-box").index(); var $sib = $(this).siblings(".banner-text-box"); if (index % 2 == 0) { $(this).after($sib); } else { $(this).before($sib); } }) return; } ; $imgBox.each(function () { var $prev = $(this).prev(); if ($prev.length == 0) return true; $prev.before($(this)); }) } changePosition(); //初始化时调用 $(window).resize(function () { //窗口变化时调用 changePosition(); }) }); //--------------------采购服务页面图片切换------------------// //2017-6-7/ch $(function () { var $row = $(".slide-18-box>.slide-item"); $(".switch-button").on("click", function () { var index = $(this).index(); $(this).css('background', '#333'); $(this).siblings().css('background', '#c1c1c1'); if (index == 1) { $row.eq(0).css("margin-left", "-100%"); } else { $row.eq(0).css("margin-left", "0px"); } }) }) //----------------发展历程页面效果------------------// //2017-6-7/ch /*索引事件 绑定*/ $(function () { var $a = $(".slide-box>a"), //锚点集合 $imgBox = $(".course-img-box"), $slideBox = $("#slide-box"); if ($("#slide-box").length === 0) return; sHeight = $("#slide-box")[0].offsetHeight, $parent = $("#course-all-box"), jTop = $("#slide-box")[0].offsetHeight - $(window).height() / 2, //记录索引div 初始化时距离窗口顶部的距离 $(window).unbind('scroll').scroll(function () { // var cHeight = $slideBox.offset().top; var wHeight = $(window).height(); var containerHeight = $('#history-container').height(); var top = $("body").scrollTop() || $("html").scrollTop(); //记录body的scrolltop var footerHeight = document.querySelector('.footer').clientHeight; // var tFlag = (cHeight - top + sHeight / 2) < wHeight / 2; //判断是否固定定位 // var pTop = $parent.offset().top + $parent[0].offsetHeight - top; //历程容器底部 距离窗口顶部的距离 var fixedTop = 100-(top/containerHeight)*100; $slideBox.css({top:fixedTop+'%'}); /*if (pTop < (sHeight / 2 + wHeight / 2)) { //索引整块 的位置判断 $slideBox.css({ "position": "fixed", "bottom": 0, top: "20%" }); } else if (tFlag) { $slideBox.css({ "position": "fixed", "top": '20%', bottom: "auto" }); } else if (top <= jTop) { $slideBox.css({ "position": "fixed", "bottom": "auto", top: "20%" }); } else if (pTop > (sHeight / 2 + wHeight / 2)) { $slideBox.css({ "position": "fixed", "top": 'wHeight / 2 - sHeight / 2 + "px"', bottom: "auto" }); }*/ $imgBox.each(function (index) { //判断 图片盒子的位子来 年份横杆 的过度效果变化 var offsetT = $(this).offset().top; var tHeight = $(this).height(); if (offsetT - top < wHeight / 2) { //判断 图片盒子的位子来 $a.eq(index).addClass("active").siblings(".active").removeClass( "active"); } /*当图片从底部出现时 动画效果*/ if (offsetT - top > wHeight) { $(this).addClass("slide-up").removeClass("active"); } else if (offsetT - top + tHeight > 0 && offsetT - top < wHeight) { $(this).addClass("active"); } }); }); /*点击索引时 滑动到相依年份图片*/ $a.on("click", function (e) { var index = $(this).index(); var $active = $imgBox.eq(index); var offsetT = $active.offset().top; var wHeight = $(window).height(); $("body,html").stop().animate({ "scrollTop": offsetT - wHeight / 2 + 5 }, 750); }); })