Coder Social home page Coder Social logo

react-native-waterfall's Introduction

react-native-waterfall-layout

基于react-native官方组件封装的瀑布流组件

Preview

iOS

iOS

Android

Android

Getting started

1.安装

$ npm i react-native-waterfall-layout --save

2.导入

import Waterfall from 'react-native-waterfall-layout';

Properties

Prop Default Type Description
columns 2 Number 瀑布流的列数
space 10 Number 瀑布流每列之间的间隔
renderIte null Function 用于自定义瀑布流中每一项的内容
keyExtractor null Function 为给定的item生成一个不重复的key。若不指定此函数,则默认抽取item.key作为key值。若item.key也不存在,则使用数组下标index
refresh true Boolean 是否启用下拉刷新
refreshing (done) =>{} Function 下拉刷新触发该函数,接收一个done函数用于结束刷新
refreshConf Object 下拉刷新参数,配置详见RefreshControl
infinite true Boolean 是否启用滚动加载
infiniting (done) => {} Function 滚动到列表底部触发该函数,接收参数同refreshing
hasMore true Boolean 设置为false滚动到列表底部后将不触发infiniting
renderInfinite Function 用于自定义滚动加载组件及样式,接收一个loading用于判断是否正在加载

Methods

addItems

添加Items到瀑布流中,其中Item的高度自动计算出来,将Item添加到最矮的列中,所以会导致Items依次渲染。

this.refs.waterfall.addItems([

    {name: 'Item1'}, 

    {name: 'Item2'}

])
addItemWithHeight

添加 items 到瀑布流组件中,item的高度也将自动确定,但需要在每个item对象的数据中添加height属性,该属性不是item渲染后的实际高度,而是作为item分配列的算法参考值。和addItems不一样的是,是批量渲染的

this.refs.waterfall.addItemsWithHeight([

      {name:"Item1", height: 210 },

      {name:"Item2", height: 150 }

]);
clear

清除瀑布流中的所有项

this.refs.waterfall.clear();

Example

点击Demo查看

react-native-waterfall's People

Contributors

junhaotong avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.