Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/org/fxmisc/flowless/Navigator.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ private void cropToNeighborhoodOf( int itemIndex ) {
int begin = Math.max( 0, getFirstVisibleIndex() );
int end = Math.max( itemIndex, getLastVisibleIndex() );
positioner.cropTo( Math.min( begin, itemIndex ), end+1 );
// Needed for correct layout in some situations
sizeTracker.getAverageLengthEstimate();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.fxmisc.flowless;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.control.Label;
import javafx.scene.Scene;
import javafx.stage.Stage;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class FirstCellCreationAndLayoutTest extends FlowlessTestBase
{
private VirtualFlow<Label, ?> flow;

@Override
public void start(Stage stage)
{
Label first = new Label( "First Item" );
Label second = new Label( "Second Item" );
ObservableList<Label> items = FXCollections.observableArrayList( first, second );
flow = VirtualFlow.createVertical( items, Cell::wrapNode );

stage.setScene( new Scene( flow, 200, 100 ) );
stage.show();
}

@Test
public void does_the_first_cell_layout_correctly()
{
assertEquals( 0, flow.getFirstVisibleIndex() );
}
}