From 439d4a53c19bdac8b9d271d8eae38e9cbbc0f663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pekka=20Hyv=C3=B6nen?= Date: Fri, 15 May 2015 13:12:00 +0300 Subject: [PATCH] Fixed 1px offset error #3 --- .gitignore | 2 +- .../pekka/resizablecsslayout/demo/DemoUI.java | 2 -- .../main/webapp/VAADIN/themes/demo/demo.scss | 6 ---- .../client/ResizableVCssLayout.java | 31 ++++++++++--------- .../resizablecsslayout.scss | 13 +++++--- 5 files changed, 26 insertions(+), 28 deletions(-) diff --git a/.gitignore b/.gitignore index 8592d65..86e22db 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,6 @@ rebel.xml *.launch resizablecsslayout-demo/src/main/webapp/VAADIN/widgetsets/* - +*/assembly/* # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* diff --git a/resizablecsslayout-demo/src/main/java/com/vaadin/pekka/resizablecsslayout/demo/DemoUI.java b/resizablecsslayout-demo/src/main/java/com/vaadin/pekka/resizablecsslayout/demo/DemoUI.java index b45e6d4..75dccfa 100644 --- a/resizablecsslayout-demo/src/main/java/com/vaadin/pekka/resizablecsslayout/demo/DemoUI.java +++ b/resizablecsslayout-demo/src/main/java/com/vaadin/pekka/resizablecsslayout/demo/DemoUI.java @@ -149,8 +149,6 @@ private Grid createGrid() { Grid grid = new Grid(); grid.setContainerDataSource(container); grid.getColumn("name").setExpandRatio(2); - grid.getColumn("amount").setExpandRatio(1); - grid.getColumn("count").setExpandRatio(1); grid.setSizeFull(); grid.setSelectionMode(SelectionMode.NONE); return grid; diff --git a/resizablecsslayout-demo/src/main/webapp/VAADIN/themes/demo/demo.scss b/resizablecsslayout-demo/src/main/webapp/VAADIN/themes/demo/demo.scss index 8aeeafd..ad20fcd 100644 --- a/resizablecsslayout-demo/src/main/webapp/VAADIN/themes/demo/demo.scss +++ b/resizablecsslayout-demo/src/main/webapp/VAADIN/themes/demo/demo.scss @@ -6,8 +6,6 @@ .v-absolutelayout{ border: 1px solid green; .v-csslayout.resizable { - border: 1px solid orchid; - padding: 1px; &.resizing, &.resizing > div { -webkit-user-select: none; /* Chrome all / Safari all */ @@ -17,9 +15,5 @@ user-select: none; } } - .v-csslayout { - padding: 1px; - border: 1px solid black; - } } } \ No newline at end of file diff --git a/resizablecsslayout/src/main/java/com/vaadin/pekka/resizablecsslayout/client/ResizableVCssLayout.java b/resizablecsslayout/src/main/java/com/vaadin/pekka/resizablecsslayout/client/ResizableVCssLayout.java index df23eb9..c129560 100644 --- a/resizablecsslayout/src/main/java/com/vaadin/pekka/resizablecsslayout/client/ResizableVCssLayout.java +++ b/resizablecsslayout/src/main/java/com/vaadin/pekka/resizablecsslayout/client/ResizableVCssLayout.java @@ -15,6 +15,7 @@ import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.EventListener; +import com.vaadin.client.WidgetUtil; import com.vaadin.client.ui.VCssLayout; /** @@ -361,7 +362,7 @@ public void onBrowserEvent(Event event) { private void onMouseMove(Event event) { if (resizingY) { - int clientY = event.getClientY(); + int clientY = WidgetUtil.getTouchOrMouseClientY(event); if (!isInVerticalBoundary(event)) { // set the size to the edge of the boundary element clientY = clientY < boundaryElement.getAbsoluteTop() ? (boundaryElement @@ -378,7 +379,7 @@ private void onMouseMove(Event event) { event.stopPropagation(); } if (resizingX) { - int clientX = event.getClientX(); + int clientX = WidgetUtil.getTouchOrMouseClientX(event); if (!isInHorizontalBoundary(event)) { // set the size to the edge of the boundary element clientX = clientX < boundaryElement.getAbsoluteLeft() ? (boundaryElement @@ -448,9 +449,11 @@ protected void acceptResize(boolean accept) { waitingAccept = false; if (accept) { getElement().getStyle().setWidth( - dragOverlayElement.getClientWidth(), Unit.PX); + WidgetUtil.getRequiredWidth(dragOverlayElement), + Unit.PX); getElement().getStyle().setHeight( - dragOverlayElement.getClientHeight(), Unit.PX); + WidgetUtil.getRequiredHeight(dragOverlayElement), + Unit.PX); } resizingX = false; resizingY = false; @@ -480,8 +483,8 @@ private void onResizeEnd(Event event) { event.stopPropagation(); stopCursorOverride(); unmarkBoundaryResizing(); - fireResizeEnd(dragOverlayElement.getClientWidth(), - dragOverlayElement.getClientHeight()); + fireResizeEnd(WidgetUtil.getRequiredWidth(dragOverlayElement), + WidgetUtil.getRequiredHeight(dragOverlayElement)); if (autoAcceptResize) { acceptResize(true); } @@ -514,11 +517,11 @@ private ResizeLocation startDiagonalResize(Event event, Element target) { resizingX = true; resizingY = true; Style style = dragOverlayElement.getStyle(); - startHeight = getElement().getClientHeight(); - startClientY = event.getClientY(); + startHeight = WidgetUtil.getRequiredHeight(getElement()); + startClientY = WidgetUtil.getTouchOrMouseClientY(event); style.setHeight(startHeight, Unit.PX); - startWidth = getElement().getClientWidth(); - startClientX = event.getClientX(); + startWidth = WidgetUtil.getRequiredWidth(getElement()); + startClientX = WidgetUtil.getTouchOrMouseClientX(event); style.setWidth(startWidth, Unit.PX); if (target.equals(topLeftCorner) || target.equals(topRightCorner)) { revertY = true; @@ -545,8 +548,8 @@ private ResizeLocation startVerticalResize(Event event, Element target) { ResizeLocation resizeLocation; resizingY = true; Style style = dragOverlayElement.getStyle(); - startHeight = getElement().getClientHeight(); - startClientY = event.getClientY(); + startHeight = WidgetUtil.getRequiredHeight(getElement()); + startClientY = WidgetUtil.getTouchOrMouseClientY(event); style.setHeight(startHeight, Unit.PX); if (target.equals(topSide)) { revertY = true; @@ -566,8 +569,8 @@ private ResizeLocation startHorizontalResize(Event event, Element target) { ResizeLocation resizeLocation; resizingX = true; Style style = dragOverlayElement.getStyle(); - startWidth = getElement().getClientWidth(); - startClientX = event.getClientX(); + startWidth = WidgetUtil.getRequiredWidth(getElement()); + startClientX = WidgetUtil.getTouchOrMouseClientX(event); style.setWidth(startWidth, Unit.PX); if (target.equals(leftSide)) { revertX = true; diff --git a/resizablecsslayout/src/main/resources/VAADIN/addons/resizablecsslayout/resizablecsslayout.scss b/resizablecsslayout/src/main/resources/VAADIN/addons/resizablecsslayout/resizablecsslayout.scss index b999425..2200761 100644 --- a/resizablecsslayout/src/main/resources/VAADIN/addons/resizablecsslayout/resizablecsslayout.scss +++ b/resizablecsslayout/src/main/resources/VAADIN/addons/resizablecsslayout/resizablecsslayout.scss @@ -3,11 +3,14 @@ position: relative; &.resizing { overflow: visible; - .drag-overlay { - border: 1px solid red; - position: absolute; - z-index: 10; - } + } + .drag-overlay { + border: 1px solid red; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + position: absolute; + z-index: 10; } .tlc, .ts, .trc, .rs, .brc, .bs, .blc, .ls { background-color: transparent;