QSMP.Web/Content/layui/lay/modules/carousel.js

(开头部分) 8KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

/**

 @Name:layui.carousel 轮播模块
 @Author:贤心
 @License:MIT
    
 */
 
layui.define('jquery', function(exports){
  "use strict";
  
  var $ = layui.$
  ,hint = layui.hint()
  ,device = layui.device()

  //外部接口
  ,carousel = {
    config: {} //全局配置项

    //设置全局项
    ,set: function(options){
      var that = this;
      that.config = $.extend({}, that.config, options);
      return that;
    }
    
    //事件监听
    ,on: function(events, callback){
      return layui.onevent.call(this, MOD_NAME, events, callback);
    }
  }
  
  //字符常量
  ,MOD_NAME = 'carousel', ELEM = '.layui-carousel', THIS = 'layui-this', SHOW = 'layui-show', HIDE = 'layui-hide', DISABLED = 'layui-disabled'
  
  ,ELEM_ITEM = '>*[carousel-item]>*', ELEM_LEFT = 'layui-carousel-left', ELEM_RIGHT = 'layui-carousel-right', ELEM_PREV = 'layui-carousel-prev', ELEM_NEXT = 'layui-carousel-next', ELEM_ARROW = 'layui-carousel-arrow', ELEM_IND = 'layui-carousel-ind'
  
  //构造器
  ,Class = function(options){
    var that = this;
    that.config = $.extend({}, that.config, carousel.config, options);
    that.render();
  };
  
  //默认配置
  Class.prototype.config = {
    width: '600px'
    ,height: '280px'
    ,full: false //是否全屏
    ,arrow: 'hover' //切换箭头默认显示状态:hover/always/none
    ,indicator: 'inside' //指示器位置:inside/outside/none
    ,autoplay: true //是否自动切换
    ,interval: 3000 //自动切换的时间间隔,不能低于800ms
    ,anim: '' //动画类型:default/updown/fade
    ,trigger: 'click' //指示器的触发方式:click/hover
    ,index: 0 //初始开始的索引
  };
  
  //轮播渲染
  Class.prototype.render = function(){
后面还有 255 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。