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.
@@ -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, '. An item\'s height is allowed to change only in two cases: when the item\'s "state" changes and the developer calls `setItemState(i, newState)`, or when the item\'s height changes for any reason and the developer calls `onItemHeightDidChange(i)` right after that happens. Perhaps you forgot to persist the item\'s "state" by calling `setItemState(i, newState)` when it changed, and that "state" got lost when the item element was unmounted, which resulted in a different height when the item was shown again having its "state" reset.')
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
  }
@@ -77,7 +77,7 @@ export default function() {
77
77
 
78
78
  let layoutUpdateReason
79
79
 
80
- if (this.updateLayoutAfterRenderBecauseItemHeightChanged) {
80
+ if (itemHeightHasChanged) {
81
81
  layoutUpdateReason = LAYOUT_REASON.ITEM_HEIGHT_CHANGED
82
82
  }
83
83
 
@@ -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
- // If next row is detected.
10
- if (itemTopOffset !== firstShownRowTopOffset) {
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.