()
| 489 | } |
| 490 | |
| 491 | render() { |
| 492 | const { axis, getListStyle, length, type, useTranslate3d } = this.props; |
| 493 | const { from, itemsPerRow } = this.state; |
| 494 | |
| 495 | const items = this.renderItems(); |
| 496 | if (type === 'simple') return items; |
| 497 | |
| 498 | const style = { position: 'relative' }; |
| 499 | const cache = {}; |
| 500 | const bottom = Math.ceil(length / itemsPerRow) * itemsPerRow; |
| 501 | const size = this.getSpaceBefore(bottom, cache); |
| 502 | if (size) { |
| 503 | style[SIZE_KEYS[axis]] = size; |
| 504 | if (axis === 'x') style.overflowX = 'hidden'; |
| 505 | } |
| 506 | const offset = this.getSpaceBefore(from, cache); |
| 507 | const x = axis === 'x' ? offset : 0; |
| 508 | const y = axis === 'y' ? offset : 0; |
| 509 | const transform = useTranslate3d |
| 510 | ? `translate3d(${x}px, ${y}px, 0)` |
| 511 | : `translate(${x}px, ${y}px)`; |
| 512 | const listStyle = getListStyle |
| 513 | ? getListStyle({ x, y }) |
| 514 | : { |
| 515 | msTransform: transform, |
| 516 | WebkitTransform: transform, |
| 517 | transform |
| 518 | }; |
| 519 | return ( |
| 520 | <div style={style} ref={c => (this.el = c)}> |
| 521 | <div style={listStyle}>{items}</div> |
| 522 | </div> |
| 523 | ); |
| 524 | } |
| 525 | } |
no test coverage detected