MCPcopy Create free account
hub / github.com/caseywebdev/react-list / getSizeOfItem

Method getSizeOfItem

src/react-list.js:428–450  ·  view source on GitHub ↗
(index)

Source from the content-addressed store, hash-verified

426 }
427
428 getSizeOfItem(index) {
429 const { cache, items } = this;
430 const { axis, itemSizeGetter, itemSizeEstimator, type } = this.props;
431 const { from, itemSize, size } = this.state;
432
433 // Try the static itemSize.
434 if (itemSize) return itemSize;
435
436 // Try the itemSizeGetter.
437 if (itemSizeGetter) return itemSizeGetter(index);
438
439 // Try the cache.
440 if (index in cache) return cache[index];
441
442 // Try the DOM.
443 if (type === 'simple' && index >= from && index < from + size && items) {
444 const itemEl = items.children[index - from];
445 if (itemEl) return itemEl[OFFSET_SIZE_KEYS[axis]];
446 }
447
448 // Try the itemSizeEstimator.
449 if (itemSizeEstimator) return itemSizeEstimator(index, cache);
450 }
451
452 scrollTo(index) {
453 if (index != null) this.setScroll(this.getSpaceBefore(index));

Callers 6

updateVariableFrameMethod · 0.95
getSpaceBeforeMethod · 0.95
scrollAroundMethod · 0.95
getVisibleRangeMethod · 0.95
react-list.jsFile · 0.80
index.jsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected