react-measured-grid API | MeasuredGrid | ScrollPosition | PositionTracker | demos | repo |
The PositionTracker
class records measured sizes of items,
and provides various estimates of sizes of items.
With modest efficiency it also provides estimates of the total scrolling offset
of an item within the entire grid.
The sizes that are tracked can be either the heights of rows or the widths of columns. An item is identified by its zero-based index.
The following are methods that are available for use:
PositionTracker(itemCount, unmeasuredSize, lowSize, maxBranches, maxLeafItems)
itemCount
is the number of items being tracked
(the number of rows or columns in the grid).
The default value is 0.unMeasuredSize
is the number of pixels used
to estimate the size of unmeasured items
when calculating the total scroll offset of an item
or when calculating the total size of the grid.
The default value is 18.lowSize
is the number of pixels used to estimate
how much space an unmeasured item will take up when
determining how many rows should be put in the DOM
to fill the view window.
It can also be a function that maps an item index
to a number that is such an estimate.
The default value is 12.PositionTracker
builds a tree structure over its recorded size measurements,
in order to more efficiently calculate total scrolling offsets for an item.
The default values are usually satisfactory for most use cases.
maxBranches
is the maximum number of branches from a node in all but the
bottom level of the tree.
The default value is 32.maxLeafItems
is the maximum number of items recorded in a node
that is at the bottom level of the tree.
The default value is 32.The rest of the methods are instance methods.
clearAllItems()
clearItemSize(index)
getContainingIndex(offset)
offset
is a total scrolling offset.getItemCount()
getItemLowSize(index)
getItemMeasuredSize(index)
getItemSize(index)
getItemStats(index)
getLowSize()
getMaxBranches()
getMaxLeafItems()
getTotalSize()
getUnmeasuredSize()
setItemCount(itemCount)
setItemSize(index, size)
setLowSize(lowSize)
lowSize
can be a number or a function that maps an index to a lowSize estimate.
The default value is 30.setUnmeasuredSize(index, size)