Skip to content

Commit

Permalink
Fixed 1px offset error #3
Browse files Browse the repository at this point in the history
  • Loading branch information
pleku committed May 15, 2015
1 parent cf21a3a commit 439d4a5
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -17,9 +15,5 @@
user-select: none;
}
}
.v-csslayout {
padding: 1px;
border: 1px solid black;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 439d4a5

Please sign in to comment.