一款移动端微型 swiper 插件,小而美,无依赖.

mSwiper.js

downloads license

View README in Englishgit

项目地址github

移动端微型 swiper 插件,小而美,无依赖.npm

前言

mSwiper 相对于其余的swiper插件而言,最大的优点就是 ,压缩后仅 1.2k ,能知足部分开发需求。插件的开发采用 组合使用构造函数模式和原型模式,经过 Gulp 构建,感兴趣的能够阅读源码?。欢迎 star ?gulp

如有问题,请提issuebash

效果演示

在线浏览Demo请戳这里函数

手机浏览请扫描下方二维码

在线浏览

开发

# 克隆本仓库
git clone https://github.com/JohnsenZhou/mSwiper.js.git

# 进入仓库目录
cd mSwiper.js

# 安装依赖
npm install

# 启动项目,本地浏览地址 => localhost:8080
gulp

# 打包压缩
gulp build

安装

前往 release 下载所需版本。ui

使用

<ul id="selector">
  <li>
    <img src="./img/1.jpg">
  </li>
  <li>
    <img src="./img/2.jpg">
  </li>
  <li>
    <img src="./img/3.jpg">
  </li>
  <li>
    <img src="./img/4.jpg">
  </li>
  <li>
    <img src="./img/5.jpg">
  </li>
</ul>
<script src="../src/mSwiper.js"></script>
<script>
  var options = {
    selector: "#selector",  // 节点选择
    isAutoPlay: true,       // 是否自动播放
    autoPlayTime: 3000,     // 设置自动播放时间
  }
  var mSwiper = new mSwiper(options);
</script>

mSwiper 同时也支持 AMD 规范,你能够经过 require.js 进行加载使用:spa

require(['mSwiper'], function(mSwiper) {
  var options = {
    selector: "#selector",  // 节点选择
    isAutoPlay: true,       // 是否自动播放
    autoPlayTime: 3000,     // 设置自动播放时间
  }
  var mSwiper = new mSwiper(options);
})

Api

new mSwiper(options)

options 具体参数:插件

参数 类型 默认值 功能描述
selector string #selector 容器选择器
isAutoPlay bool false 是否自动播放
isManual bool false 是否支持手指滑动
autoPlayTime number 5000 自动播放间隔时间
goDirection string left 自动播放方向(left&right)

License

MIT Licensecode

相关文章
相关标签/搜索