Skip to content

Commit

Permalink
fix(ui-grid-body): scrolling with mousewheel works
Browse files Browse the repository at this point in the history
  • Loading branch information
c0bra committed Jan 6, 2014
1 parent 58d3f1f commit 7933c1a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/js/directives/ui-grid-body.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,19 @@ app.directive('uiGridBody', ['$log', 'GridUtil', function($log, GridUtil) {
// use wheelDeltaY
evt.preventDefault();

$log.debug('evt.wheelDeltaY', evt.wheelDeltaY);
// $log.debug('evt.wheelDeltaY', evt.wheelDeltaY);

var scrollAmount = evt.wheelDeltaY * -1;

// Get the scroll percentage
var scrollPercentage = (uiGridCtrl.viewport[0].scrollTop + scrollAmount) / (uiGridCtrl.viewport[0].scrollHeight - scope.options.viewportHeight);
// var scrollPercentage = (uiGridCtrl.viewport[0].scrollTop + scrollAmount) / (uiGridCtrl.viewport[0].scrollHeight - scope.options.viewportHeight);
var scrollPercentage = (uiGridCtrl.viewport[0].scrollTop + scrollAmount) / (scope.options.canvasHeight - scope.options.viewportHeight);

// TODO(c0bra): Keep scrollPercentage within the range 0-1.
if (scrollPercentage < 0) { scrollPercentage = 0; }
if (scrollPercentage > 1) { scrollPercentage = 1; }

$log.debug('scrollPercentage', scrollPercentage);
// $log.debug('scrollPercentage', scrollPercentage);

// $log.debug('new scrolltop', uiGridCtrl.canvas[0].scrollTop + scrollAmount);
// uiGridCtrl.canvas[0].scrollTop = uiGridCtrl.canvas[0].scrollTop + scrollAmount;
Expand Down

0 comments on commit 7933c1a

Please sign in to comment.