Skip to content

Commit 89461bc

Browse files
committed
fix(scrolling): Fix for #3260 atTop/Bottom/Left/Right needed tweaking
1 parent d4a784f commit 89461bc

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

Diff for: src/js/core/directives/ui-grid-render-container.js

+9-11
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
'use strict';
33

44
var module = angular.module('ui.grid');
5-
5+
66
module.directive('uiGridRenderContainer', ['$timeout', '$document', 'uiGridConstants', 'gridUtil', 'ScrollEvent',
77
function($timeout, $document, uiGridConstants, gridUtil, ScrollEvent) {
88
return {
@@ -45,7 +45,7 @@
4545

4646
var rowContainer = $scope.rowContainer = grid.renderContainers[$scope.rowContainerName];
4747
var colContainer = $scope.colContainer = grid.renderContainers[$scope.colContainerName];
48-
48+
4949
containerCtrl.containerId = $scope.containerId;
5050
containerCtrl.rowContainer = rowContainer;
5151
containerCtrl.colContainer = colContainer;
@@ -98,10 +98,8 @@
9898
}
9999

100100
// Let the parent container scroll if the grid is already at the top/bottom
101-
if (scrollEvent.atTop(scrollTop) ||
102-
scrollEvent.atBottom(scrollTop) ||
103-
scrollEvent.atLeft(scrollLeft) ||
104-
scrollEvent.atRight(scrollLeft)) {
101+
if ((event.deltaY !== 0 && (scrollEvent.atTop(scrollTop) || scrollEvent.atBottom(scrollTop))) ||
102+
(event.deltaX !== 0 && (scrollEvent.atLeft(scrollLeft) || scrollEvent.atRight(scrollLeft)))) {
105103
//parent controller scrolls
106104
}
107105
else {
@@ -118,7 +116,7 @@
118116
$elm.unbind(eventName);
119117
});
120118
});
121-
119+
122120
// TODO(c0bra): Handle resizing the inner canvas based on the number of elements
123121
function update() {
124122
var ret = '';
@@ -137,7 +135,7 @@
137135

138136
var headerViewportWidth = colContainer.getHeaderViewportWidth();
139137
var footerViewportWidth = colContainer.getHeaderViewportWidth();
140-
138+
141139
// Set canvas dimensions
142140
ret += '\n .grid' + uiGridCtrl.grid.id + ' .ui-grid-render-container-' + $scope.containerId + ' .ui-grid-canvas { width: ' + canvasWidth + 'px; height: ' + canvasHeight + 'px; }';
143141

@@ -146,7 +144,7 @@
146144
if (renderContainer.explicitHeaderCanvasHeight) {
147145
ret += '\n .grid' + uiGridCtrl.grid.id + ' .ui-grid-render-container-' + $scope.containerId + ' .ui-grid-header-canvas { height: ' + renderContainer.explicitHeaderCanvasHeight + 'px; }';
148146
}
149-
147+
150148
ret += '\n .grid' + uiGridCtrl.grid.id + ' .ui-grid-render-container-' + $scope.containerId + ' .ui-grid-viewport { width: ' + viewportWidth + 'px; height: ' + viewportHeight + 'px; }';
151149
ret += '\n .grid' + uiGridCtrl.grid.id + ' .ui-grid-render-container-' + $scope.containerId + ' .ui-grid-header-viewport { width: ' + headerViewportWidth + 'px; }';
152150

@@ -155,7 +153,7 @@
155153

156154
return ret;
157155
}
158-
156+
159157
uiGridCtrl.grid.registerStyleComputation({
160158
priority: 6,
161159
func: update
@@ -168,7 +166,7 @@
168166
}]);
169167

170168
module.controller('uiGridRenderContainer', ['$scope', 'gridUtil', function ($scope, gridUtil) {
171-
169+
172170
}]);
173171

174172
})();

Diff for: src/js/core/factories/ScrollEvent.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,15 @@
132132
};
133133

134134
ScrollEvent.prototype.atTop = function(scrollTop) {
135-
return (this.y && this.y.percentage < 1 && scrollTop === 0);
135+
return (this.y && this.y.percentage === 0 && scrollTop === 0);
136136
};
137137

138138
ScrollEvent.prototype.atBottom = function(scrollTop) {
139139
return (this.y && this.y.percentage === 1 && scrollTop > 0);
140140
};
141141

142142
ScrollEvent.prototype.atLeft = function(scrollLeft) {
143-
return (this.x && this.x.percentage < 1 && scrollLeft === 0);
143+
return (this.x && this.x.percentage === 0 && scrollLeft === 0);
144144
};
145145

146146
ScrollEvent.prototype.atRight = function(scrollLeft) {
@@ -160,4 +160,4 @@
160160

161161

162162

163-
})();
163+
})();

0 commit comments

Comments
 (0)