diff --git a/src/main/java/org/fxmisc/flowless/SizeTracker.java b/src/main/java/org/fxmisc/flowless/SizeTracker.java index d5d4ba4..9423171 100644 --- a/src/main/java/org/fxmisc/flowless/SizeTracker.java +++ b/src/main/java/org/fxmisc/flowless/SizeTracker.java @@ -62,8 +62,9 @@ public SizeTracker( viewportBounds, (a, b) -> Math.max(a, orientation.breadth(b))); - Val, Double>> lengthFn = avoidFalseInvalidations(breadthForCells).map( - breadth -> cell -> orientation.prefLength(cell, breadth)); + Val, Double>> lengthFn; + lengthFn = (orientation instanceof HorizontalHelper ? breadthForCells : avoidFalseInvalidations(breadthForCells)) + .map(breadth -> cell -> orientation.prefLength(cell, breadth)); this.lengths = cells.mapDynamic(lengthFn).memoize(); @@ -193,4 +194,4 @@ public double lengthFor(int itemIndex) { public double getCellLayoutBreadth() { return breadthForCells.getValue(); } -} \ No newline at end of file +}