@@ -31,6 +31,8 @@ export default class SCROLL_EFFECT_MODULE {
3131 firstDelay : 10 ,
3232 firstDelaySteps : 100 ,
3333
34+ throttleInterval : 50 ,
35+
3436 addClassNameActive : 'is-active' ,
3537
3638 autoStart : true ,
@@ -88,17 +90,21 @@ export default class SCROLL_EFFECT_MODULE {
8890 this . Update ( ) ;
8991 } ) ;
9092
93+ function throttle ( fn , wait ) {
94+ var time = Date . now ( ) ;
95+ return function ( ) {
96+ if ( ( time + wait - Date . now ( ) ) < 0 ) {
97+ fn ( ) ;
98+ time = Date . now ( ) ;
99+ }
100+ } ;
101+ }
102+
91103 // for Scroll-Event
92- let ticking = false ;
93- window . addEventListener ( 'scroll' , ( ) => {
94- if ( ! ticking ) {
95- requestAnimationFrame ( ( ) => {
96- ticking = false ;
97- this . StoreElementStateAtPosList ( 'scroll' ) ;
98- } ) ;
99- ticking = true ;
100- }
101- } , { passive : true } ) ;
104+ window . addEventListener ( 'scroll' , throttle ( function ( ) {
105+ _that . _storeElementStateAtPosList ( 'scroll' ) ;
106+ } , this . config . throttleInterval ) , { passive : true } ) ;
107+
102108 }
103109
104110 CacheDom ( ) {
@@ -165,21 +171,21 @@ export default class SCROLL_EFFECT_MODULE {
165171 this . state . PosList . map ( ( el ) => {
166172
167173 if ( this . config . displayRatio === this . config . displayRatioReverse ) {
168- if ( this . state . NumScrolltop + ( this . NumWindowHeight * this . config . displayRatio ) > el . pos ) {
169- // First count up.
170- if ( method === 'load' ) {
171- el . count ++ ;
172- }
174+ if ( this . state . NumScrolltop + ( this . NumWindowHeight * this . config . displayRatio ) > el . pos ) {
175+ // First count up.
176+ if ( method === 'load' ) {
177+ el . count ++ ;
178+ }
173179
174- // 「active」Set of lists
180+ // 「active」Set of lists
175181 el . active = true ;
176- this . state . PosListFix . push ( el ) ;
177- } else {
182+ this . state . PosListFix . push ( el ) ;
183+ } else {
178184
179- // 「none active」Set of lists
185+ // 「none active」Set of lists
180186 el . active = false ;
181- this . state . PosListNoneFix . push ( el ) ;
182- }
187+ this . state . PosListNoneFix . push ( el ) ;
188+ }
183189 }
184190
185191 if ( this . config . displayRatio !== this . config . displayRatioReverse ) {
0 commit comments