@@ -2347,6 +2347,29 @@ angular.module('ui.grid')
2347
2347
return percentage <= 1 ? percentage : 1 ;
2348
2348
}
2349
2349
2350
+ // Only returns the scroll Y position if the percentage is different from the previous
2351
+ function getScrollY ( scrollPixels , scrollLength , prevScrolltopPercentage ) {
2352
+ var scrollPercentage = getScrollPercentage ( scrollPixels , scrollLength ) ;
2353
+
2354
+ if ( scrollPercentage !== prevScrolltopPercentage ) {
2355
+ return { percentage : getScrollPercentage ( scrollPixels , scrollLength ) } ;
2356
+ }
2357
+
2358
+ return undefined ;
2359
+ }
2360
+
2361
+ // Only returns the scroll X position if the percentage is different from the previous
2362
+ function getScrollX ( horizScrollPixels , horizScrollLength , prevScrollleftPercentage ) {
2363
+ var horizPercentage = horizScrollPixels / horizScrollLength ;
2364
+ horizPercentage = ( horizPercentage > 1 ) ? 1 : horizPercentage ;
2365
+
2366
+ if ( horizPercentage !== prevScrollleftPercentage ) {
2367
+ return { percentage : horizPercentage } ;
2368
+ }
2369
+
2370
+ return undefined ;
2371
+ }
2372
+
2350
2373
/**
2351
2374
* @ngdoc method
2352
2375
* @methodOf ui.grid.class:Grid
@@ -2421,15 +2444,15 @@ angular.module('ui.grid')
2421
2444
// to get the full position we need
2422
2445
scrollPixels = self . renderContainers . body . prevScrollTop - ( topBound - pixelsToSeeRow ) ;
2423
2446
2424
- scrollEvent . y = { percentage : getScrollPercentage ( scrollPixels , scrollLength ) } ;
2447
+ scrollEvent . y = getScrollY ( scrollPixels , scrollLength , self . renderContainers . body . prevScrolltopPercentage ) ;
2425
2448
}
2426
2449
// 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...
2427
2450
else if ( pixelsToSeeRow > bottomBound ) {
2428
2451
// Get the different between the bottom boundary and the required scroll position and add it to the current scroll position
2429
2452
// to get the full position we need
2430
2453
scrollPixels = pixelsToSeeRow - bottomBound + self . renderContainers . body . prevScrollTop ;
2431
2454
2432
- scrollEvent . y = { percentage : getScrollPercentage ( scrollPixels , scrollLength ) } ;
2455
+ scrollEvent . y = getScrollY ( scrollPixels , scrollLength , self . renderContainers . body . prevScrolltopPercentage ) ;
2433
2456
}
2434
2457
}
2435
2458
@@ -2454,7 +2477,7 @@ angular.module('ui.grid')
2454
2477
// Don't let the pixels required to see the column be less than zero
2455
2478
columnRightEdge = ( columnRightEdge < 0 ) ? 0 : columnRightEdge ;
2456
2479
2457
- var horizScrollPixels , horizPercentage ;
2480
+ var horizScrollPixels ;
2458
2481
2459
2482
// If the scroll position we need to see the column is LESS than the left boundary, i.e. obscured before the left of the self...
2460
2483
if ( columnLeftEdge < leftBound ) {
@@ -2463,9 +2486,7 @@ angular.module('ui.grid')
2463
2486
horizScrollPixels = self . renderContainers . body . prevScrollLeft - ( leftBound - columnLeftEdge ) ;
2464
2487
2465
2488
// Turn the scroll position into a percentage and make it an argument for a scroll event
2466
- horizPercentage = horizScrollPixels / horizScrollLength ;
2467
- horizPercentage = ( horizPercentage > 1 ) ? 1 : horizPercentage ;
2468
- scrollEvent . x = { percentage : horizPercentage } ;
2489
+ scrollEvent . x = getScrollX ( horizScrollPixels , horizScrollLength , self . renderContainers . body . prevScrollleftPercentage ) ;
2469
2490
}
2470
2491
// Otherwise if the scroll position we need to see the column is MORE than the right boundary, i.e. obscured after the right of the self...
2471
2492
else if ( columnRightEdge > rightBound ) {
@@ -2474,9 +2495,7 @@ angular.module('ui.grid')
2474
2495
horizScrollPixels = columnRightEdge - rightBound + self . renderContainers . body . prevScrollLeft ;
2475
2496
2476
2497
// Turn the scroll position into a percentage and make it an argument for a scroll event
2477
- horizPercentage = horizScrollPixels / horizScrollLength ;
2478
- horizPercentage = ( horizPercentage > 1 ) ? 1 : horizPercentage ;
2479
- scrollEvent . x = { percentage : horizPercentage } ;
2498
+ scrollEvent . x = getScrollX ( horizScrollPixels , horizScrollLength , self . renderContainers . body . prevScrollleftPercentage ) ;
2480
2499
}
2481
2500
}
2482
2501
0 commit comments