From 89461bcbcfdfc527655c398df19555738fa9bd63 Mon Sep 17 00:00:00 2001 From: swalters Date: Tue, 21 Apr 2015 14:04:51 -0500 Subject: [PATCH] fix(scrolling): Fix for #3260 atTop/Bottom/Left/Right needed tweaking --- .../directives/ui-grid-render-container.js | 20 +++++++++---------- src/js/core/factories/ScrollEvent.js | 6 +++--- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/js/core/directives/ui-grid-render-container.js b/src/js/core/directives/ui-grid-render-container.js index f3d882b399..55851e9ade 100644 --- a/src/js/core/directives/ui-grid-render-container.js +++ b/src/js/core/directives/ui-grid-render-container.js @@ -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 { @@ -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; @@ -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 { @@ -118,7 +116,7 @@ $elm.unbind(eventName); }); }); - + // TODO(c0bra): Handle resizing the inner canvas based on the number of elements function update() { var ret = ''; @@ -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; }'; @@ -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; }'; @@ -155,7 +153,7 @@ return ret; } - + uiGridCtrl.grid.registerStyleComputation({ priority: 6, func: update @@ -168,7 +166,7 @@ }]); module.controller('uiGridRenderContainer', ['$scope', 'gridUtil', function ($scope, gridUtil) { - + }]); })(); diff --git a/src/js/core/factories/ScrollEvent.js b/src/js/core/factories/ScrollEvent.js index 6d84ec5374..68f692aa73 100644 --- a/src/js/core/factories/ScrollEvent.js +++ b/src/js/core/factories/ScrollEvent.js @@ -132,7 +132,7 @@ }; 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) { @@ -140,7 +140,7 @@ }; 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) { @@ -160,4 +160,4 @@ -})(); \ No newline at end of file +})();