Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(GridRenderContainer): Fixing scrollbar styles. #6534

Merged
merged 1 commit into from
Jan 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 11 additions & 21 deletions src/js/core/factories/GridRenderContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ angular.module('ui.grid')
self.prevScrollleftPercentage = 0;
self.prevColumnScrollIndex = 0;

self.columnStyles = "";
self.columnStyles = '';

self.viewportAdjusters = [];

Expand Down Expand Up @@ -127,7 +127,7 @@ angular.module('ui.grid')

var min = 0;
var totalWidth = 0;
// self.columns.forEach(function(col, i) {

for (var i = 0; i < self.visibleColumnCache.length; i++) {
var col = self.visibleColumnCache[i];

Expand Down Expand Up @@ -285,7 +285,7 @@ angular.module('ui.grid')

var oldCanvasHeight = self.$$canvasHeight;

self.$$canvasHeight = 0;
self.$$canvasHeight = 0;

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

var ret = self.canvasWidth;

return ret;
return self.canvasWidth;
};

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

// Handle RTL here

if (newScrollLeft !== this.prevScrollLeft) {
var xDiff = newScrollLeft - this.prevScrollLeft;

Expand Down Expand Up @@ -463,11 +460,9 @@ angular.module('ui.grid')
return;
}
}
var rangeStart = {};
var rangeEnd = {};

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

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

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

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

var i, column, colWidth;

if (asterisksArray.length > 0) {
// the width that each asterisk value would be assigned (this can be negative)
var asteriskVal = remainingWidth / asteriskNum;
Expand Down Expand Up @@ -807,13 +800,10 @@ angular.module('ui.grid')
self.hasVScrollbar = !self.grid.isRTL() ? self.grid.options.enableVerticalScrollbar !== uiGridConstants.scrollbars.NEVER : false;
}

styles['overflow-x'] = self.hasHScrollbar ? 'auto' : 'hidden';
styles['overflow-y'] = self.hasVScrollbar ? 'auto' : 'hidden';

styles['overflow-x'] = self.hasHScrollbar ? 'scroll' : 'hidden';
styles['overflow-y'] = self.hasVScrollbar ? 'scroll' : 'hidden';

return styles;


};

return GridRenderContainer;
Expand Down
10 changes: 5 additions & 5 deletions test/unit/core/factories/GridRenderContainer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ describe('GridRenderContainer factory', function() {

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

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

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

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

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

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

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