File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -286,11 +286,28 @@ <h1>Multitask Singularity Regression Kriging</h1>
286286}
287287
288288function tick ( ) { idx = ( idx + 1 ) % steps . length ; render ( ) ; }
289- function resetTimer ( ) { if ( timer ) clearInterval ( timer ) ; if ( ! reduceMotion ) timer = setInterval ( tick , 2200 ) ; }
289+ let simInView = true ;
290+ function resetTimer ( ) {
291+ if ( timer ) clearInterval ( timer ) ;
292+ if ( ! reduceMotion && simInView ) timer = setInterval ( tick , 2200 ) ;
293+ }
290294
291295renderNodes ( ) ;
292296render ( ) ;
293297resetTimer ( ) ;
298+
299+ const simObserver = new IntersectionObserver ( ( entries ) => {
300+ entries . forEach ( ( entry ) => {
301+ simInView = entry . isIntersecting ;
302+ if ( simInView ) {
303+ resetTimer ( ) ;
304+ } else if ( timer ) {
305+ clearInterval ( timer ) ;
306+ timer = null ;
307+ }
308+ } ) ;
309+ } , { threshold : 0.15 } ) ;
310+ simObserver . observe ( document . getElementById ( 'sim' ) ) ;
294311</ script >
295312</ body >
296313</ html >
You can’t perform that action at this time.
0 commit comments