@@ -2339,6 +2339,14 @@ angular.module('ui.grid')
2339
2339
return this . hasRightContainer ( ) && this . renderContainers . right . renderedColumns . length > 0 ;
2340
2340
} ;
2341
2341
2342
+ // Turn the scroll position into a percentage and make it an argument for a scroll event
2343
+ function getScrollPercentage ( scrollPixels , scrollLength ) {
2344
+ var percentage = scrollPixels / scrollLength ;
2345
+
2346
+ // if the percentage is greater than 1, set it to 1
2347
+ return percentage <= 1 ? percentage : 1 ;
2348
+ }
2349
+
2342
2350
/**
2343
2351
* @ngdoc method
2344
2352
* @methodOf ui.grid.class:Grid
@@ -2405,31 +2413,23 @@ angular.module('ui.grid')
2405
2413
// Don't let the pixels required to see the row be less than zero
2406
2414
pixelsToSeeRow = ( pixelsToSeeRow < 0 ) ? 0 : pixelsToSeeRow ;
2407
2415
2408
- var scrollPixels , percentage ;
2416
+ var scrollPixels ;
2409
2417
2410
2418
// If the scroll position we need to see the row is LESS than the top boundary, i.e. obscured above the top of the self...
2411
2419
if ( pixelsToSeeRow < topBound ) {
2412
2420
// Get the different between the top boundary and the required scroll position and subtract it from the current scroll position\
2413
2421
// to get the full position we need
2414
2422
scrollPixels = self . renderContainers . body . prevScrollTop - ( topBound - pixelsToSeeRow ) ;
2415
2423
2416
- // Turn the scroll position into a percentage and make it an argument for a scroll event
2417
- percentage = scrollPixels / scrollLength ;
2418
- if ( percentage <= 1 ) {
2419
- scrollEvent . y = { percentage : percentage } ;
2420
- }
2424
+ scrollEvent . y = { percentage : getScrollPercentage ( scrollPixels , scrollLength ) } ;
2421
2425
}
2422
2426
// Otherwise if the scroll position we need to see the row is MORE than the bottom boundary, i.e. obscured below the bottom of the self...
2423
2427
else if ( pixelsToSeeRow > bottomBound ) {
2424
2428
// Get the different between the bottom boundary and the required scroll position and add it to the current scroll position
2425
2429
// to get the full position we need
2426
2430
scrollPixels = pixelsToSeeRow - bottomBound + self . renderContainers . body . prevScrollTop ;
2427
2431
2428
- // Turn the scroll position into a percentage and make it an argument for a scroll event
2429
- percentage = scrollPixels / scrollLength ;
2430
- if ( percentage <= 1 ) {
2431
- scrollEvent . y = { percentage : percentage } ;
2432
- }
2432
+ scrollEvent . y = { percentage : getScrollPercentage ( scrollPixels , scrollLength ) } ;
2433
2433
}
2434
2434
}
2435
2435
0 commit comments