Skip to content

Commit

Permalink
Update of fix scroll on top/bottom : add a check if vertical scroll l…
Browse files Browse the repository at this point in the history
…ength is negative, mean 'Let the parent container scroll
  • Loading branch information
Jacquelin committed Jun 2, 2015
1 parent f1140a1 commit 6163555
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/js/core/directives/ui-grid-render-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,10 @@

scrollTop = containerCtrl.viewport[0].scrollTop;

var scrollCount = scrollTop + scrollYAmount;
// Get the scroll percentage
var scrollYPercentage = scrollCount / rowContainer.getVerticalScrollLength();
var scrollYPercentage = (scrollTop + scrollYAmount) / rowContainer.getVerticalScrollLength();

// Keep scrollPercentage within the range 0-1.
if (scrollCount < 0 && rowContainer.getVerticalScrollLength() < 0) { scrollYPercentage = 0; }
if (scrollYPercentage < 0) { scrollYPercentage = 0; }
else if (scrollYPercentage > 1) { scrollYPercentage = 1; }

Expand All @@ -101,7 +99,8 @@
}

// Let the parent container scroll if the grid is already at the top/bottom
if ((event.deltaY !== 0 && (scrollEvent.atTop(scrollTop) || scrollEvent.atBottom(scrollTop))) ||
if (rowContainer.getVerticalScrollLength() < 0 ||
(event.deltaY !== 0 && (scrollEvent.atTop(scrollTop) || scrollEvent.atBottom(scrollTop))) ||
(event.deltaX !== 0 && (scrollEvent.atLeft(scrollLeft) || scrollEvent.atRight(scrollLeft)))) {
//parent controller scrolls
}
Expand Down

0 comments on commit 6163555

Please sign in to comment.