diff options
author | Artur <artur@vaadin.com> | 2017-03-07 12:44:01 +0200 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-03-16 12:32:19 +0200 |
commit | 833e6e3bd98ff04a35b428c35afe16c874893780 (patch) | |
tree | d657866c79341476bcbcd13dac0944f6daf2fd5a /client | |
parent | c299a6bb4803bb132409fa2b9c0d4b45636a7a4c (diff) | |
download | vaadin-framework-833e6e3bd98ff04a35b428c35afe16c874893780.tar.gz vaadin-framework-833e6e3bd98ff04a35b428c35afe16c874893780.zip |
Always calculate Escalator max row count the same way (#8740)
* Rename getMaxEscalatorRowCapacity to describe what it does
* Always calculate Escalator max row count the same way
This changes Escalator to not take a horizontal scrollbar
into account when trying to determine "maximum visible rows". This will
add another row, compared to previous versions, when there is a horizontal
scrollbar. In reality, it would likely make sense to always add 10 more rows
to have some buffer above and below the visible area.
Fixes #8661
Diffstat (limited to 'client')
-rw-r--r-- | client/src/main/java/com/vaadin/client/widgets/Escalator.java | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/client/src/main/java/com/vaadin/client/widgets/Escalator.java b/client/src/main/java/com/vaadin/client/widgets/Escalator.java index 34cdb70b2b..8f79483eb8 100644 --- a/client/src/main/java/com/vaadin/client/widgets/Escalator.java +++ b/client/src/main/java/com/vaadin/client/widgets/Escalator.java @@ -2970,7 +2970,7 @@ public class Escalator extends Widget private List<TableRowElement> fillAndPopulateEscalatorRowsIfNeeded( final int index, final int numberOfRows) { - final int escalatorRowsStillFit = getMaxEscalatorRowCapacity() + final int escalatorRowsStillFit = getMaxVisibleRowCount() - getDomRowCount(); final int escalatorRowsNeeded = Math.min(numberOfRows, escalatorRowsStillFit); @@ -3003,16 +3003,22 @@ public class Escalator extends Widget } } - private int getMaxEscalatorRowCapacity() { - final int maxEscalatorRowCapacity = (int) Math - .ceil(getHeightOfSection() / getDefaultRowHeight()) + 1; + private int getMaxVisibleRowCount() { + double heightOfSection = getHeightOfSection(); + // By including the possibly shown scrollbar height, we get a + // consistent count and do not add/remove rows whenever a scrollbar + // is shown + heightOfSection += horizontalScrollbarDeco.getOffsetHeight(); + double defaultRowHeight = getDefaultRowHeight(); + final int maxVisibleRowCount = (int) Math + .ceil(heightOfSection / defaultRowHeight) + 1; /* - * maxEscalatorRowCapacity can become negative if the headers and - * footers start to overlap. This is a crazy situation, but Vaadin - * blinks the components a lot, so it's feasible. + * maxVisibleRowCount can become negative if the headers and footers + * start to overlap. This is a crazy situation, but Vaadin blinks + * the components a lot, so it's feasible. */ - return Math.max(0, maxEscalatorRowCapacity); + return Math.max(0, maxVisibleRowCount); } @Override @@ -3489,12 +3495,12 @@ public class Escalator extends Widget * TODO [[spacer]]: these assumptions will be totally broken with * spacers. */ - final int maxEscalatorRows = getMaxEscalatorRowCapacity(); + final int maxVisibleRowCount = getMaxVisibleRowCount(); final int currentTopRowIndex = getLogicalRowIndex( visualRowOrder.getFirst()); final Range[] partitions = logicalRange.partitionWith( - Range.withLength(currentTopRowIndex, maxEscalatorRows)); + Range.withLength(currentTopRowIndex, maxVisibleRowCount)); final Range insideRange = partitions[1]; return insideRange.offsetBy(-currentTopRowIndex); } @@ -3606,8 +3612,8 @@ public class Escalator extends Widget return; } - final int maxEscalatorRows = getMaxEscalatorRowCapacity(); - final int neededEscalatorRows = Math.min(maxEscalatorRows, + final int maxVisibleRowCount = getMaxVisibleRowCount(); + final int neededEscalatorRows = Math.min(maxVisibleRowCount, body.getRowCount()); final int neededEscalatorRowsDiff = neededEscalatorRows - visualRowOrder.size(); @@ -6646,7 +6652,7 @@ public class Escalator extends Widget * @return the maximum capacity */ public int getMaxVisibleRowCount() { - return body.getMaxEscalatorRowCapacity(); + return body.getMaxVisibleRowCount(); } /** |