...
|
...
|
@@ -7,6 +7,9 @@ var $ = require('jquery'), |
|
|
Hammer = require('hammer'),
|
|
|
Swiper = require('yoho.iswiper'),
|
|
|
lazyLoad = require('yoho.lazyload'),
|
|
|
$mobileWrap = $('.mobile-wrap'),
|
|
|
$overlay = $('.overlay'),
|
|
|
$sideNav = $('.side-nav'),
|
|
|
bannerSwiper,
|
|
|
recommendSwiper,
|
|
|
hotBrandsSwiper,
|
...
|
...
|
@@ -28,31 +31,11 @@ require('./maybe-like'); |
|
|
|
|
|
lazyLoad($('img.lazy'));
|
|
|
|
|
|
//$('img:in-viewport').trigger('appear');
|
|
|
|
|
|
//点击首页汉堡menu图标,滑出侧栏导航
|
|
|
// $('.nav-btn').on('tap', function (event) {
|
|
|
// if (!$(this).hasClass('menu-open')) {
|
|
|
// $('.mobile-wrap').addClass('menu-open');
|
|
|
// $('.overlay').show().css('opacity', 0.3);
|
|
|
// $('.side-nav').addClass('on');
|
|
|
|
|
|
// //设置boy高宽,页面不能上下滑动
|
|
|
// $('body').css({
|
|
|
// height: $(window).height(),
|
|
|
// width: '100%',
|
|
|
// overflow: 'hidden'
|
|
|
// });
|
|
|
// }
|
|
|
// event.stopPropagation();
|
|
|
// });
|
|
|
|
|
|
navHammer = new Hammer($('.nav-btn')[0]);
|
|
|
navHammer.on('tap', function(event) {
|
|
|
if (!$(this).hasClass('menu-open')) {
|
|
|
$('.mobile-wrap').addClass('menu-open');
|
|
|
$('.overlay').show().css('opacity', 0.3);
|
|
|
$('.side-nav').addClass('on');
|
|
|
$mobileWrap.addClass('menu-open');
|
|
|
$overlay.show().css('opacity', 0.3);
|
|
|
$sideNav.addClass('on');
|
|
|
|
|
|
//设置boy高宽,页面不能上下滑动
|
|
|
$('body').css({
|
...
|
...
|
@@ -60,34 +43,16 @@ navHammer.on('tap', function(event) { |
|
|
width: '100%',
|
|
|
overflow: 'hidden'
|
|
|
});
|
|
|
}
|
|
|
event.stopPropagation();
|
|
|
event.srcEvent.stopPropagation();
|
|
|
});
|
|
|
|
|
|
//点击页面主体,收起侧栏导航及二级导航
|
|
|
// $('.mobile-wrap').on('tap', function () {
|
|
|
// if ($(this).hasClass('menu-open')) {
|
|
|
// $('.mobile-wrap').removeClass('menu-open');
|
|
|
// $('.overlay').css('opacity', 0);
|
|
|
// $('.sub-nav').removeClass('show');
|
|
|
// $('.side-nav').removeClass('on');
|
|
|
// $('body').css({
|
|
|
// height: 'auto',
|
|
|
// overflow: 'auto'
|
|
|
// });
|
|
|
// setTimeout(function() {
|
|
|
// $('.overlay').hide();
|
|
|
// }, 300);
|
|
|
// }
|
|
|
// });
|
|
|
|
|
|
mobileWrapHammer = new Hammer($('.mobile-wrap')[0]);
|
|
|
mobileWrapHammer.on('tap', function(event) {
|
|
|
if ($(this).hasClass('menu-open')) {
|
|
|
$('.mobile-wrap').removeClass('menu-open');
|
|
|
$('.overlay').css('opacity', 0);
|
|
|
mobileWrapHammer.on('tap', function(e) {
|
|
|
if ($mobileWrap.hasClass('menu-open')) {
|
|
|
$mobileWrap.removeClass('menu-open');
|
|
|
$overlay.css('opacity', 0);
|
|
|
$('.sub-nav').removeClass('show');
|
|
|
$('.side-nav').removeClass('on');
|
|
|
$sideNav.removeClass('on');
|
|
|
$('body').css({
|
|
|
height: 'auto',
|
|
|
overflow: 'auto'
|
...
|
...
|
@@ -95,11 +60,12 @@ mobileWrapHammer.on('tap', function(event) { |
|
|
setTimeout(function() {
|
|
|
$('.overlay').hide();
|
|
|
}, 300);
|
|
|
e.srcEvent.stopPropagation();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//点击一级导航,弹出二级导航
|
|
|
$('.side-nav').on('touchstart', 'li', function () {
|
|
|
$sideNav.on('touchstart', 'li', function () {
|
|
|
if ($(this).find('.sub-nav').size() > 0) {
|
|
|
$('.sub-nav').removeClass('show');
|
|
|
$(this).find('.sub-nav').addClass('show');
|
...
|
...
|
@@ -114,13 +80,6 @@ $('.sub-nav').each(function () { |
|
|
});
|
|
|
});
|
|
|
|
|
|
//二级导航样式控制
|
|
|
$('.sub-nav').on('mouseenter', 'li', function () {
|
|
|
if ($(this).index() !== 0) {
|
|
|
$(this).addClass('current').siblings().removeClass('current');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//头部banner轮播
|
|
|
if ($('.banner-swiper').find('li').size() > 1) {
|
|
|
bannerSwiper = new Swiper('.banner-swiper', {
|
...
|
...
|
|