summaryrefslogtreecommitdiffstats
path: root/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-07 12:44:01 +0200
commit0c5414744b720da51aedace58b9efa21ecd4bd0e (patch)
tree1ff08e689abfbc098ff26ba72e7ad6df0df32ba1 /client
parentf25041bfabd1e3b13a2a9bd85289098d33699cc2 (diff)
downloadvaadin-framework-0c5414744b720da51aedace58b9efa21ecd4bd0e.tar.gz
vaadin-framework-0c5414744b720da51aedace58b9efa21ecd4bd0e.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.java32
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 f9c8d96ad4..7d5cd8981b 100644
--- a/client/src/main/java/com/vaadin/client/widgets/Escalator.java
+++ b/client/src/main/java/com/vaadin/client/widgets/Escalator.java
@@ -2999,7 +2999,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);
@@ -3032,16 +3032,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
@@ -3524,12 +3530,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);
}
@@ -3641,8 +3647,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();
@@ -6687,7 +6693,7 @@ public class Escalator extends Widget
* @return the maximum capacity
*/
public int getMaxVisibleRowCount() {
- return body.getMaxEscalatorRowCapacity();
+ return body.getMaxVisibleRowCount();
}
/**