File tree Expand file tree Collapse file tree
main/java/org/fxmisc/flowless
test/java/org/fxmisc/flowless Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -146,6 +146,8 @@ private void cropToNeighborhoodOf( int itemIndex ) {
146146 int begin = Math .max ( 0 , getFirstVisibleIndex () );
147147 int end = Math .max ( itemIndex , getLastVisibleIndex () );
148148 positioner .cropTo ( Math .min ( begin , itemIndex ), end +1 );
149+ // Needed for correct layout in some situations
150+ sizeTracker .getAverageLengthEstimate ();
149151 }
150152
151153 @ Override
Original file line number Diff line number Diff line change 1+ package org .fxmisc .flowless ;
2+
3+ import javafx .collections .FXCollections ;
4+ import javafx .collections .ObservableList ;
5+ import javafx .scene .control .Label ;
6+ import javafx .scene .Scene ;
7+ import javafx .stage .Stage ;
8+ import org .junit .Test ;
9+
10+ import static org .junit .Assert .assertEquals ;
11+
12+ public class FirstCellCreationAndLayoutTest extends FlowlessTestBase
13+ {
14+ private VirtualFlow <Label , ?> flow ;
15+
16+ @ Override
17+ public void start (Stage stage )
18+ {
19+ Label first = new Label ( "First Item" );
20+ Label second = new Label ( "Second Item" );
21+ ObservableList <Label > items = FXCollections .observableArrayList ( first , second );
22+ flow = VirtualFlow .createVertical ( items , Cell ::wrapNode );
23+
24+ stage .setScene ( new Scene ( flow , 200 , 100 ) );
25+ stage .show ();
26+ }
27+
28+ @ Test
29+ public void does_the_first_cell_layout_correctly ()
30+ {
31+ assertEquals ( 0 , flow .getFirstVisibleIndex () );
32+ }
33+ }
You can’t perform that action at this time.
0 commit comments