Skip to content

Commit

Permalink
fix(Column Moving): Abs instead of fixed position
Browse files Browse the repository at this point in the history
Fixed positioning in IE wasn't displaying correctly. This change uses
relative positioning on the header row container, and absolute positioning
on the cloned column header element.

This also prevents having to check for IE when doing the positioning.

Fixes #2894
  • Loading branch information
c0bra committed Apr 27, 2015
1 parent 1625e04 commit 1a83269
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
24 changes: 10 additions & 14 deletions src/features/move-columns/js/column-movable.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@
* - if we are a touchstart then we listen for a touchmove, if we are a mousedown we listen for
* a mousemove (i.e. a drag) before we decide that there's a move underway. If there's never a move,
* and we instead get a mouseup or a touchend, then we just drop out again and do nothing.
*
*
*/
var $contentsElm = angular.element( $elm[0].querySelectorAll('.ui-grid-cell-contents') );

Expand Down Expand Up @@ -281,11 +281,11 @@
$document.on('touchend', upFn);
}
};

var moveFn = function( event ) {
//Disable text selection in Chrome during column move
document.onselectstart = function() { return false; };

moveOccurred = true;

var changeValue = event.pageX - previousMouseX;
Expand All @@ -297,7 +297,7 @@
previousMouseX = event.pageX;
}
};

var upFn = function( event ){
//Re-enable text selection after column move
document.onselectstart = null;
Expand All @@ -307,7 +307,7 @@
movingElm.remove();
elmCloned = false;
}

offAllEvents();
onDownEvents();

Expand Down Expand Up @@ -366,12 +366,12 @@
}
}
};

var onDownEvents = function(){
$contentsElm.on('touchstart', downFn);
$contentsElm.on('mousedown', downFn);
};

var offAllEvents = function() {
$contentsElm.off('touchstart', downFn);
$contentsElm.off('mousedown', downFn);
Expand All @@ -382,7 +382,7 @@
$document.off('mouseup', upFn);
$document.off('touchend', upFn);
};

onDownEvents();


Expand Down Expand Up @@ -429,12 +429,8 @@
var currentElmLeft = movingElm[0].getBoundingClientRect().left - 1;
var currentElmRight = movingElm[0].getBoundingClientRect().right;
var newElementLeft;
if (gridUtil.detectBrowser() === 'ie') {
newElementLeft = currentElmLeft + changeValue;
}
else {
newElementLeft = currentElmLeft - gridLeft + changeValue;
}

newElementLeft = currentElmLeft - gridLeft + changeValue;
newElementLeft = newElementLeft < rightMoveLimit ? newElementLeft : rightMoveLimit;

//Update css of moving column to adjust to new left value or fire scroll in case column has reached edge of grid
Expand Down
6 changes: 3 additions & 3 deletions src/features/move-columns/less/colMovable.less
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
@import '../../../less/variables';

.movingColumn {

position: fixed;
position: absolute;
top: 0;
border: 1px solid @borderColor;
box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.2);

.ui-grid-icon-angle-down {
display: none;
}
}
}
1 change: 1 addition & 0 deletions src/less/header.less
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@

.ui-grid-header-cell-row {
display: table-row;
position: relative
}

.ui-grid-header-cell {
Expand Down

0 comments on commit 1a83269

Please sign in to comment.