@@ -6,6 +6,11 @@ import Adapter from './modules/adapter.js';
66
77angular . module ( 'ui.scroll' , [ ] )
88
9+ . service ( 'uiScrollService' , function ( ) {
10+ let instances = 0 ;
11+ this . register = ( ) => instances ++ ;
12+ this . count = ( ) => instances ;
13+ } )
914 . constant ( 'JQLiteExtras' , JQLiteExtras )
1015 . run ( [ 'JQLiteExtras' , ( JQLiteExtras ) =>
1116 ! window . jQuery ? ( new JQLiteExtras ( ) ) . registerFor ( angular . element ) : null
@@ -42,7 +47,8 @@ angular.module('ui.scroll', [])
4247 '$interval' ,
4348 '$q' ,
4449 '$parse' ,
45- function ( console , $injector , $rootScope , $timeout , $interval , $q , $parse ) {
50+ 'uiScrollService' ,
51+ function ( console , $injector , $rootScope , $timeout , $interval , $q , $parse , uiScrollService ) {
4652
4753 return {
4854 require : [ '?^uiScrollViewport' ] ,
@@ -59,6 +65,8 @@ angular.module('ui.scroll', [])
5965 throw new Error ( 'Expected uiScroll in form of \'_item_ in _datasource_\' but got \'' + $attr . uiScroll + '\'' ) ;
6066 }
6167
68+ uiScrollService . register ( ) ;
69+
6270 function parseNumericAttr ( value , defaultValue ) {
6371 const result = $parse ( value ) ( $scope ) ;
6472 return isNaN ( result ) ? defaultValue : result ;
@@ -81,7 +89,7 @@ angular.module('ui.scroll', [])
8189 let ridActual = 0 ; // current data revision id
8290 let pending = [ ] ;
8391
84- const elementRoutines = new ElementRoutines ( $injector , $q ) ;
92+ const elementRoutines = new ElementRoutines ( $injector , $q , uiScrollService ) ;
8593 const buffer = new ScrollBuffer ( elementRoutines , bufferSize , startIndex ) ;
8694 const viewport = new Viewport ( elementRoutines , buffer , element , viewportController , $rootScope , padding ) ;
8795 const adapter = new Adapter ( $scope , $parse , $attr , viewport , buffer , doAdjust , reload ) ;
0 commit comments