|
|
var $ = require('yoho-jquery'),
|
|
|
IScroll = require('yoho-iscroll'),
|
|
|
lazyLoad = require('yoho-jquery-lazyload');
|
|
|
IScroll = require('yoho-iscroll');
|
|
|
|
|
|
lazyLoad($('img.lazy'));
|
|
|
var defaultOpt = {
|
|
|
navClass: '.outlet-nav'
|
|
|
};
|
|
|
|
|
|
// nav 滚动
|
|
|
function initNavScroll() {
|
|
|
var $navBox = $('.outlet-nav'),
|
|
|
$lis = $navBox.find('li'),
|
|
|
function initNavScroll(opt) {
|
|
|
var $navBox,
|
|
|
// $lis,
|
|
|
iScroll;
|
|
|
|
|
|
$.extend(opt || {}, defaultOpt);
|
|
|
|
|
|
$navBox = $(opt.navClass);
|
|
|
// $lis = $navBox.find('li');
|
|
|
|
|
|
function scroll(ele) {
|
|
|
var offset;
|
|
|
|
...
|
...
|
@@ -21,20 +27,23 @@ function initNavScroll() { |
|
|
}, 1);
|
|
|
}
|
|
|
|
|
|
iScroll = new IScroll($navBox[0], {
|
|
|
scrollX: true,
|
|
|
scrollY: false
|
|
|
$.each($navBox, function(index) {
|
|
|
iScroll = new IScroll($navBox[index], {
|
|
|
scrollX: true,
|
|
|
scrollY: false
|
|
|
});
|
|
|
});
|
|
|
$navBox.on('click', 'li', function() {
|
|
|
var $this = $(this); // eslint-disable-line
|
|
|
var i = $this.index();
|
|
|
|
|
|
$lis.eq(i).addClass('active').siblings().removeClass('active');
|
|
|
scroll($this[0]);
|
|
|
});
|
|
|
// $navBox.on('click', 'li', function() {
|
|
|
// var $this = $(this); // eslint-disable-line
|
|
|
// var i = $this.index();
|
|
|
|
|
|
// $lis.eq(i).addClass('active').siblings().removeClass('active');
|
|
|
// scroll($this[0]);
|
|
|
// });
|
|
|
|
|
|
scroll($navBox.find('.active')[0]);
|
|
|
}
|
|
|
|
|
|
initNavScroll();
|
|
|
module.exports = initNavScroll;
|
|
|
|
...
|
...
|
|