Skip to content
This repository has been archived by the owner on Dec 8, 2017. It is now read-only.

Update GridConstrainedDropController.java #197

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ public GridConstrainedDropController(AbsolutePanel dropTarget, int gridX, int gr

@Override
public void drop(Widget widget, int left, int top) {
left = Math.max(0, Math.min(left, dropTarget.getOffsetWidth() - widget.getOffsetWidth()));
top = Math.max(0, Math.min(top, dropTarget.getOffsetHeight() - widget.getOffsetHeight()));
int scrollLeft = Math.round(elementBox.getParent().getElement().getScrollLeft());
int scrollTop = Math.round(elementBox.getParent().getElement().getScrollTop());
left = left + scrollLeft;
top = top + scrollTop;
left = Math.max(0, Math.min(left, dropTarget.getOffsetWidth() - widget.getOffsetWidth() + scrollLeft));
top = Math.max(0, Math.min(top, dropTarget.getOffsetHeight() - widget.getOffsetHeight() + scrollTop));
left = Math.round((float) left / gridX) * gridX;
top = Math.round((float) top / gridY) * gridY;
dropTarget.add(widget, left, top);
Expand All @@ -46,13 +50,15 @@ public void drop(Widget widget, int left, int top) {
@Override
public void onMove(DragContext context) {
super.onMove(context);
int scrollLeft = Math.round(elementBox.getParent().getElement().getScrollLeft());
int scrollTop = Math.round(elementBox.getParent().getElement().getScrollTop());
for (Draggable draggable : draggableList) {
draggable.desiredX = context.desiredDraggableX - dropTargetOffsetX + draggable.relativeX;
draggable.desiredY = context.desiredDraggableY - dropTargetOffsetY + draggable.relativeY;
draggable.desiredX = Math.max(0, Math.min(draggable.desiredX, dropTargetClientWidth
- draggable.offsetWidth));
- draggable.offsetWidth + scrollLeft));
draggable.desiredY = Math.max(0, Math.min(draggable.desiredY, dropTargetClientHeight
- draggable.offsetHeight));
- draggable.offsetHeight + scrollLeft));
draggable.desiredX = Math.round((float) draggable.desiredX / gridX) * gridX;
draggable.desiredY = Math.round((float) draggable.desiredY / gridY) * gridY;
dropTarget.add(draggable.positioner, draggable.desiredX, draggable.desiredY);
Expand Down