diff options
author | Pekka Hyvönen <pekka@vaadin.com> | 2015-05-06 11:52:47 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2015-05-15 11:11:23 +0000 |
commit | bdc28f77c6c629eec0a0129a1a791855a6fc435d (patch) | |
tree | 6eb7f60012480698f15f206035327984680144e4 /client | |
parent | 3a5cd8e4cd36a9db986978c01fe39356b3cbe3b6 (diff) | |
download | vaadin-framework-bdc28f77c6c629eec0a0129a1a791855a6fc435d.tar.gz vaadin-framework-bdc28f77c6c629eec0a0129a1a791855a6fc435d.zip |
Wrong floating element pos. on DND column reorder Grid #17693
When Grid was wider, the floating element did follow mouse to the
right after some point.
Also makes sure floating element is not shown on top of frozen columns
when auto scrolling left.
Change-Id: Ied779222c484f1f22119f89c0e720f868bbc898e
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/widgets/Grid.java | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/client/src/com/vaadin/client/widgets/Grid.java b/client/src/com/vaadin/client/widgets/Grid.java index 92827c47f0..07074eeddf 100644 --- a/client/src/com/vaadin/client/widgets/Grid.java +++ b/client/src/com/vaadin/client/widgets/Grid.java @@ -3541,24 +3541,26 @@ public class Grid<T> extends ResizeComposite implements private void resolveDragElementHorizontalPosition(final int clientX) { double left = clientX - table.getAbsoluteLeft(); - final double frozenColumnsWidth = getFrozenColumnsWidth(); - if (left < frozenColumnsWidth) { - left = (int) frozenColumnsWidth; - } - // do not show the drag element beyond a spanned header cell + // Do not show the drag element beyond a spanned header cell // limitation final Double leftBound = possibleDropPositions.firstKey(); final Double rightBound = possibleDropPositions.lastKey(); - double scrollLeft = getScrollLeft(); + final double scrollLeft = getScrollLeft(); if (left + scrollLeft < leftBound) { left = leftBound - scrollLeft + autoScrollX; } else if (left + scrollLeft > rightBound) { left = rightBound - scrollLeft + autoScrollX; } - // do not show the drag element beyond the grid - left = Math.max(0, Math.min(left, table.getClientWidth())); + // Do not show the drag element beyond the grid + final int bodyOffsetWidth = getEscalator().getBody().getElement() + .getOffsetWidth(); + // Do not show on left of the frozen columns (even if scrolled) + final int frozenColumnsWidth = (int) getFrozenColumnsWidth(); + + left = Math + .max(frozenColumnsWidth, Math.min(left, bodyOffsetWidth)); left -= dragElement.getClientWidth() / 2; dragElement.getStyle().setLeft(left, Unit.PX); |