/** @flow */
import React, { Component, PropTypes } from 'react'
import Immutable from 'immutable'
import { ContentBox, ContentBoxHeader, ContentBoxParagraph } from '../demo/ContentBox'
import { LabeledInput, InputRow } from '../demo/LabeledInput'
import AutoSizer from '../AutoSizer'
import Collection from './Collection'
import shallowCompare from 'react-addons-shallow-compare'
import styles from './Collection.example.css'
// Defines a pattern of sizes and positions for a range of 10 rotating cells
// These cells cover an area of 600 (wide) x 400 (tall)
const GUTTER_SIZE = 3
const CELL_WIDTH = 75
export default class CollectionExample extends Component {
static contextTypes = {
list: PropTypes.instanceOf(Immutable.List).isRequired
};
constructor (props, context) {
super(props, context)
this.state = {
cellCount: context.list.size,
columnCount: this._getColumnCount(context.list.size),
height: 300,
horizontalOverscanSize: 0,
scrollToCell: undefined,
showScrollingPlaceholder: false,
verticalOverscanSize: 0
}
this._columnYMap = []
this._cellRenderer = this._cellRenderer.bind(this)
this._cellSizeAndPositionGetter = this._cellSizeAndPositionGetter.bind(this)
this._noContentRenderer = this._noContentRenderer.bind(this)
this._onCellCountChange = this._onCellCountChange.bind(this)
this._onHeightChange = this._onHeightChange.bind(this)
this._onHorizontalOverscanSizeChange = this._onHorizontalOverscanSizeChange.bind(this)
this._onScrollToCellChange = this._onScrollToCellChange.bind(this)
this._onVerticalOverscanSizeChange = this._onVerticalOverscanSizeChange.bind(this)
}
render () {
const { cellCount, height, horizontalOverscanSize, scrollToCell, showScrollingPlaceholder, verticalOverscanSize } = this.state
return (
Grid, which renders checkerboard data, Collection can render arbitrarily positioned- even overlapping- data.