Skip to content

Commit c36be95

Browse files
Portugal, Marcelomportuga
Portugal, Marcelo
authored andcommitted
fix(GridRenderContainer): Fixing scrollbar styles.
After reading over the comments by @cwalther on issue #6474, I decided to revert some of the changes done in commit 21819c5. fix #6292, fix #6474, fix #6484
1 parent 9cf6450 commit c36be95

File tree

2 files changed

+16
-26
lines changed

2 files changed

+16
-26
lines changed

src/js/core/factories/GridRenderContainer.js

+11-21
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ angular.module('ui.grid')
4141
self.prevScrollleftPercentage = 0;
4242
self.prevColumnScrollIndex = 0;
4343

44-
self.columnStyles = "";
44+
self.columnStyles = '';
4545

4646
self.viewportAdjusters = [];
4747

@@ -127,7 +127,7 @@ angular.module('ui.grid')
127127

128128
var min = 0;
129129
var totalWidth = 0;
130-
// self.columns.forEach(function(col, i) {
130+
131131
for (var i = 0; i < self.visibleColumnCache.length; i++) {
132132
var col = self.visibleColumnCache[i];
133133

@@ -285,7 +285,7 @@ angular.module('ui.grid')
285285

286286
var oldCanvasHeight = self.$$canvasHeight;
287287

288-
self.$$canvasHeight = 0;
288+
self.$$canvasHeight = 0;
289289

290290
self.visibleRowCache.forEach(function(row){
291291
self.$$canvasHeight += row.height;
@@ -310,9 +310,7 @@ angular.module('ui.grid')
310310
GridRenderContainer.prototype.getCanvasWidth = function getCanvasWidth() {
311311
var self = this;
312312

313-
var ret = self.canvasWidth;
314-
315-
return ret;
313+
return self.canvasWidth;
316314
};
317315

318316
GridRenderContainer.prototype.setRenderedRows = function setRenderedRows(newRows) {
@@ -372,7 +370,6 @@ angular.module('ui.grid')
372370
var horizScrollPercentage = -1;
373371

374372
// Handle RTL here
375-
376373
if (newScrollLeft !== this.prevScrollLeft) {
377374
var xDiff = newScrollLeft - this.prevScrollLeft;
378375

@@ -463,11 +460,9 @@ angular.module('ui.grid')
463460
return;
464461
}
465462
}
466-
var rangeStart = {};
467-
var rangeEnd = {};
468463

469-
rangeStart = Math.max(0, rowIndex - self.grid.options.excessRows);
470-
rangeEnd = Math.min(rowCache.length, rowIndex + minRows + self.grid.options.excessRows);
464+
var rangeStart = Math.max(0, rowIndex - self.grid.options.excessRows);
465+
var rangeEnd = Math.min(rowCache.length, rowIndex + minRows + self.grid.options.excessRows);
471466

472467
newRange = [rangeStart, rangeEnd];
473468
}
@@ -620,12 +615,12 @@ angular.module('ui.grid')
620615
// get all the columns across all render containers, we have to calculate them all or one render container
621616
// could consume the whole viewport
622617
var columnCache = [];
623-
angular.forEach(self.grid.renderContainers, function (container, name) {
618+
angular.forEach(self.grid.renderContainers, function (container) {
624619
columnCache = columnCache.concat(container.visibleColumnCache);
625620
});
626621

627622
// look at each column, process any manual values or %, put the * into an array to look at later
628-
columnCache.forEach(function (column, i) {
623+
columnCache.forEach(function (column) {
629624
var width = 0;
630625
// Skip hidden columns
631626
if (!column.visible) { return; }
@@ -645,7 +640,7 @@ angular.module('ui.grid')
645640
column.drawnWidth = width;
646641

647642
fixedNumberArray.push(column);
648-
} else if (gridUtil.endsWith(column.width, "%")) {
643+
} else if (gridUtil.endsWith(column.width, '%')) {
649644
// percentage width, set to percentage of the viewport
650645
// round down to int - some browsers don't play nice with float maxWidth
651646
var percentageIntegerValue = parseInt(column.width.replace(/%/g, ''), 10);
@@ -674,8 +669,6 @@ angular.module('ui.grid')
674669
// Get the remaining width (available width subtracted by the used widths sum)
675670
var remainingWidth = availableWidth - usedWidthSum;
676671

677-
var i, column, colWidth;
678-
679672
if (asterisksArray.length > 0) {
680673
// the width that each asterisk value would be assigned (this can be negative)
681674
var asteriskVal = remainingWidth / asteriskNum;
@@ -807,13 +800,10 @@ angular.module('ui.grid')
807800
self.hasVScrollbar = !self.grid.isRTL() ? self.grid.options.enableVerticalScrollbar !== uiGridConstants.scrollbars.NEVER : false;
808801
}
809802

810-
styles['overflow-x'] = self.hasHScrollbar ? 'auto' : 'hidden';
811-
styles['overflow-y'] = self.hasVScrollbar ? 'auto' : 'hidden';
812-
803+
styles['overflow-x'] = self.hasHScrollbar ? 'scroll' : 'hidden';
804+
styles['overflow-y'] = self.hasVScrollbar ? 'scroll' : 'hidden';
813805

814806
return styles;
815-
816-
817807
};
818808

819809
return GridRenderContainer;

test/unit/core/factories/GridRenderContainer.spec.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,19 @@ describe('GridRenderContainer factory', function() {
4242

4343
it('should have a vert and horiz scrollbar on body', function() {
4444
r.name = 'body';
45-
expect(r.getViewportStyle()).toEqual({'overflow-x': 'auto', 'overflow-y': 'auto'});
45+
expect(r.getViewportStyle()).toEqual({'overflow-x': 'scroll', 'overflow-y': 'scroll'});
4646
});
4747

4848
it('should have a vert only', function() {
4949
r.name = 'body';
5050
grid.options.enableVerticalScrollbar = uiGridConstants.scrollbars.NEVER;
51-
expect(r.getViewportStyle()).toEqual({'overflow-x': 'auto', 'overflow-y': 'hidden'});
51+
expect(r.getViewportStyle()).toEqual({'overflow-x': 'scroll', 'overflow-y': 'hidden'});
5252
});
5353

5454
it('should have a horiz only', function() {
5555
r.name = 'body';
5656
grid.options.enableHorizontalScrollbar = uiGridConstants.scrollbars.NEVER;
57-
expect(r.getViewportStyle()).toEqual({'overflow-x': 'hidden', 'overflow-y': 'auto'});
57+
expect(r.getViewportStyle()).toEqual({'overflow-x': 'hidden', 'overflow-y': 'scroll'});
5858
});
5959

6060
it('left should have a no scrollbar when not rtl', function() {
@@ -64,7 +64,7 @@ describe('GridRenderContainer factory', function() {
6464

6565
it('right should have a vert scrollbar when not rtl', function() {
6666
r.name = 'right';
67-
expect(r.getViewportStyle()).toEqual({'overflow-x': 'hidden', 'overflow-y': 'auto'});
67+
expect(r.getViewportStyle()).toEqual({'overflow-x': 'hidden', 'overflow-y': 'scroll'});
6868
});
6969

7070
it('right should have no scrollbar when configured', function() {
@@ -76,7 +76,7 @@ describe('GridRenderContainer factory', function() {
7676
it('left should have a vert scrollbar when rtl', function() {
7777
r.name = 'left';
7878
grid.rtl = true;
79-
expect(r.getViewportStyle()).toEqual({'overflow-x': 'hidden', 'overflow-y': 'auto'});
79+
expect(r.getViewportStyle()).toEqual({'overflow-x': 'hidden', 'overflow-y': 'scroll'});
8080
});
8181

8282
it('left should have no vert scrollbar when rtl and configured Never', function() {

0 commit comments

Comments
 (0)