Skip to content

Commit

Permalink
Prevent adding cells under the ground when item index is the last one
Browse files Browse the repository at this point in the history
When VirtualFlow is wrapped in a VirtualizedScrollPane and is scrolled, so that the last cell is being shown, this method should return 0. However, due to a scroll bar temporarily adjusting the viewport length, it returns a value that's roughly the height of the last cell's node. Thus, the call in `fillViewportFrom` will add more cells under the ground and shift them towards the sky. This call then hides the last item and the viewport appears to scroll up by one cell. The change insures that the last index always returns 0 rather than a postive value that causes the cell shift.
  • Loading branch information
JordanMartinez committed Oct 8, 2017
1 parent 3f3a792 commit 1b7ae6c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/java/org/fxmisc/flowless/Navigator.java
Expand Up @@ -357,8 +357,9 @@ private double distanceFromGround(int itemIndex) {

private double distanceFromSky(int itemIndex) {
C cell = positioner.getVisibleCell(itemIndex);
int lastIndex = cellListManager.getLazyCellList().size() - 1;
return gravity.get() == Gravity.FRONT
? sizeTracker.getViewportLength() - orientation.maxY(cell)
? itemIndex == lastIndex ? 0 : sizeTracker.getViewportLength() - orientation.maxY(cell)
: orientation.minY(cell);
}

Expand Down

0 comments on commit 1b7ae6c

Please sign in to comment.