File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,7 @@ class QueryRenderChild extends MarkdownRenderChild {
91
91
92
92
private renderEventRef : EventRef | undefined ;
93
93
private queryReloadTimeout : NodeJS . Timeout | undefined ;
94
+ private observer : IntersectionObserver | null = null ;
94
95
95
96
private readonly queryResultsRenderer : QueryResultsRenderer ;
96
97
@@ -162,6 +163,28 @@ class QueryRenderChild extends MarkdownRenderChild {
162
163
this . handleMetadataOrFilePathChange ( tFile . path , fileCache ) ;
163
164
} ) ,
164
165
) ;
166
+
167
+ this . setupVisibilityObserver ( ) ;
168
+ }
169
+
170
+ private setupVisibilityObserver ( ) {
171
+ if ( this . observer ) {
172
+ return ;
173
+ }
174
+
175
+ this . observer = new IntersectionObserver ( ( entries ) => {
176
+ for ( const entry of entries ) {
177
+ const visible = entry . isIntersecting && this . containerEl . isShown ( ) ;
178
+ if ( visible ) {
179
+ this . queryResultsRenderer . query . warn ( `[render][observer] Became visible, with this source:
180
+ ---
181
+ ${ this . queryResultsRenderer . query . source }
182
+ ---` ) ;
183
+ }
184
+ }
185
+ } ) ;
186
+
187
+ this . observer . observe ( this . containerEl ) ;
165
188
}
166
189
167
190
private handleMetadataOrFilePathChange ( filePath : string , fileCache : CachedMetadata | null ) {
@@ -189,6 +212,9 @@ class QueryRenderChild extends MarkdownRenderChild {
189
212
if ( this . queryReloadTimeout !== undefined ) {
190
213
clearTimeout ( this . queryReloadTimeout ) ;
191
214
}
215
+
216
+ this . observer ?. disconnect ( ) ;
217
+ this . observer = null ;
192
218
}
193
219
194
220
/**
You can’t perform that action at this time.
0 commit comments