Skip to content

Commit 702e1b8

Browse files
committed
Merge pull request #4824 from merlinchen/fix-3448
Fix #3448 Moving a column when the grid has horizontal scroll is broken
2 parents 7a8c608 + ab0dc11 commit 702e1b8

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
@@ -439,16 +439,7 @@
439439
//Left of cloned element should be aligned to original header cell.
440440
movingElm.addClass('movingColumn');
441441
var movingElementStyles = {};
442-
var elmLeft;
443-
if (gridUtil.detectBrowser() === 'safari') {
444-
//Correction for Safari getBoundingClientRect,
445-
//which does not correctly compute when there is an horizontal scroll
446-
elmLeft = $elm[0].offsetLeft + $elm[0].offsetWidth - $elm[0].getBoundingClientRect().width;
447-
}
448-
else {
449-
elmLeft = $elm[0].getBoundingClientRect().left;
450-
}
451-
movingElementStyles.left = (elmLeft - gridLeft) + 'px';
442+
movingElementStyles.left = $elm[0].offsetLeft + 'px';
452443
var gridRight = $scope.grid.element[0].getBoundingClientRect().right;
453444
var elmRight = $elm[0].getBoundingClientRect().right;
454445
if (elmRight > gridRight) {
@@ -478,7 +469,8 @@
478469

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

0 commit comments

Comments
 (0)