@@ -159,32 +159,6 @@ export default class VirtualList extends React.PureComponent<Props, State> {
159159
160160 private styleCache : StyleCache = { } ;
161161
162- private getRef = ( node : HTMLDivElement ) : void => {
163- this . rootNode = node ;
164- } ;
165-
166- private handleScroll = ( event : UIEvent ) => {
167- const { onScroll } = this . props ;
168- const offset = this . getNodeOffset ( ) ;
169-
170- if (
171- offset < 0 ||
172- this . state . offset === offset ||
173- event . target !== this . rootNode
174- ) {
175- return ;
176- }
177-
178- this . setState ( {
179- offset,
180- scrollChangeReason : SCROLL_CHANGE_REASON . OBSERVED ,
181- } ) ;
182-
183- if ( typeof onScroll === 'function' ) {
184- onScroll ( offset , event ) ;
185- }
186- } ;
187-
188162 componentDidMount ( ) {
189163 const { scrollOffset, scrollToIndex } = this . props ;
190164 this . rootNode . addEventListener ( 'scroll' , this . handleScroll , {
@@ -384,6 +358,32 @@ export default class VirtualList extends React.PureComponent<Props, State> {
384358 ) ;
385359 }
386360
361+ private getRef = ( node : HTMLDivElement ) : void => {
362+ this . rootNode = node ;
363+ } ;
364+
365+ private handleScroll = ( event : UIEvent ) => {
366+ const { onScroll } = this . props ;
367+ const offset = this . getNodeOffset ( ) ;
368+
369+ if (
370+ offset < 0 ||
371+ this . state . offset === offset ||
372+ event . target !== this . rootNode
373+ ) {
374+ return ;
375+ }
376+
377+ this . setState ( {
378+ offset,
379+ scrollChangeReason : SCROLL_CHANGE_REASON . OBSERVED ,
380+ } ) ;
381+
382+ if ( typeof onScroll === 'function' ) {
383+ onScroll ( offset , event ) ;
384+ }
385+ } ;
386+
387387 private getNodeOffset ( ) {
388388 const { scrollDirection = DIRECTION . VERTICAL } = this . props ;
389389
0 commit comments