Skip to content

Commit ab0dc11

Browse files
committed
fix(move-columns): Fix #3448 - The issue is caused by setting a left 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.
1 parent 13820c0 commit ab0dc11

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

src/features/move-columns/js/column-movable.js

+3-11
Original file line numberDiff line numberDiff line change
@@ -436,16 +436,7 @@
436436
//Left of cloned element should be aligned to original header cell.
437437
movingElm.addClass('movingColumn');
438438
var movingElementStyles = {};
439-
var elmLeft;
440-
if (gridUtil.detectBrowser() === 'safari') {
441-
//Correction for Safari getBoundingClientRect,
442-
//which does not correctly compute when there is an horizontal scroll
443-
elmLeft = $elm[0].offsetLeft + $elm[0].offsetWidth - $elm[0].getBoundingClientRect().width;
444-
}
445-
else {
446-
elmLeft = $elm[0].getBoundingClientRect().left;
447-
}
448-
movingElementStyles.left = (elmLeft - gridLeft) + 'px';
439+
movingElementStyles.left = $elm[0].offsetLeft + 'px';
449440
var gridRight = $scope.grid.element[0].getBoundingClientRect().right;
450441
var elmRight = $elm[0].getBoundingClientRect().right;
451442
if (elmRight > gridRight) {
@@ -475,7 +466,8 @@
475466

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

0 commit comments

Comments
 (0)