Authored by hongweigao

Merge branch 'feature/newCustomer' into release/5.2

... ... @@ -70,6 +70,6 @@ if (homePage === 'boys') {
}
$('.new-user-proList').slider2({
autoplay: false,
shownum: 5
shownum: 5,
isCircle: false
});
... ...
... ... @@ -19,12 +19,16 @@
index: 0,
shownum: 3,
autoplay: false,
delaytime: 3000
delaytime: 3000,
isCircle: true
};
var shownum = options.shownum ? options.shownum : // eslint-disable-line
$.fn.slider2.defaults.shownum;
var isCircle = 'isCircle' in options ? options.isCircle : // eslint-disable-line
$.fn.slider2.defaults.isCircle;
function autoplayrecycle(index, limit, toright) {
window.setTimeout(autoplay, $.fn.slider2.defaults.delaytime, index, limit, toright);// eslint-disable-line
}
... ... @@ -66,6 +70,45 @@
}
/**
* 不轮播左右切换
* @param $items 图片dom
* @param shownum 展示张数
* @param direction 0=左箭头, 1=右箭头
* @param $switch 按钮
*/
function changeMarLeft(wItem, num, direction, $arrow) {
// 处理双击问题
var disableSwitch = $arrow.data('disable') ? true : false;
var offersetleft = num * wItem;
var w = parseInt($imglist.css('width'), 10);
var ml = $imglist.css('margin-left') === '0px' ? 0 : parseInt($imglist.css('margin-left'), 10);
var gap = ml + offersetleft > wItem ? 0 : ml + offersetleft;
var mo = direction === 0 ? gap : ml - offersetleft;
var flag = direction === 0 ? ml < 0 : (w - (-ml) - offersetleft) >= wItem;
if (disableSwitch) {
return;
}
$prevswitch.data('disable', true);
$nextswitch.data('disable', true);
if (flag) {
$imglist
.animate({
'margin-left': mo + 'px'
}, 'slow', function() {
$prevswitch.data('disable', false);
$nextswitch.data('disable', false);
});
} else {
$prevswitch.data('disable', false);
$nextswitch.data('disable', false);
}
}
function _slideShow() {
var $imgLazyList = $imglist.find('img.lazy'),
i = 0,
... ... @@ -110,18 +153,24 @@
_obj = null;
e.preventDefault();
changePic(shownum, _width, function() {
for (i = 0; i < shownum; i++) {
_obj = bannerarr.shift();
$imglist.append(_obj.outerHTML);
bannerarr.push(_obj);
$imglist.find('.img-item').first().remove();
}
$imglist.css({
'margin-left': '0'
if (isCircle) {
// 循环播放
changePic(shownum, _width, function() {
for (i = 0; i < shownum; i++) {
_obj = bannerarr.shift();
$imglist.append(_obj.outerHTML);
bannerarr.push(_obj);
$imglist.find('.img-item').first().remove();
}
$imglist.css({
'margin-left': '0'
});
});
});
} else {
changeMarLeft($banneritems.outerWidth() + mr, shownum, 1, $nextswitch);
}
});
$prevswitch.on('click', function(e) {
... ... @@ -130,18 +179,22 @@
offersetleft = '';
e.preventDefault();
for (i = 0; i < shownum; i++) {
_obj = bannerarr.pop();
if (isCircle) {
for (i = 0; i < shownum; i++) {
_obj = bannerarr.pop();
$imglist.prepend(_obj.outerHTML);
bannerarr.unshift(_obj);
$imglist.find('.img-item').last().remove();
$imglist.prepend(_obj.outerHTML);
bannerarr.unshift(_obj);
$imglist.find('.img-item').last().remove();
}
offersetleft = shownum * _width;
$imglist.css({
'margin-left': -offersetleft + 'px'
});
changePic(0, _width);
} else {
changeMarLeft($banneritems.outerWidth() + mr, shownum, 0, $prevswitch);
}
offersetleft = shownum * _width;
$imglist.css({
'margin-left': -offersetleft + 'px'
});
changePic(0, _width);
});
if (opts.autoplay === true) {
// autoplayrecycle(opts.index, _size, true);
... ...