The following code is taken from grid.java in the vaadin repo, this is identical to that used in vaadin-grid to generate the javascript.
[code]
private void resolveDragElementHorizontalPosition(final int clientX) {
double left = clientX - table.getAbsoluteLeft();
// Do not show the drag element beyond a spanned header cell
// limitation
final Double leftBound = possibleDropPositions.firstKey();
final Double rightBound = possibleDropPositions.lastKey();
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
final double sidebarBoundary = getSidebarBoundaryComparedTo(left);
final double gridBoundary = escalator.getInnerWidth();
final double rightBoundary = Math
.min(sidebarBoundary, gridBoundary);
// Do not show on left of the frozen columns (even if scrolled)
final int frozenColumnsWidth = (int) autoScroller
.getFrozenColumnsWidth();
left = Math.max(frozenColumnsWidth, Math.min(left, rightBoundary));
left -= dragElement.getClientWidth() / 2;
dragElement.getStyle().setLeft(left, Unit.PX);
}
[/code]The bold red text is what ive found to be a problem when trying to use this for dragability purposes. After using gulp to get the resultant javascript we have:
function $resolveDragElementHorizontalPosition(this$static, clientX){
var frozenColumnsWidth, gridBoundary, left, leftBound, rightBound, rightBoundary, scrollLeft, sidebarBoundary;
left = clientX - $getAbsoluteLeft(this$static.table);
leftBound = castToDouble(getKeyOrNSE($getFirstEntry(this$static.possibleDropPositions)));
rightBound = castToDouble(getKeyOrNSE($getLastEntry(this$static.possibleDropPositions)));
scrollLeft = this$static.this$01.escalator.horizontalScrollbar.scrollPos;
left + scrollLeft < (checkCriticalNotNull(leftBound) , leftBound)?(left = (checkCriticalNotNull(leftBound) , leftBound) - scrollLeft + this$static.autoScrollX):left + scrollLeft > (checkCriticalNotNull(rightBound) , rightBound) && (left = (checkCriticalNotNull(rightBound) , rightBound) - scrollLeft + this$static.autoScrollX);
sidebarBoundary = $getSidebarBoundaryComparedTo(this$static, left);
gridBoundary = getRequiredWidthBoundingClientRectDouble(this$static.this$01.escalator.tableWrapper);
rightBoundary = $wnd.Math.min(sidebarBoundary, gridBoundary);
frozenColumnsWidth = round_int($getFrozenColumnsWidth(this$static.this$01.autoScroller));
left = $wnd.Math.max(frozenColumnsWidth, $wnd.Math.min(left, rightBoundary));
left -= (this$static.dragElement.clientWidth | 0) / 2 | 0;
this$static.dragElement.style['left']
= left + ($clinit_Style$Unit() , 'px');
}
Again, the red highlighted area is the “broken” code. This actually tries to move the dragElement within its parent div, which is the same size as it, resulting in no movement. By changing the above line in the compile JS to:
this$static.dragElement.parentElement.style['left']
= left + ($clinit_Style$Unit() , 'px');
We can instead move around the parent element, resulting in correct movement, this however is simply a temporary fix allowing us to see the corrections that need to be made. In the actual grid.java we should change the element being changed to more permenately fix the problem, however I am not sure if this is a change that will break the non-JS use of this grid and didnt want to make changes until i was sure of this.
Sorry, red highlighting isnt showing, in every code block the final line of code is that which is needing corrected