@@ -5,10 +5,10 @@ import { ContentBox, ContentBoxHeader, ContentBoxParagraph } from '../demo/Conte
55import AutoSizer from '../AutoSizer'
66import Grid from '../Grid'
77import ScrollSync from './ScrollSync'
8- import VirtualScroll from '../VirtualScroll'
98import shouldPureComponentUpdate from 'react-pure-render/function'
109import cn from 'classnames'
1110import styles from './ScrollSync.example.css'
11+ import scrollbarSize from 'dom-helpers/util/scrollbarSize'
1212
1313const LEFT_COLOR_FROM = hexToRgb ( '#471061' )
1414const LEFT_COLOR_TO = hexToRgb ( '#BC3959' )
@@ -83,21 +83,47 @@ export default class GridExample extends Component {
8383 const middleColor = `#ffffff`
8484
8585 return (
86- < div className = { styles . GridRow } >
86+ < div className = { styles . GridRow } >
8787 < div
8888 className = { styles . LeftSideGridContainer }
8989 style = { {
90- backgroundColor : `rgb(${ leftBackgroundColor . r } ,${ leftBackgroundColor . g } ,${ leftBackgroundColor . b } )` ,
90+ position : 'absolute' ,
91+ left : 0 ,
92+ top : 0 ,
9193 color : leftColor ,
92- marginTop : rowHeight
94+ backgroundColor : `rgb( ${ topBackgroundColor . r } , ${ topBackgroundColor . g } , ${ topBackgroundColor . b } )`
9395 } }
9496 >
95- < VirtualScroll
96- className = { styles . LeftSideGrid }
97- height = { height }
97+ < Grid
98+ renderCell = { this . _renderLeftHeaderCell }
99+ className = { styles . HeaderGrid }
100+ width = { columnWidth }
101+ height = { rowHeight }
102+ rowHeight = { rowHeight }
103+ columnWidth = { columnWidth }
104+ rowsCount = { 1 }
105+ columnsCount = { 1 }
106+ />
107+ </ div >
108+ < div
109+ className = { styles . LeftSideGridContainer }
110+ style = { {
111+ position : 'absolute' ,
112+ left : 0 ,
113+ top : rowHeight ,
114+ color : leftColor ,
115+ backgroundColor : `rgb(${ leftBackgroundColor . r } ,${ leftBackgroundColor . g } ,${ leftBackgroundColor . b } )`
116+ } }
117+ >
118+ < Grid
119+ overscanColumnsCount = { overscanColumnsCount }
98120 overscanRowsCount = { overscanRowsCount }
121+ renderCell = { this . _renderLeftSideCell }
122+ columnWidth = { columnWidth }
123+ columnsCount = { 1 }
124+ className = { styles . LeftSideGrid }
125+ height = { height - scrollbarSize ( ) }
99126 rowHeight = { rowHeight }
100- rowRenderer = { this . _renderLeftSideCell }
101127 rowsCount = { rowsCount }
102128 scrollTop = { scrollTop }
103129 width = { columnWidth }
@@ -111,7 +137,7 @@ export default class GridExample extends Component {
111137 backgroundColor : `rgb(${ topBackgroundColor . r } ,${ topBackgroundColor . g } ,${ topBackgroundColor . b } )` ,
112138 color : topColor ,
113139 height : rowHeight ,
114- width
140+ width : width - scrollbarSize ( )
115141 } } >
116142 < Grid
117143 className = { styles . HeaderGrid }
@@ -123,7 +149,7 @@ export default class GridExample extends Component {
123149 rowHeight = { rowHeight }
124150 rowsCount = { 1 }
125151 scrollLeft = { scrollLeft }
126- width = { width }
152+ width = { width - scrollbarSize ( ) }
127153 />
128154 </ div >
129155 < div
@@ -161,32 +187,38 @@ export default class GridExample extends Component {
161187 }
162188
163189 _renderBodyCell ( { columnIndex, rowIndex } ) {
164- const rowClass = rowIndex % 2 === 0
165- ? columnIndex % 2 === 0 ? styles . evenRow : styles . oddRow
166- : columnIndex % 2 !== 0 ? styles . evenRow : styles . oddRow
167- const classNames = cn ( rowClass , styles . cell )
190+ if ( columnIndex < 1 ) {
191+ return
192+ }
168193
169- return (
170- < div className = { classNames } >
171- { `R${ rowIndex } , C${ columnIndex } ` }
172- </ div >
173- )
194+ return this . _renderLeftSideCell ( { columnIndex, rowIndex } )
174195 }
175196
176197 _renderHeaderCell ( { columnIndex, rowIndex } ) {
198+ if ( columnIndex < 1 ) {
199+ return
200+ }
201+
202+ return this . _renderLeftHeaderCell ( { columnIndex, rowIndex } )
203+ }
204+
205+ _renderLeftHeaderCell ( { columnIndex, rowIndex } ) {
177206 return (
178207 < div className = { styles . headerCell } >
179208 { `C${ columnIndex } ` }
180209 </ div >
181210 )
182211 }
183212
184- _renderLeftSideCell ( rowIndex ) {
185- const classNames = cn ( styles . cell , styles . leftCell )
213+ _renderLeftSideCell ( { columnIndex, rowIndex } ) {
214+ const rowClass = rowIndex % 2 === 0
215+ ? columnIndex % 2 === 0 ? styles . evenRow : styles . oddRow
216+ : columnIndex % 2 !== 0 ? styles . evenRow : styles . oddRow
217+ const classNames = cn ( rowClass , styles . cell )
186218
187219 return (
188220 < div className = { classNames } >
189- { `R${ rowIndex } ` }
221+ { `R${ rowIndex } , C ${ columnIndex } ` }
190222 </ div >
191223 )
192224 }
0 commit comments