GithubHelp home page GithubHelp logo

cht8687 / react-listview-sticky-header Goto Github PK

View Code? Open in Web Editor NEW
80.0 5.0 13.0 3.01 MB

react listview with sticky section header

JavaScript 97.28% CSS 2.72%
react react-component reactjs sticky-headers

react-listview-sticky-header's Introduction

Join the chat at https://gitter.im/cht8687/react-listview-sticky-header

React listview with sticky header

Circle CI NPM Version Coverage Status Build Status Downloads Dependency Status License

React Listview sticky header

Installation

npm

$ npm install --save react-listview-sticky-header

Since React is peer dependency, you need to install it manually if you haven't.

Demo

http://cht8687.github.io/react-listview-sticky-header/example/

Usage

<ReactListView 
    data={data} 
    headerAttName="headerName"
    itemsAttName="items" 
    styles={styles}
/>

Options

data: PropTypes.array.isRequired

const DATALIST = [
{
  headerName : "ListA",
    items : [{
      title : "items1"
    }, {
      title : "items2"
    }]
},
{
  headerName : "ListB",
    items : [{
      title : "items1"
    }, {
      title : "items2"
    }]
}
];

headerAttName: PropTypes.string.isRequired

variable name of header in your data object. In above example, it's headerName.

itemsAttName: PropTypes.string.isRequired

variable name which hold items data in your data object. In above example, it's items.

styles: PropTypes.object.isRequired

let styles = {
  outerDiv: {
    height: '420px',
    overflowY: 'auto',
    outline: '#b9ceb6 dashed 1px',
    width: '383px'
  },

  ul: {
    margin: '0px',
    listStyleType: 'none',
    padding: '0px'
  },

  fixedPosition: {
    position: 'fixed',
    width: '383px',
    top: '0px'
  },

  listHeader: {
    width: '383px',
    height: '27px',
    background: '#94D6CF',
    color: 'white'
  },

  listItems: {
    color: '#a9adab'
  }
}

outerDiv, ul, fixedPosition, listHeader, listItems are required, you can modify the CSS to meet your needs.

Development

$ git clone [email protected]:cht8687/react-listview-sticky-header.git
$ cd react-listview-sticky-header
$ npm install
$ webpack-dev-server

Then

open http://localhost:8080/webpack-dev-server/

License

MIT

js-standard-style

react-listview-sticky-header's People

Contributors

cht8687 avatar dependabot[bot] avatar gitter-badger avatar haotian-infotrack avatar katerberg avatar stevemao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

react-listview-sticky-header's Issues

objects are not valid as react child

const MyAccountfunc= async ({navigation})=>{
let user = await AsyncStorage.getItem('user'); //it is showing error here
alert(user); //my user contains one mail
if(user==null)
{
alert('Login first')
navigation.navigate('Login')

}
else{
alert('done')
navigation.navigate('MyAccount')

}
return null
}

const DrawerNavigation = createDrawerNavigator(

{

  "Home": App,
  "My Account": MyAccountfunc,
  "Order History": OrderHistory,
  "About us": Aboutus,
  "Contact us": Contactus,
  "Logout": LogoutFunc

},
{
initialRouteName: "Home",
contentOptions: {
activeTintColor: "red"
}
}
);

export default createAppContainer(DrawerNavigation);

Need rewrite onScroll() logic

At the moment, if data array is long enough, the headers are not sticking to the correct position.
need to be fixed.

Objects are not valid as a React child (found: object with keys {title})

From the example, (with react 0.14)

Invariant Violation: Objects are not valid as a React child (found: object with keys {title}). If you meant to render a collection of children, use an array instead or wrap the object using createFragment(object) from the React add-ons. Check the render method of ListItem.

flickering effect when scrolling down

when scrolling down the list as soon as there is a new sticky title there is an annoying flickering effect as the new sticky title becomes active. also the first item of the new group is hidden beneath the new sticky title
screen shot 2015-11-13 at 09 58 17

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.