File tree Expand file tree Collapse file tree 1 file changed +10
-12
lines changed
packages/core/useInfiniteScroll Expand file tree Collapse file tree 1 file changed +10
-12
lines changed Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ export function useInfiniteScroll<T extends InfiniteScrollElement>(
8585 function checkAndLoad ( ) {
8686 state . measure ( )
8787
88- if ( ! observedElement . value || ! isElementVisible . value || ! canLoad . value )
88+ if ( ! observedElement . value || ! isElementVisible . value || ! canLoad . value || promise . value )
8989 return
9090
9191 const { scrollHeight, clientHeight, scrollWidth, clientWidth } = observedElement . value as HTMLElement
@@ -94,23 +94,21 @@ export function useInfiniteScroll<T extends InfiniteScrollElement>(
9494 : scrollWidth <= clientWidth
9595
9696 if ( state . arrivedState [ direction ] || isNarrower ) {
97- if ( ! promise . value ) {
98- promise . value = Promise . all ( [
99- onLoadMore ( state ) ,
100- new Promise ( resolve => setTimeout ( resolve , interval ) ) ,
101- ] )
102- . finally ( ( ) => {
103- promise . value = null
104- nextTick ( ( ) => checkAndLoad ( ) )
105- } )
106- }
97+ promise . value = Promise . all ( [
98+ onLoadMore ( state ) ,
99+ new Promise ( resolve => setTimeout ( resolve , interval ) ) ,
100+ ] )
101+ . finally ( ( ) => {
102+ promise . value = null
103+ nextTick ( ( ) => checkAndLoad ( ) )
104+ } )
107105 }
108106 }
109107
110108 const stop = watch (
111109 ( ) => [ state . arrivedState [ direction ] , isElementVisible . value , canLoad . value ] ,
112110 checkAndLoad ,
113- { immediate : true } ,
111+ { immediate : true , flush : 'post' } ,
114112 )
115113
116114 tryOnUnmounted ( stop )
You can’t perform that action at this time.
0 commit comments