summaryrefslogtreecommitdiffstats
path: root/compatibility-client
diff options
context:
space:
mode:
authorArtur <artur@vaadin.com>2017-03-07 12:44:01 +0200
committerHenri Sara <henri.sara@gmail.com>2017-03-16 12:32:19 +0200
commit833e6e3bd98ff04a35b428c35afe16c874893780 (patch)
treed657866c79341476bcbcd13dac0944f6daf2fd5a /compatibility-client
parentc299a6bb4803bb132409fa2b9c0d4b45636a7a4c (diff)
downloadvaadin-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 'compatibility-client')
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Escalator.java32
1 files changed, 19 insertions, 13 deletions
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Escalator.java b/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Escalator.java
index 04fcdbe766..f022d691b7 100644
--- a/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Escalator.java
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Escalator.java
@@ -2982,7 +2982,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);
@@ -3015,16 +3015,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
@@ -3507,12 +3513,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);
}
@@ -3624,8 +3630,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();
@@ -6673,7 +6679,7 @@ public class Escalator extends Widget
* @return the maximum capacity
*/
public int getMaxVisibleRowCount() {
- return body.getMaxEscalatorRowCapacity();
+ return body.getMaxVisibleRowCount();
}
/**