Skip to content

Commit 944db59

Browse files
committed
Merge pull request #2054 from novice3030/master
RTL support for column resize feature
2 parents c19ffb1 + fc1eac7 commit 944db59

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/features/resize-columns/js/ui-grid-column-resizer.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,14 @@
274274
link: function ($scope, $elm, $attrs, uiGridCtrl) {
275275
var startX = 0,
276276
x = 0,
277-
gridLeft = 0;
277+
gridLeft = 0,
278+
rtlMultiplier = 1;
279+
280+
//when in RTL mode reverse the direction using the rtlMultiplier and change the position to left
281+
if (uiGridCtrl.grid.isRTL()) {
282+
$scope.position = 'left';
283+
rtlMultiplier = -1;
284+
}
278285

279286
if ($scope.position === 'left') {
280287
$elm.addClass('left');
@@ -345,17 +352,17 @@
345352
var xDiff = x - startX;
346353

347354
// Get the width that this mouse would give the column
348-
var newWidth = col.drawnWidth + xDiff;
355+
var newWidth = parseInt(col.drawnWidth + xDiff * rtlMultiplier, 10);
349356

350357
// If the new width would be less than the column's allowably minimum width, don't allow it
351358
if (col.colDef.minWidth && newWidth < col.colDef.minWidth) {
352-
x = x + (col.colDef.minWidth - newWidth);
359+
x = x + (col.colDef.minWidth - newWidth) * rtlMultiplier;
353360
}
354361
else if (!col.colDef.minWidth && columnBounds.minWidth && newWidth < columnBounds.minWidth) {
355362
x = x + (col.colDef.minWidth - newWidth);
356363
}
357364
else if (col.colDef.maxWidth && newWidth > col.colDef.maxWidth) {
358-
x = x + (col.colDef.maxWidth - newWidth);
365+
x = x + (col.colDef.maxWidth - newWidth) * rtlMultiplier;
359366
}
360367

361368
resizeOverlay.css({ left: x + 'px' });
@@ -401,7 +408,7 @@
401408
}
402409

403410
// Get the new width
404-
var newWidth = parseInt(col.drawnWidth + xDiff, 10);
411+
var newWidth = parseInt(col.drawnWidth + xDiff * rtlMultiplier, 10);
405412

406413
// If the new width is less than the minimum width, make it the minimum width
407414
if (col.colDef.minWidth && newWidth < col.colDef.minWidth) {

0 commit comments

Comments
 (0)