File tree Expand file tree Collapse file tree 1 file changed +27
-2
lines changed Expand file tree Collapse file tree 1 file changed +27
-2
lines changed Original file line number Diff line number Diff line change 5
5
<i :class =" spinnerType" ></i >
6
6
</slot >
7
7
</div >
8
- <div class =" infinite-status-prompt" v-show =" !isLoading && isComplete && isFirstLoad " >
8
+ <div class =" infinite-status-prompt" v-show =" isNoResults " >
9
9
<slot name =" no-results" >No results :(</slot >
10
10
</div >
11
- <div class =" infinite-status-prompt" v-show =" !isLoading && isComplete && !isFirstLoad " >
11
+ <div class =" infinite-status-prompt" v-show =" isNoMore " >
12
12
<slot name =" no-more" >No more data :)</slot >
13
13
</div >
14
14
</div >
78
78
spinnerType () {
79
79
return spinnerMapping[this .spinner ] || spinnerMapping .default ;
80
80
},
81
+ isNoResults: {
82
+ cache: false , // disable cache to fix the problem of get slot text delay
83
+ get () {
84
+ const noResultsSlot = this .$slots [' no-results' ];
85
+ const isBlankNoResultsSlot = (noResultsSlot && noResultsSlot[0 ].elm && noResultsSlot[0 ].elm .textContent === ' ' );
86
+
87
+ return ! this .isLoading && this .isComplete && this .isFirstLoad && ! isBlankNoResultsSlot;
88
+ },
89
+ },
90
+ isNoMore: {
91
+ cache: false , // disable cache to fix the problem of get slot text delay
92
+ get () {
93
+ const noMoreSlot = this .$slots [' no-more' ];
94
+ const isBlankNoMoreSlot = (noMoreSlot && noMoreSlot[0 ].elm && noMoreSlot[0 ].elm .textContent === ' ' );
95
+
96
+ return ! this .isLoading && this .isComplete && ! this .isFirstLoad && ! isBlankNoMoreSlot;
97
+ },
98
+ },
81
99
},
82
100
props: {
83
101
distance: {
109
127
this .$nextTick (this .attemptLoad );
110
128
}
111
129
});
130
+
112
131
this .$on (' $InfiniteLoading:complete' , () => {
113
132
this .isLoading = false ;
114
133
this .isComplete = true ;
134
+
135
+ // force re-complation computed properties to fix the problem of get slot text delay
136
+ this .$nextTick (() => {
137
+ this .$forceUpdate ();
138
+ });
115
139
this .scrollParent .removeEventListener (' scroll' , this .scrollHandler );
116
140
});
141
+
117
142
this .$on (' $InfiniteLoading:reset' , () => {
118
143
this .isLoading = false ;
119
144
this .isComplete = false ;
You can’t perform that action at this time.
0 commit comments