diff options
author | Henrik Paul <henrik@vaadin.com> | 2015-03-03 16:49:19 +0200 |
---|---|---|
committer | Henrik Paul <henrik@vaadin.com> | 2015-03-03 16:49:19 +0200 |
commit | b4a5adca6c2d69bb521ae71fd584bef7a320e7d0 (patch) | |
tree | 26b2159b15ea522092ba507023499fc0618eb692 /client/src | |
parent | b973c65eaff99ab2575854f12bb046e968baa3ff (diff) | |
download | vaadin-framework-b4a5adca6c2d69bb521ae71fd584bef7a320e7d0.tar.gz vaadin-framework-b4a5adca6c2d69bb521ae71fd584bef7a320e7d0.zip |
Adds support for -1 row index Escalator spacers (#16644)
Change-Id: Iced2f089785983ce2ef1d2225517156cec4a7db4
Diffstat (limited to 'client/src')
-rw-r--r-- | client/src/com/vaadin/client/widget/escalator/RowContainer.java | 3 | ||||
-rw-r--r-- | client/src/com/vaadin/client/widgets/Escalator.java | 11 |
2 files changed, 11 insertions, 3 deletions
diff --git a/client/src/com/vaadin/client/widget/escalator/RowContainer.java b/client/src/com/vaadin/client/widget/escalator/RowContainer.java index e2baf9a03b..b7aae1f4f3 100644 --- a/client/src/com/vaadin/client/widget/escalator/RowContainer.java +++ b/client/src/com/vaadin/client/widget/escalator/RowContainer.java @@ -57,7 +57,8 @@ public interface RowContainer { * * @param rowIndex * the row index for the spacer to modify. The affected - * spacer is underneath the given index + * spacer is underneath the given index. Use -1 to insert a + * spacer before the first row * @param height * the pixel height of the spacer. If {@code height} is * negative, the affected spacer (if exists) will be removed diff --git a/client/src/com/vaadin/client/widgets/Escalator.java b/client/src/com/vaadin/client/widgets/Escalator.java index 1d7d9a9910..9b11e7aec1 100644 --- a/client/src/com/vaadin/client/widgets/Escalator.java +++ b/client/src/com/vaadin/client/widgets/Escalator.java @@ -4453,8 +4453,15 @@ public class Escalator extends Widget implements RequiresResize, .getScrollSize() + heightDiff); } + /* + * Don't modify the scrollbars if we're expanding the -1 spacer + * while we're scrolled to the top. + */ + boolean minusOneSpacerException = spacerIsGrowing + && getRow() == -1 && body.getTopRowLogicalIndex() == 0; + boolean viewportNeedsScrolling = getRow() < body - .getTopRowLogicalIndex(); + .getTopRowLogicalIndex() && !minusOneSpacerException; if (viewportNeedsScrolling) { /* @@ -4570,7 +4577,7 @@ public class Escalator extends Widget implements RequiresResize, public void setSpacer(int rowIndex, double height) throws IllegalArgumentException { - if (rowIndex < 0 || rowIndex >= getBody().getRowCount()) { + if (rowIndex < -1 || rowIndex >= getBody().getRowCount()) { throw new IllegalArgumentException("invalid row index: " + rowIndex + ", while the body only has " + getBody().getRowCount() + " rows."); |