升级.net8暂存
This commit is contained in:
@ -3,15 +3,17 @@
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
layui.define('jquery', function(exports){
|
||||
layui.define(['jquery', 'lay'], function(exports){
|
||||
"use strict";
|
||||
|
||||
var $ = layui.$
|
||||
,hint = layui.hint()
|
||||
,device = layui.device()
|
||||
var $ = layui.$;
|
||||
var lay = layui.lay;
|
||||
|
||||
var hint = layui.hint();
|
||||
var device = layui.device();
|
||||
|
||||
//外部接口
|
||||
,carousel = {
|
||||
var carousel = {
|
||||
config: {} //全局配置项
|
||||
|
||||
//设置全局项
|
||||
@ -55,8 +57,22 @@ layui.define('jquery', function(exports){
|
||||
|
||||
//轮播渲染
|
||||
Class.prototype.render = function(){
|
||||
var that = this
|
||||
,options = that.config;
|
||||
var that = this;
|
||||
var options = that.config;
|
||||
|
||||
// 若 elem 非唯一,则拆分为多个实例
|
||||
var elem = $(options.elem);
|
||||
if(elem.length > 1){
|
||||
layui.each(elem, function(){
|
||||
carousel.render($.extend({}, options, {
|
||||
elem: this
|
||||
}));
|
||||
});
|
||||
return that;
|
||||
}
|
||||
|
||||
// 合并 lay-options 属性上的配置信息
|
||||
$.extend(options, lay.options(elem[0]));
|
||||
|
||||
options.elem = $(options.elem);
|
||||
if(!options.elem[0]) return;
|
||||
@ -184,7 +200,7 @@ layui.define('jquery', function(exports){
|
||||
//避免重复插入
|
||||
if(options.elem.find('.'+ELEM_ARROW)[0]){
|
||||
options.elem.find('.'+ELEM_ARROW).remove();
|
||||
};
|
||||
}
|
||||
options.elem.append(tplArrow);
|
||||
|
||||
//事件
|
||||
@ -194,6 +210,18 @@ layui.define('jquery', function(exports){
|
||||
that.slide(type);
|
||||
});
|
||||
};
|
||||
|
||||
// 跳转到特定下标
|
||||
Class.prototype.goto = function(index){
|
||||
var that = this;
|
||||
var options = that.config;
|
||||
|
||||
if(index > options.index){
|
||||
that.slide('add', index - options.index);
|
||||
} else if(index < options.index){
|
||||
that.slide('sub', options.index - index);
|
||||
}
|
||||
}
|
||||
|
||||
//指示器
|
||||
Class.prototype.indicator = function(){
|
||||
@ -217,22 +245,16 @@ layui.define('jquery', function(exports){
|
||||
//避免重复插入
|
||||
if(options.elem.find('.'+ELEM_IND)[0]){
|
||||
options.elem.find('.'+ELEM_IND).remove();
|
||||
};
|
||||
}
|
||||
options.elem.append(tplInd);
|
||||
|
||||
if(options.anim === 'updown'){
|
||||
tplInd.css('margin-top', -(tplInd.height()/2));
|
||||
}
|
||||
|
||||
//事件
|
||||
// 事件
|
||||
tplInd.find('li').on(options.trigger === 'hover' ? 'mouseover' : options.trigger, function(){
|
||||
var othis = $(this)
|
||||
,index = othis.index();
|
||||
if(index > options.index){
|
||||
that.slide('add', index - options.index);
|
||||
} else if(index < options.index){
|
||||
that.slide('sub', options.index - index);
|
||||
}
|
||||
that.goto($(this).index());
|
||||
});
|
||||
};
|
||||
|
||||
@ -261,7 +283,7 @@ layui.define('jquery', function(exports){
|
||||
elemItem.eq(thisIndex).addClass(ELEM_LEFT);
|
||||
elemItem.eq(options.index).addClass(ELEM_LEFT);
|
||||
}, 50);
|
||||
};
|
||||
}
|
||||
|
||||
//移除过度类
|
||||
setTimeout(function(){
|
||||
@ -308,8 +330,7 @@ layui.define('jquery', function(exports){
|
||||
|
||||
//核心入口
|
||||
carousel.render = function(options){
|
||||
var inst = new Class(options);
|
||||
return inst;
|
||||
return new Class(options);
|
||||
};
|
||||
|
||||
exports(MOD_NAME, carousel);
|
||||
|
Reference in New Issue
Block a user