...
|
...
|
@@ -26,10 +26,27 @@ var $ = require('yoho.jquery'), |
|
|
} else {
|
|
|
this._createPage();
|
|
|
}
|
|
|
|
|
|
if (this.options.orient) {
|
|
|
this._createOrient();
|
|
|
}
|
|
|
this._slideShow();
|
|
|
this._bindEvent();
|
|
|
this._autoplay();
|
|
|
},
|
|
|
_createOrient: function() {
|
|
|
|
|
|
var orientHtml = '<div class="slide-switch">' +
|
|
|
'<a class="prev" href="javascript:;"><span class="iconfont"></span></a>' +
|
|
|
'<a class="next" href="javascript:;"><span class="iconfont"></span></a>' +
|
|
|
'</div>';
|
|
|
|
|
|
if (this.$element.find('.slide-switch').length > 0) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
this.$element.append(orientHtml);
|
|
|
},
|
|
|
_createPage: function() {
|
|
|
var pageHtml = '<div class="slide-pagination"><div class="slide-pagination-inner">' +
|
|
|
'<div class="slide-shade"></div><div class="slide-pagination-last">',
|
...
|
...
|
@@ -69,6 +86,12 @@ var $ = require('yoho.jquery'), |
|
|
}).on('mouseleave', function() {
|
|
|
that._autoplay();
|
|
|
});
|
|
|
|
|
|
this.$element.on('mouseenter', function() {
|
|
|
$(this).find('.slide-switch').addClass('show');
|
|
|
}).on('mouseleave', function() {
|
|
|
$(this).find('.slide-switch').removeClass('show');
|
|
|
});
|
|
|
},
|
|
|
_nextSlide: function() {
|
|
|
if (this.index === this.len - 1) {
|
...
|
...
|
@@ -89,12 +112,14 @@ var $ = require('yoho.jquery'), |
|
|
_slideShow: function() {
|
|
|
var $img = this.bigItem.eq(this.index).find('img.lazy');
|
|
|
|
|
|
//未加载图片的及时显示
|
|
|
if ($img.attr('src') !== $img.data('original')) {
|
|
|
lazyLoad($img.trigger('appear'));
|
|
|
}
|
|
|
if (this.len > 1) {
|
|
|
this.$element.find('.slide-switch').addClass('show');
|
|
|
lazyLoad($img, {
|
|
|
event: 'sporty'
|
|
|
});
|
|
|
$img.trigger('sporty');
|
|
|
}
|
|
|
|
|
|
this.smallItem.eq(this.index).addClass('focus').siblings().removeClass('focus');
|
|
|
this.bigItem.eq(this.index).fadeIn().siblings().fadeOut();
|
|
|
},
|
...
|
...
|
@@ -124,6 +149,7 @@ var $ = require('yoho.jquery'), |
|
|
$.fn.slider.Constructor = Slider;
|
|
|
$.fn.slider.defaults = {
|
|
|
time: 5000,
|
|
|
orient: true, //左右切换箭头的显示
|
|
|
pagination: null
|
|
|
};
|
|
|
})($); |
|
|
\ No newline at end of file |
...
|
...
|
|