img-brand.js
772 Bytes
var $ = require('yoho-jquery');
window.jQuery = $;
require('yoho-slider');
exports.init = function(selector) {
var $imgBrand = $(selector);
var slider = $imgBrand.unslider({
autoplay: true,
delay: 3000,
arrows: {
},
nav: false,
animate: 'fade'
});
var imgBrandNum = $imgBrand.find('li').length;
var rows = imgBrandNum / 3;
if (!($imgBrand.find('li').length % 3)) {
rows -= 1;
}
$imgBrand.find('li:nth-child(3n)').css('margin-right', 0);
slider.on('unslider.change', function(event, index) {
if (index > rows) {
slider.unslider('animate:' + imgBrandNum);
slider.unslider('animate:first');
}
});
// TODO: 手动点击左右
};