aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2015-06-11 11:34:41 +0300
committerVaadin Code Review <review@vaadin.com>2015-06-11 10:43:22 +0000
commit61037a75a565828e1f6dd752347e82036182e489 (patch)
treec7038ea8855a4a9d700dc81e4f8a6f5f34d841e2
parent2e6ecec3dff65a43ef5f6e186058119d4bc72bf4 (diff)
downloadvaadin-framework-61037a75a565828e1f6dd752347e82036182e489.tar.gz
vaadin-framework-61037a75a565828e1f6dd752347e82036182e489.zip
Fix Grid column dnd reorder scrollarea calculation in Chrome 43 (#18234)
This patch also fixes issues with vertical scrollbar on page and autoscrolling along with calculating drag element and marker positions wrong. Change-Id: I3d39c7bc6ddea630e04a9967ff8e1055c0736b79
-rw-r--r--client/src/com/vaadin/client/widget/grid/AutoScroller.java61
-rw-r--r--client/src/com/vaadin/client/widgets/Grid.java12
2 files changed, 10 insertions, 63 deletions
diff --git a/client/src/com/vaadin/client/widget/grid/AutoScroller.java b/client/src/com/vaadin/client/widget/grid/AutoScroller.java
index f2e44196ec..90d206d98b 100644
--- a/client/src/com/vaadin/client/widget/grid/AutoScroller.java
+++ b/client/src/com/vaadin/client/widget/grid/AutoScroller.java
@@ -538,9 +538,8 @@ public class AutoScroller {
final int endBorder = getBodyClientEnd();
startBorder += getFrozenColumnsWidth();
- final int scrollCompensation = getScrollCompensation();
- startingBound = scrollCompensation + startBorder + scrollAreaPX;
- endingBound = scrollCompensation + endBorder - scrollAreaPX;
+ startingBound = startBorder + scrollAreaPX;
+ endingBound = endBorder - scrollAreaPX;
gradientArea = scrollAreaPX;
// modify bounds if they're too tightly packed
@@ -553,18 +552,6 @@ public class AutoScroller {
}
}
- private int getScrollCompensation() {
- Element cursor = grid.getElement();
- int scroll = 0;
- while (cursor != null) {
- scroll -= scrollDirection == ScrollAxis.VERTICAL ? cursor
- .getScrollTop() : cursor.getScrollLeft();
- cursor = cursor.getParentElement();
- }
-
- return scroll;
- }
-
private void injectNativeHandler() {
removeNativeHandler();
nativePreviewHandlerRegistration = Event
@@ -588,15 +575,6 @@ public class AutoScroller {
}
}
- private TableSectionElement getTbodyElement() {
- TableElement table = getTableElement();
- if (table != null) {
- return table.getTBodies().getItem(0);
- } else {
- return null;
- }
- }
-
private TableSectionElement getTheadElement() {
TableElement table = getTableElement();
if (table != null) {
@@ -615,47 +593,20 @@ public class AutoScroller {
}
}
- /** Get the "top" of an element in relation to "client" coordinates. */
- @SuppressWarnings("static-method")
- private int getClientTop(final Element e) {
- Element cursor = e;
- int top = 0;
- while (cursor != null) {
- top += cursor.getOffsetTop();
- cursor = cursor.getOffsetParent();
- }
- return top;
- }
-
- /** Get the "left" of an element in relation to "client" coordinates. */
- @SuppressWarnings("static-method")
- private int getClientLeft(final Element e) {
- Element cursor = e;
- int left = 0;
- while (cursor != null) {
- left += cursor.getOffsetLeft();
- cursor = cursor.getOffsetParent();
- }
- return left;
- }
-
private int getBodyClientEnd() {
if (scrollDirection == ScrollAxis.VERTICAL) {
- return getClientTop(getTfootElement()) - 1;
+ return getTfootElement().getAbsoluteTop() - 1;
} else {
- TableSectionElement tbodyElement = getTbodyElement();
- return getClientLeft(tbodyElement) + tbodyElement.getOffsetWidth()
- - 1;
+ return getTableElement().getAbsoluteRight();
}
}
private int getBodyClientStart() {
if (scrollDirection == ScrollAxis.VERTICAL) {
- return getClientTop(grid.getElement())
- + getTheadElement().getOffsetHeight();
+ return getTheadElement().getAbsoluteBottom() + 1;
} else {
- return getClientLeft(getTbodyElement());
+ return getTableElement().getAbsoluteLeft();
}
}
diff --git a/client/src/com/vaadin/client/widgets/Grid.java b/client/src/com/vaadin/client/widgets/Grid.java
index bf0ab5a83b..f6772ba1f6 100644
--- a/client/src/com/vaadin/client/widgets/Grid.java
+++ b/client/src/com/vaadin/client/widgets/Grid.java
@@ -3641,17 +3641,14 @@ public class Grid<T> extends ResizeComposite implements
// scrolled to the right
if (latestColumnDropIndex == visibleColumns
&& rightBoundaryForDrag < dropMarkerLeft
- && dropMarkerLeft <= escalator.getHeader().getElement()
- .getOffsetWidth()) {
+ && dropMarkerLeft <= escalator.getInnerWidth()) {
dropMarkerLeft = rightBoundaryForDrag - dropMarkerWidthOffset;
}
// Check if the drop marker shouldn't be shown at all
else if (dropMarkerLeft < frozenColumnsWidth
- || dropMarkerLeft > Math
- .min(rightBoundaryForDrag, escalator.getHeader()
- .getElement().getOffsetWidth())
- || dropMarkerLeft < 0) {
+ || dropMarkerLeft > Math.min(rightBoundaryForDrag,
+ escalator.getInnerWidth()) || dropMarkerLeft < 0) {
dropMarkerLeft = -10000000;
}
dropMarker.getStyle().setLeft(dropMarkerLeft, Unit.PX);
@@ -3673,8 +3670,7 @@ public class Grid<T> extends ResizeComposite implements
// Do not show the drag element beyond the grid
final double sidebarBoundary = getSidebarBoundaryComparedTo(left);
- final int gridBoundary = escalator.getHeader().getElement()
- .getOffsetWidth();
+ final double gridBoundary = escalator.getInnerWidth();
final double rightBoundary = Math
.min(sidebarBoundary, gridBoundary);