...
|
...
|
@@ -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,67 +31,28 @@ 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');
|
|
|
|
|
|
//设置boy高宽,页面不能上下滑动
|
|
|
$('body').css({
|
|
|
height: $(window).height(),
|
|
|
width: '100%',
|
|
|
overflow: 'hidden'
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// event.stopPropagation();
|
|
|
$mobileWrap.addClass('menu-open');
|
|
|
$overlay.show().css('opacity', 0.3);
|
|
|
$sideNav.addClass('on');
|
|
|
|
|
|
//设置boy高宽,页面不能上下滑动
|
|
|
$('body').css({
|
|
|
height: $(window).height(),
|
|
|
width: '100%',
|
|
|
overflow: 'hidden'
|
|
|
});
|
|
|
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'
|
...
|
...
|
@@ -96,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');
|
...
|
...
|
@@ -115,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', {
|
...
|
...
|
|