1.0.4 • Published 8 years ago

ray-rn-collapse v1.0.4

Weekly downloads
2
License
MIT
Repository
-
Last release
8 years ago

ray-rn-collapse

author

ilex.h

Install

npm i --save ray-rn-collapse

Usage

basic

import React, { Component } from 'react';
import Collapse from 'ray-rn-collapse';

// easing: linear、easeInQuad、easeOutQuad、easeInOutQuad、easeInCubic、easeOutCubic...

const datas = [ 0, 1, 2, 3, 4, 5 ];

class BasicDemo extends Component {

  constructor(props) {
    super(props);
    const ds = new ListView.DataSource({ rowHasChanged: (r1, r2) => r1 !== r2 });
    this.state = {
      dataSource: ds.cloneWithRows(datas)
    };
  }

  _renderRow() {
    const header = (
      <View style={...}>
        <Text>展开</Text>
      </View>
    );

    const content = (
      <View style={...}>
        <Text>内容区域</Text>
      </View>
    );

    return (
      <Collapse
        header={header}
        content={content}
        easing="easeInOutQuad"
      />
    );
  }

  render() {
    return (
      <ListView
        dataSource={this.state.dataSource}
        renderRow={this._renderRow}
      />
    );
  }
}

Props

The following props can be used to modify the Accordion's style and/or behaviour:

PropTypeOpt/RequiredDefaultNote
activeOpacitynumber可选1active透明度 TouchableHighlight.
animationDurationnumber可选300动画持续时间
contentnode|element可选-面板内容
contentWrapperStyleobject可选-面板内容外层view样式
emptyContentnode|element!string可选Empty content默认空数据
easingstring可选linear缓动函数.
expandedboolean可选false是否展开(初始时默认展开则设置为true)
disabledboolean可选false禁用展开
showPressAnimboolean可选true点击展开时是否显示视觉反馈
headernode|element必填-面板头内容
onPressfunction可选-press事件.
underlayColorstring可选#000按下颜色 TouchableHighlight.
styleobject可选{}The styles you want to set on the accordion element.

Methods

The following methods can be used to open and close the collapse panel:

MethodParametersNote
open-Open the collapse.
close-Close the collapse.
toggle-Toggle the collapse.
<Collapse
  ref={coll => this.coll = coll}
  header={header}
  content={content}
  easing="easeInOutQuad"
/>

this.coll.open();
this.coll.close();
this.coll.toggle();

License

MIT

1.0.4

8 years ago

1.0.2

8 years ago

1.0.3

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago