Skip to content

Commit

Permalink
fix(move-columns): Fix #3448 - The issue is caused by setting a left …
Browse files Browse the repository at this point in the history
…position to moving element relative to the browser viewport which will not take scroll position into account. By setting left position relative to moving element's parent, the problem will gone.
  • Loading branch information
merlinchen committed Dec 9, 2015
1 parent 13820c0 commit ab0dc11
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/features/move-columns/js/column-movable.js
Expand Up @@ -436,16 +436,7 @@
//Left of cloned element should be aligned to original header cell.
movingElm.addClass('movingColumn');
var movingElementStyles = {};
var elmLeft;
if (gridUtil.detectBrowser() === 'safari') {
//Correction for Safari getBoundingClientRect,
//which does not correctly compute when there is an horizontal scroll
elmLeft = $elm[0].offsetLeft + $elm[0].offsetWidth - $elm[0].getBoundingClientRect().width;
}
else {
elmLeft = $elm[0].getBoundingClientRect().left;
}
movingElementStyles.left = (elmLeft - gridLeft) + 'px';
movingElementStyles.left = $elm[0].offsetLeft + 'px';
var gridRight = $scope.grid.element[0].getBoundingClientRect().right;
var elmRight = $elm[0].getBoundingClientRect().right;
if (elmRight > gridRight) {
Expand Down Expand Up @@ -475,7 +466,8 @@

//Update css of moving column to adjust to new left value or fire scroll in case column has reached edge of grid
if ((currentElmLeft >= gridLeft || changeValue > 0) && (currentElmRight <= rightMoveLimit || changeValue < 0)) {
movingElm.css({visibility: 'visible', 'left': newElementLeft + 'px'});
movingElm.css({visibility: 'visible', 'left': (movingElm[0].offsetLeft +
(newElementLeft < rightMoveLimit ? changeValue : (rightMoveLimit - currentElmLeft))) + 'px'});
}
else if (totalColumnWidth > Math.ceil(uiGridCtrl.grid.gridWidth)) {
changeValue *= 8;
Expand Down

1 comment on commit ab0dc11

@YonatanKra
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not really understand - what does that fix solve?

Please sign in to comment.