Skip to content

Commit

Permalink
Do not change target position when equal amount of cells are replaced
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanMartinez committed Oct 8, 2017
1 parent d49214b commit 3f3a792
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions src/main/java/org/fxmisc/flowless/TargetPosition.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@ public TargetPosition transformByChange(
// change before the target item, just update item index
return new StartOffStart(itemIndex - removedSize + addedSize, offsetFromStart);
} else if(itemIndex >= pos) {
// target item deleted, show the first inserted at the target offset
return new StartOffStart(pos, offsetFromStart);
// target item deleted
if (addedSize == removedSize) {
return this;
} else {
// show the first inserted at the target offset
return new StartOffStart(pos, offsetFromStart);
}
} else {
// change after the target item, target position not affected
return this;
Expand Down Expand Up @@ -119,8 +124,13 @@ public TargetPosition transformByChange(
// change before the target item, just update item index
return new EndOffEnd(itemIndex - removedSize + addedSize, offsetFromEnd);
} else if(itemIndex >= pos) {
// target item deleted, show the last inserted at the target offset
return new EndOffEnd(pos + addedSize - 1, offsetFromEnd);
// target item deleted
if (addedSize == removedSize) {
return this;
} else {
// show the last inserted at the target offset
return new EndOffEnd(pos + addedSize - 1, offsetFromEnd);
}
} else {
// change after the target item, target position not affected
return this;
Expand Down Expand Up @@ -165,8 +175,13 @@ public TargetPosition transformByChange(
// change before the target item, just update item index
return new MinDistanceTo(itemIndex - removedSize + addedSize, minY, maxY);
} else if(itemIndex >= pos) {
// target item deleted, show the first inserted
return new MinDistanceTo(pos, Offset.fromStart(0.0), Offset.fromEnd(0.0));
// target item deleted
if (addedSize == removedSize) {
return this;
} else {
// show the first inserted
return new MinDistanceTo(pos, Offset.fromStart(0.0), Offset.fromEnd(0.0));
}
} else {
// change after the target item, target position not affected
return this;
Expand Down

0 comments on commit 3f3a792

Please # to comment.