File tree Expand file tree Collapse file tree 1 file changed +12
-15
lines changed Expand file tree Collapse file tree 1 file changed +12
-15
lines changed Original file line number Diff line number Diff line change 44 </div >
55</template >
66<script >
7- let scrollParent;
8- let scrollHandler;
9-
107 /**
118 * get the first scroll parent of an element
129 * @param {DOM} elm the element which find scorll parent
4239 data () {
4340 return {
4441 isLoading: false ,
42+ scrollParent: null ,
43+ scrollHandler: null ,
4544 };
4645 },
4746 props: {
5352 this .$set (' distance' , 100 );
5453 }
5554
56- scrollParent = getScrollParent (this .$el );
55+ this . scrollParent = getScrollParent (this .$el );
5756
58- scrollHandler = function scrollHandlerOriginal () {
59- const currentDistance = getCurrentDistance (scrollParent);
60- if (! this .isLoading ) {
61- if (currentDistance <= this .distance ) {
62- this .isLoading = true ;
63- if (this .onInfinite ) {
64- this .onInfinite .call ();
65- }
57+ this .scrollHandler = function scrollHandlerOriginal () {
58+ const currentDistance = getCurrentDistance (this .scrollParent );
59+ if (! this .isLoading && currentDistance <= this .distance ) {
60+ this .isLoading = true ;
61+ if (this .onInfinite ) {
62+ this .onInfinite .call ();
6663 }
6764 }
6865 }.bind (this );
6966
70- setTimeout (scrollHandler, 1 );
71- scrollParent .addEventListener (' scroll' , scrollHandler);
67+ setTimeout (this . scrollHandler , 1 );
68+ this . scrollParent .addEventListener (' scroll' , this . scrollHandler );
7269 },
7370 events: {
7471 // Hide the loading icon when data was loaded
7774 },
7875 },
7976 destroyed () {
80- scrollParent .removeEventListener (' scroll' , scrollHandler);
77+ this . scrollParent .removeEventListener (' scroll' , this . scrollHandler );
8178 },
8279 };
8380 </script >
You can’t perform that action at this time.
0 commit comments