Skip to content

Commit 040a5ee

Browse files
committed
Feature[Core] Viewport's native scrollbars are now used instead of a separate div containing a scrollbar. results in better positioning of scrollbar and eliminates scrollbar positioning calculations
1 parent d9b2314 commit 040a5ee

File tree

7 files changed

+61
-10
lines changed

7 files changed

+61
-10
lines changed

src/js/core/directives/ui-grid-native-scrollbar.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,8 @@
282282
}
283283
}
284284

285-
var gridScrollDereg = $scope.$on(uiGridConstants.events.GRID_SCROLL, gridScroll);
286-
$scope.$on('$destroy', gridScrollDereg);
285+
// var gridScrollDereg = $scope.$on(uiGridConstants.events.GRID_SCROLL, gridScroll);
286+
// $scope.$on('$destroy', gridScrollDereg);
287287

288288

289289

src/js/core/directives/ui-grid-render-container.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@
6868
$elm.addClass('ui-grid-render-container-' + $scope.containerId);
6969

7070
// Bind to left/right-scroll events
71-
var scrollUnbinder;
71+
var scrollUnbinder = function() {};
7272
if ($scope.bindScrollHorizontal || $scope.bindScrollVertical) {
73-
scrollUnbinder = $scope.$on(uiGridConstants.events.GRID_SCROLL, scrollHandler);
73+
//scrollUnbinder = $scope.$on(uiGridConstants.events.GRID_SCROLL, scrollHandler);
7474
}
7575

7676
function scrollHandler (evt, args) {
@@ -404,6 +404,7 @@
404404
$scope.rowContainer.visibleRowCache[$scope.rowContainer.currentTopRow].height;
405405

406406
// return { 'margin-top': hiddenRowWidth + 'px' };
407+
//gridUtil.logDebug('margin-top ' + hiddenRowWidth );
407408
styles['margin-top'] = hiddenRowWidth + 'px';
408409
}
409410
}

src/js/core/factories/Grid.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,7 +1364,7 @@ angular.module('ui.grid')
13641364

13651365
viewPortHeight = viewPortHeight + adjustment.height;
13661366

1367-
// gridUtil.logDebug('viewPortHeight', viewPortHeight);
1367+
//gridUtil.logDebug('viewPortHeight', viewPortHeight);
13681368

13691369
return viewPortHeight;
13701370
};
@@ -1382,7 +1382,7 @@ angular.module('ui.grid')
13821382

13831383
viewPortWidth = viewPortWidth + adjustment.width;
13841384

1385-
// gridUtil.logDebug('getviewPortWidth', viewPortWidth);
1385+
//gridUtil.logDebug('getviewPortWidth', viewPortWidth);
13861386

13871387
return viewPortWidth;
13881388
};
@@ -1799,6 +1799,28 @@ angular.module('ui.grid')
17991799
}
18001800
};
18011801

1802+
/**
1803+
* @ngdoc function
1804+
* @name hasLeftContainerColumns
1805+
* @methodOf ui.grid.class:Grid
1806+
* @description returns true if leftContainer has columns
1807+
*/
1808+
Grid.prototype.hasLeftContainerColumns = function () {
1809+
return this.hasLeftContainer() && this.renderContainers.left.renderedColumns.length > 0;
1810+
};
1811+
1812+
/**
1813+
* @ngdoc function
1814+
* @name hasRightContainerColumns
1815+
* @methodOf ui.grid.class:Grid
1816+
* @description returns true if rightContainer has columns
1817+
*/
1818+
Grid.prototype.hasRightContainerColumns = function () {
1819+
return this.hasRightContainer() && this.renderContainers.right.renderedColumns.length > 0;
1820+
};
1821+
1822+
1823+
18021824

18031825
// Blatantly stolen from Angular as it isn't exposed (yet? 2.0?)
18041826
function RowHashMap() {}

src/js/core/factories/GridRenderContainer.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,34 @@ angular.module('ui.grid')
687687
this.columnStyles = ret;
688688
};
689689

690+
GridRenderContainer.prototype.getViewPortStyle = function () {
691+
var self = this;
692+
var styles = {};
693+
694+
if (self.name === 'body') {
695+
styles['overflow-x'] = 'scroll';
696+
if (self.grid.hasRightContainerColumns()) {
697+
styles['overflow-y'] = 'hidden';
698+
}
699+
else {
700+
styles['overflow-y'] = 'scroll';
701+
}
702+
}
703+
else if (self.name === 'left') {
704+
styles['overflow-x'] = 'hidden';
705+
styles['overflow-y'] = 'hidden';
706+
}
707+
else {
708+
styles['overflow-x'] = 'hidden';
709+
styles['overflow-y'] = 'scroll';
710+
}
711+
712+
// if (self.grid.isRTL()) {
713+
714+
return styles;
715+
716+
};
717+
690718
return GridRenderContainer;
691719
}]);
692720

src/less/body.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
// overflow: auto; // TODO(c0bra): turn back on when virtual repeater is hooked up
1616
min-height: 20px;
1717
position: relative;
18-
overflow: hidden;
1918

2019
:focus {
2120
outline: none;
@@ -24,6 +23,7 @@
2423

2524
.ui-grid-canvas {
2625
position: relative;
26+
padding-top:1px; //to prevent canvas from absorbing the 1st rendered row's margin
2727
}
2828

2929
.ui-grid-row {

src/templates/ui-grid/uiGridRenderContainer.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
<div ui-grid-footer ng-if="grid.options.showFooter"></div>
55

66
<!-- native scrolling -->
7-
<div ui-grid-native-scrollbar ng-if="enableVerticalScrollbar" type="vertical"></div>
8-
<div ui-grid-native-scrollbar ng-if="enableHorizontalScrollbar" type="horizontal"></div>
7+
<!--<div ui-grid-native-scrollbar ng-if="enableVerticalScrollbar" type="vertical"></div>-->
8+
<!--<div ui-grid-native-scrollbar ng-if="enableHorizontalScrollbar" type="horizontal"></div>-->
99
</div>

src/templates/ui-grid/uiGridViewport.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="ui-grid-viewport">
1+
<div class="ui-grid-viewport" ng-style="containerCtrl.colContainer.getViewPortStyle()">
22
<div class="ui-grid-canvas">
33
<div ng-repeat="(rowRenderIndex, row) in rowContainer.renderedRows track by $index" class="ui-grid-row" ng-style="containerCtrl.rowStyle(rowRenderIndex)">
44
<div ui-grid-row="row" row-render-index="rowRenderIndex"></div>

0 commit comments

Comments
 (0)