anima-scroller

2.0.0 • Public • Published

anima-scroller


更好的滚动选择组件,主要逻辑来自 Zynga Scroller,支持Android 4.1+,iOS 6+。

安装

$ npm install anima-scroller --save

截图

Screenshot

使用方法

var Scroller = require('anima-scroller');
 
new Scroller('#id', {
  data : [
    {name : '', value : 0},
    {name : '', value : 1}
  ],
  defaultValue : 0,
  onSelect : function(value) {
    console.log(value);
  }
});

构造函数

Scroller(container [, options])

container为要添加的元素,可以是CSS3选择器或DOM元素。options请参考以下配置说明。

配置说明

template String

设置模板,覆盖的时候不要缺少 data-role ,默认模板请查看源码。

data Array|Object

数据列表,支持数组和key-value形式。

// 数组形式
new Scroller('#id', {
  data : ['', '']
});
 
// key-value形式
new Scroller('#id', {
  data : [
    {name : '', value : 0},
    {name : '', value : 1}
  ]
});

defaultValue String|Number

默认值,初始化组件时默认选中。

onSelect(value) Function

选中后执行的回调函数,value为选中的值。

itemClass String

数据项元素的class名称,默认值为 scroller-item

实例方法

selectByIndex(index [, animate])

通过索引选中一项,animate为false时无动画效果。

select(value [, animate])

通过值选中一项,animate为false时无动画效果。

scrollTo(top [, animate])

通过像素选中,animate为false时无动画效果。

destroy()

销毁控件,从DOM中移除。

Readme

Keywords

none

Package Sidebar

Install

npm i anima-scroller

Weekly Downloads

6

Version

2.0.0

License

none

Last publish

Collaborators

  • jaredleechn
  • smbey0nd
  • yuanfei.gyf