Class VFXListHelper.VerticalHelper<T,C extends VFXCell<T>>

All Implemented Interfaces:
VFXContainerHelper<T,VFXList<T,C>>, VFXListHelper<T,C>
Direct Known Subclasses:
VFXPaginatedListHelper.VerticalHelper
Enclosing interface:
VFXListHelper<T,C extends VFXCell<T>>

public static class VFXListHelper.VerticalHelper<T,C extends VFXCell<T>> extends VFXListHelper.AbstractHelper<T,C>
Concrete implementation of VFXListHelper.AbstractHelper for Orientation.VERTICAL. Here the range of items to display and the viewport position are defined as follows:

- the range is given by the firstVisible() element minus the buffer size (VFXList.bufferSizeProperty()), (cannot be negative) and the sum between this start index and the total number of needed cells given by VFXListHelper.AbstractHelper.totalNum(), (cannot exceed the number of items - 1). It may happen the number of indexes given by the range end - start + 1 is lesser than the total number of cells we need. In such cases, the range start is corrected to be end - needed + 1. A typical situation for this is when the list position reaches the max scroll. The range computation has the following dependencies: the list's height, the virtual max y, the buffer size and the vertical position.

- the viewport position, a computation that is at the core of virtual scrolling. The viewport, which contains the cells, is not supposed to scroll by insane numbers of pixels both for performance reasons and because it is not necessary. The horizontal position is just the current VFXList.hPosProperty() but negative. The vertical position is the one virtualized. First we get the range of items to display and the total cell size given by VFXListHelper.getTotalCellSize(), yes, the spacing also affects the position. Then we compute the range to the first visible cell, which is given by IntegerRange.of(range.getMin(), firstVisible()), in other words we limit the 'complete' range to the top buffer including the first cell after the buffer. The number of indexes in this newfound range (given by IntegerRange.diff()) is multiplied by the total cell size, this way we found the number of pixels to the first visible cell, pixelsToFirst. We are missing only one last information, how much do we actually see of the first visible cell? We call this amount visibleAmountFirst and it's given by vPos % totalCellSize. Finally, the viewport's vertical position is given by -(pixelsToFirst + visibleAmountFist. While it's true that the calculations are more complex and 'needy', it's important to note that this approach allows avoiding 'hacks' to correctly lay out the cells in the viewport. No need for special offsets at the top or bottom anymore. The viewport's position computation has the following dependencies: the horizontal position, the vertical position, the cell size and the spacing