Skip to content

Commit 7933c1a

Browse files
committed
fix(ui-grid-body): scrolling with mousewheel works
1 parent 58d3f1f commit 7933c1a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/js/directives/ui-grid-body.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -147,16 +147,19 @@ app.directive('uiGridBody', ['$log', 'GridUtil', function($log, GridUtil) {
147147
// use wheelDeltaY
148148
evt.preventDefault();
149149

150-
$log.debug('evt.wheelDeltaY', evt.wheelDeltaY);
150+
// $log.debug('evt.wheelDeltaY', evt.wheelDeltaY);
151151

152152
var scrollAmount = evt.wheelDeltaY * -1;
153153

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

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

159-
$log.debug('scrollPercentage', scrollPercentage);
162+
// $log.debug('scrollPercentage', scrollPercentage);
160163

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

0 commit comments

Comments
 (0)