()
| 239 | } |
| 240 | |
| 241 | getItemSizeAndItemsPerRow() { |
| 242 | const { axis, useStaticSize } = this.props; |
| 243 | let { itemSize, itemsPerRow } = this.state; |
| 244 | if (useStaticSize && itemSize && itemsPerRow) { |
| 245 | return { itemSize, itemsPerRow }; |
| 246 | } |
| 247 | |
| 248 | const itemEls = this.items.children; |
| 249 | if (!itemEls.length) return {}; |
| 250 | |
| 251 | const firstEl = itemEls[0]; |
| 252 | |
| 253 | // Firefox has a problem where it will return a *slightly* (less than |
| 254 | // thousandths of a pixel) different size for the same element between |
| 255 | // renders. This can cause an infinite render loop, so only change the |
| 256 | // itemSize when it is significantly different. |
| 257 | const firstElSize = firstEl[OFFSET_SIZE_KEYS[axis]]; |
| 258 | const delta = Math.abs(firstElSize - itemSize); |
| 259 | if (isNaN(delta) || delta >= 1) itemSize = firstElSize; |
| 260 | |
| 261 | if (!itemSize) return {}; |
| 262 | |
| 263 | const startKey = OFFSET_START_KEYS[axis]; |
| 264 | const firstStart = firstEl[startKey]; |
| 265 | itemsPerRow = 1; |
| 266 | for ( |
| 267 | let item = itemEls[itemsPerRow]; |
| 268 | item && item[startKey] === firstStart; |
| 269 | item = itemEls[itemsPerRow] |
| 270 | ) { |
| 271 | ++itemsPerRow; |
| 272 | } |
| 273 | |
| 274 | return { itemSize, itemsPerRow }; |
| 275 | } |
| 276 | |
| 277 | clearSizeCache() { |
| 278 | this.cachedScrollPosition = null; |
no outgoing calls
no test coverage detected