Skip to content

Commit

Permalink
fix(scrolling): Fix for #3260 atTop/Bottom/Left/Right needed tweaking
Browse files Browse the repository at this point in the history
  • Loading branch information
swalters committed Apr 21, 2015
1 parent d4a784f commit 89461bc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
20 changes: 9 additions & 11 deletions src/js/core/directives/ui-grid-render-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'use strict';

var module = angular.module('ui.grid');

module.directive('uiGridRenderContainer', ['$timeout', '$document', 'uiGridConstants', 'gridUtil', 'ScrollEvent',
function($timeout, $document, uiGridConstants, gridUtil, ScrollEvent) {
return {
Expand Down Expand Up @@ -45,7 +45,7 @@

var rowContainer = $scope.rowContainer = grid.renderContainers[$scope.rowContainerName];
var colContainer = $scope.colContainer = grid.renderContainers[$scope.colContainerName];

containerCtrl.containerId = $scope.containerId;
containerCtrl.rowContainer = rowContainer;
containerCtrl.colContainer = colContainer;
Expand Down Expand Up @@ -98,10 +98,8 @@
}

// Let the parent container scroll if the grid is already at the top/bottom
if (scrollEvent.atTop(scrollTop) ||
scrollEvent.atBottom(scrollTop) ||
scrollEvent.atLeft(scrollLeft) ||
scrollEvent.atRight(scrollLeft)) {
if ((event.deltaY !== 0 && (scrollEvent.atTop(scrollTop) || scrollEvent.atBottom(scrollTop))) ||
(event.deltaX !== 0 && (scrollEvent.atLeft(scrollLeft) || scrollEvent.atRight(scrollLeft)))) {
//parent controller scrolls
}
else {
Expand All @@ -118,7 +116,7 @@
$elm.unbind(eventName);
});
});

// TODO(c0bra): Handle resizing the inner canvas based on the number of elements
function update() {
var ret = '';
Expand All @@ -137,7 +135,7 @@

var headerViewportWidth = colContainer.getHeaderViewportWidth();
var footerViewportWidth = colContainer.getHeaderViewportWidth();

// Set canvas dimensions
ret += '\n .grid' + uiGridCtrl.grid.id + ' .ui-grid-render-container-' + $scope.containerId + ' .ui-grid-canvas { width: ' + canvasWidth + 'px; height: ' + canvasHeight + 'px; }';

Expand All @@ -146,7 +144,7 @@
if (renderContainer.explicitHeaderCanvasHeight) {
ret += '\n .grid' + uiGridCtrl.grid.id + ' .ui-grid-render-container-' + $scope.containerId + ' .ui-grid-header-canvas { height: ' + renderContainer.explicitHeaderCanvasHeight + 'px; }';
}

ret += '\n .grid' + uiGridCtrl.grid.id + ' .ui-grid-render-container-' + $scope.containerId + ' .ui-grid-viewport { width: ' + viewportWidth + 'px; height: ' + viewportHeight + 'px; }';
ret += '\n .grid' + uiGridCtrl.grid.id + ' .ui-grid-render-container-' + $scope.containerId + ' .ui-grid-header-viewport { width: ' + headerViewportWidth + 'px; }';

Expand All @@ -155,7 +153,7 @@

return ret;
}

uiGridCtrl.grid.registerStyleComputation({
priority: 6,
func: update
Expand All @@ -168,7 +166,7 @@
}]);

module.controller('uiGridRenderContainer', ['$scope', 'gridUtil', function ($scope, gridUtil) {

}]);

})();
6 changes: 3 additions & 3 deletions src/js/core/factories/ScrollEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,15 @@
};

ScrollEvent.prototype.atTop = function(scrollTop) {
return (this.y && this.y.percentage < 1 && scrollTop === 0);
return (this.y && this.y.percentage === 0 && scrollTop === 0);
};

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

ScrollEvent.prototype.atLeft = function(scrollLeft) {
return (this.x && this.x.percentage < 1 && scrollLeft === 0);
return (this.x && this.x.percentage === 0 && scrollLeft === 0);
};

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



})();
})();

0 comments on commit 89461bc

Please sign in to comment.