tinyjs-plugin-scroller
滚动插件
查看demo
http://tinyjs.net/plugins/tinyjs-plugin-scroller.html#demo
引用方法
-
推荐作为依赖使用
npm install tinyjs-plugin-scroller --save
-
也可以直接引用线上cdn地址,注意要使用最新的版本号,例如:
起步
首先当然是要引入,推荐NPM
方式,当然你也可以使用CDN
或下载独立版本,先从几个例子入手吧!
1、最简单的例子
我们通过dom来演示一下:
12345678910// 引用 Tiny.js 源码
;// 或者// import Scroller from 'tinyjs-plugin-scroller';var container = document;var scroller = {containerstyletransform = 'translateY('+ -top +'px)';}scrollingY: true;// 设置滚动的规模,参数依次是 clientWidth, clientHeight, contentWidth, contentHeightscroller;// 按下时的事件监听container;// 移动时的事件监听container;// 抬起时的事件监听container;// 移出屏幕/取消的事件监听container;
依赖
Tiny.js
: Link
API文档
http://tinyjs.net/plugins/tinyjs-plugin-scroller.html#docs