From bdc28f77c6c629eec0a0129a1a791855a6fc435d Mon Sep 17 00:00:00 2001 From: Pekka Hyvönen Date: Wed, 6 May 2015 11:52:47 +0300 Subject: 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 --- client/src/com/vaadin/client/widgets/Grid.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'client/src') 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 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); -- cgit v1.2.3