virtual-scroller 1.12.0 → 1.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +74 -9
- package/bundle/virtual-scroller-dom.js +1 -1
- package/bundle/virtual-scroller-dom.js.map +1 -1
- package/bundle/virtual-scroller-react.js +1 -1
- package/bundle/virtual-scroller-react.js.map +1 -1
- package/bundle/virtual-scroller.js +1 -1
- package/bundle/virtual-scroller.js.map +1 -1
- package/commonjs/ItemHeights.js +1 -1
- package/commonjs/ItemHeights.js.map +1 -1
- package/commonjs/VirtualScroller.onRender.js +1 -1
- package/commonjs/VirtualScroller.onRender.js.map +1 -1
- package/commonjs/getVerticalSpacing.js +5 -2
- package/commonjs/getVerticalSpacing.js.map +1 -1
- package/modules/ItemHeights.js +1 -1
- package/modules/ItemHeights.js.map +1 -1
- package/modules/VirtualScroller.onRender.js +1 -1
- package/modules/VirtualScroller.onRender.js.map +1 -1
- package/modules/getVerticalSpacing.js +5 -2
- package/modules/getVerticalSpacing.js.map +1 -1
- package/package.json +1 -1
- package/source/ItemHeights.js +1 -1
- package/source/VirtualScroller.onRender.js +1 -1
- package/source/getVerticalSpacing.js +5 -2
package/source/ItemHeights.js
CHANGED
|
@@ -169,7 +169,7 @@ export default class ItemHeights {
|
|
|
169
169
|
const previousHeight = this._get(i)
|
|
170
170
|
const height = this._measureItemHeight(i, firstShownItemIndex)
|
|
171
171
|
if (previousHeight !== height) {
|
|
172
|
-
warn('Item index', i, 'height changed unexpectedly: it was', previousHeight, 'before, but now it is', height, '.
|
|
172
|
+
warn('Item index', i, 'height changed unexpectedly: it was', previousHeight, 'before, but now it is', height, '. Whenever an item\'s height changes for whatever reason, a developer must call `onItemHeightDidChange(i)` right after that change. If you are calling `onItemHeightDidChange(i)` correctly, then there\'re several other possible causes. For example, perhaps you forgot to persist the item\'s "state" by calling `setItemState(i, newState)` when that "state" did change, and so the item\'s "state" got lost when the item element was unmounted, which resulted in a different item height when the item was shown again with no previous "state". Or perhaps you\'re running your application in "devleopment" mode and `VirtualScroller` has initially rendered the list before your CSS styles or custom fonts have loaded, resulting in different item height measurements "before" and "after" the page has fully loaded.')
|
|
173
173
|
// Update the item's height as an attempt to fix things.
|
|
174
174
|
this._set(i, height)
|
|
175
175
|
}
|
|
@@ -6,9 +6,12 @@ export default function getVerticalSpacing({ itemsContainer, renderedItemsCount
|
|
|
6
6
|
while (i < renderedItemsCount) {
|
|
7
7
|
const itemTopOffset = itemsContainer.getNthRenderedItemTopOffset(i)
|
|
8
8
|
const itemHeight = itemsContainer.getNthRenderedItemHeight(i)
|
|
9
|
-
//
|
|
10
|
-
|
|
9
|
+
// See if the item is on the next row.
|
|
10
|
+
// Simply checking for `itemTopOffset !== firstShownRowTopOffset` wouldn't work
|
|
11
|
+
// because items in a row aren't required to be aligned to the top border.
|
|
12
|
+
if (itemTopOffset >= firstShownRowTopOffset + firstShownRowHeight) {
|
|
11
13
|
// Measure inter-row spacing.
|
|
14
|
+
// Can't be "negative" with the current `if` condition.
|
|
12
15
|
return itemTopOffset - (firstShownRowTopOffset + firstShownRowHeight)
|
|
13
16
|
}
|
|
14
17
|
// A row height is the maximum of its item heights.
|