"use strict"; (function () { var timeAxisEvent = timeAxisActive(); timeLineActive(); var dynamicSwiper = new Swiper('.dynamic .left-pic', { autoplay: { disableOnInteraction: false }, on: { slideChange: function slideChange() { timeAxisEvent(this.activeIndex); } } }); //时间线激活效果 function timeLineActive() { var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; var lines = $('.dynamic .time-line .time-item'); $(lines).each(function (index) { if (index == key) { $(this).addClass('line-active'); } else { $(this).removeClass('line-active'); } }); } //时间轴激活效果 function timeAxisActive() { var axis = $('.dynamic .time-axis .axis-item'); var axisMap = new Map(); var preActive = null; $(axis).each(function (index) { if (index == 0) { preActive = this; $(this).addClass('axis-active'); } axisMap.set(index, this); }); return function () { var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; if ($(axisMap.get(index)) != preActive) { $(axisMap.get(index)).addClass('axis-active'); $(preActive).removeClass('axis-active'); preActive = $(axisMap.get(index)); //把index传给时间线关联激活样式即可 timeLineActive(index); } }; } //右侧鼠标hover事件 function rightHoverEvent() { var contentlists = $('.dynamic .list-wrap .list-item'); $(contentlists).each(function (index) { $(this).hover(function () { dynamicSwiper.slideTo(index, 1000, false); }); }); var timeLists = $('.dynamic .time-line .time-item'); $(timeLists).each(function (index) { $(this).hover(function () { dynamicSwiper.slideTo(index, 1000, false); }); }); } //鼠标悬停,暂停轮播 function swiperHoverFocus() { var stopPlay = false; $('.dynamic .list-wrap-js').mouseover(function () { if (stopPlay) return false; stopPlay = true; dynamicSwiper.autoplay.stop(); }); $('.dynamic .list-wrap-js').mouseout(function () { if (stopPlay) { stopPlay = false; dynamicSwiper.autoplay.start(); } }); } rightHoverEvent(); swiperHoverFocus(); //统计 $('#dynamic .statistics-js').on('click', function (e) { var id = $(this).attr('data-id'); var url = "/news/count?id=".concat(id); window.statistics.addLog({ url: url }); }); })();