@@ -21,36 +21,22 @@ export default {
2121 },
2222 inline: {
2323 type: Boolean ,
24- default: false ,
25- coerce: Boolean
24+ default: false
2625 },
2726 offset: {
2827 type: Number ,
2928 default: 0
30- },
31- working: {
32- type: Boolean ,
33- default: true ,
34- coerce: Boolean ,
35- twoWay: true
3629 }
3730 },
3831 data () {
3932 return {
4033 index: 0 ,
41- fetching: false
42- }
43- },
44- watch: {
45- working (value ) {
46- this .scrollContainer [value ? ' addEventListener' : ' removeEventListener' ](' scroll' , this .scroll )
47- if (value) {
48- this .scroll ()
49- }
34+ fetching: false ,
35+ working: true
5036 }
5137 },
5238 methods: {
53- scroll () {
39+ poll () {
5440 if (this .fetching || ! this .working ) {
5541 return
5642 }
@@ -78,7 +64,7 @@ export default {
7864 return
7965 }
8066 if (this .element .closest (' body' )) {
81- this .scroll ()
67+ this .poll ()
8268 }
8369 })
8470 },
@@ -87,29 +73,32 @@ export default {
8773 },
8874 resume () {
8975 this .working = true
76+ this .scrollContainer .addEventListener (' scroll' , this .poll )
77+ this .poll ()
9078 },
9179 stop () {
9280 this .working = false
81+ this .scrollContainer .removeEventListener (' scroll' , this .poll )
9382 }
9483 },
9584 mounted () {
85+ console .log (' mounted' , this .working )
9686 this .$nextTick (() => {
97- this .scroll = Utils .debounce (this .scroll , 50 )
87+ this .poll = Utils .debounce (this .poll , 50 )
9888 this .element = this .$refs .content
9989
100- this .scrollContainer = this .inline ? this .$el : this .element .closest (' .layout-view' )
101- if (! this .scrollContainer ) {
102- this .scrollContainer = window
103- }
90+ console .log (' before scrollcontainer' )
91+ this .scrollContainer = this .inline ? this .$el : Utils .dom .getScrollTarget (this .$el )
92+ console .log (' intermediate scrollcontainer' )
10493 if (this .working ) {
105- this .scrollContainer .addEventListener (' scroll' , this .scroll )
94+ this .scrollContainer .addEventListener (' scroll' , this .poll )
10695 }
10796
108- this .scroll ()
97+ this .poll ()
10998 })
11099 },
111100 beforeDestroy () {
112- this .scrollContainer .removeEventListener (' scroll' , this .scroll )
101+ this .scrollContainer .removeEventListener (' scroll' , this .poll )
113102 }
114103}
115104 </script >
0 commit comments