this.state = {
trackData: [
0: '<span 1 />'
1: '<span 2 />'
2: '<span 3 />'
3: '<span 4 />'
4: '<span 5 />'
5: '<span 6 />'
6: '<span 7 />'
7: '<span 8 />'
]
}
createTrack() {
const { trackData } = this.state;
const rows = [];
for (let rowIdx = 0; rowIdx < trackData.length; rowIdx++) {
if (rowIdx % 6 === 0) {
rows.push(<div className='row__item' key={rowIdx}>{ this.createTrackCols(rowIdx) }</div>);
}
}
return rows;
}
createTrackCols(rowIdx) {
const { trackData } = this.state;
const cols = [];
for (let colIdx = rowIdx; colIdx < trackData.length; colIdx++) {
cols.push(
<div className='col-2' key={colIdx}>
<Scrollbar
speed={1}
damping={0.1}
overscrollDamping={0.1}
thumbMinSize={20}
renderByPixels
continuousScrolling={'auto'}
overscrollEffect={'bounce'}
id='scroller-col'
ref={c => this.scrollbar = c}
syncCallbacks
>
content
</Scrollbar>
</div>
);
}
return cols;
}
const cols = [];
// console.log(rowIdx);
for (let colIdx = rowIdx; colIdx < trackData.length; colIdx++) {
const sep = colIdx % 6;
if ((sep - colIdx + rowIdx) === 0) {
cols.push(
<div className={this.setColClassName(colIdx)} key={colIdx}>
<Scrollbar
speed={1}
damping={0.1}
overscrollDamping={0.1}
thumbMinSize={20}
renderByPixels
continuousScrolling={'auto'}
overscrollEffect={'bounce'}
id='scroller-col'
ref={c => this.scrollbar = c}
syncCallbacks
>
{ this.renderColItems(colIdx) }
</Scrollbar>
</div>
);
}
}
return cols;
if (rowIdx % 6 === 0)
это "каждый шестой" а не "первые шесть"if (rowIdx < 6)
let firstSix = arr.slice(0, 6)