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 4
4
</div >
5
5
</template >
6
6
<script >
7
- let scrollParent;
8
- let scrollHandler;
9
-
10
7
/**
11
8
* get the first scroll parent of an element
12
9
* @param {DOM} elm the element which find scorll parent
42
39
data () {
43
40
return {
44
41
isLoading: false ,
42
+ scrollParent: null ,
43
+ scrollHandler: null ,
45
44
};
46
45
},
47
46
props: {
53
52
this .$set (' distance' , 100 );
54
53
}
55
54
56
- scrollParent = getScrollParent (this .$el );
55
+ this . scrollParent = getScrollParent (this .$el );
57
56
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 ();
66
63
}
67
64
}
68
65
}.bind (this );
69
66
70
- setTimeout (scrollHandler, 1 );
71
- scrollParent .addEventListener (' scroll' , scrollHandler);
67
+ setTimeout (this . scrollHandler , 1 );
68
+ this . scrollParent .addEventListener (' scroll' , this . scrollHandler );
72
69
},
73
70
events: {
74
71
// Hide the loading icon when data was loaded
77
74
},
78
75
},
79
76
destroyed () {
80
- scrollParent .removeEventListener (' scroll' , scrollHandler);
77
+ this . scrollParent .removeEventListener (' scroll' , this . scrollHandler );
81
78
},
82
79
};
83
80
</script >
You can’t perform that action at this time.
0 commit comments