Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crop cells only if memorizedRange is bigger than expected range #94

Merged
merged 6 commits into from
Jul 20, 2021
Merged
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
10 changes: 8 additions & 2 deletions src/main/java/org/fxmisc/flowless/CellListManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import javafx.collections.ObservableList;
import javafx.scene.Node;
import javafx.scene.control.IndexRange;
import javafx.scene.input.ScrollEvent;

import org.reactfx.EventStreams;
Expand Down Expand Up @@ -85,8 +86,13 @@ public C getCell(int itemIndex) {
public void cropTo(int fromItem, int toItem) {
fromItem = Math.max(fromItem, 0);
toItem = Math.max(Math.min(toItem, cells.size()), 0);
cells.forget(0, fromItem);
cells.forget(toItem, cells.size());
IndexRange memorizedRange = cells.getMemoizedItemsRange();
if (memorizedRange.getStart() < fromItem) {
cells.forget(0, fromItem);
}
if (memorizedRange.getEnd() > toItem) {
cells.forget(toItem, cells.size());
}
}

private C cellForItem(T item) {
Expand Down