File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -323,6 +323,40 @@ $(document).ready(function () {
323
323
}
324
324
} ) ;
325
325
326
+ $ ( document ) . ready ( function ( ) {
327
+ // set up automatic switching of code carousel
328
+ $ ( ".code-carousel" ) . each ( function ( ) {
329
+ var carousel = this ;
330
+ var inputs = [ ] ;
331
+ $ ( carousel ) . children ( "input.code-carousel_control" ) . each ( function ( ) {
332
+ inputs . push ( this ) ;
333
+ } ) ;
334
+
335
+ // if there is more than one section, set up automatic switching
336
+ if ( inputs . length > 1 ) {
337
+
338
+ var cancelled = false ;
339
+
340
+ var index = inputs . findIndex ( input => input . checked ) ;
341
+
342
+ // switch every 8 seconds while the page is visible and not cancelled
343
+ const intervalHandle = setInterval ( ( ) => {
344
+ if ( ! document . hidden && ! cancelled ) {
345
+ const nextIndex = ( index + 1 ) % inputs . length ;
346
+ inputs [ nextIndex ] . checked = true ;
347
+ index = nextIndex ;
348
+ }
349
+ } , 8000 ) ;
350
+
351
+ carousel . addEventListener ( "click" , function cancelTicker ( ) {
352
+ carousel . removeEventListener ( "click" , cancelTicker ) ;
353
+ cancelled = true ;
354
+ clearInterval ( intervalHandle ) ;
355
+ } ) ;
356
+ }
357
+ } ) ;
358
+ } ) ;
359
+
326
360
var image = { width : 1680 , height : 1100 } ;
327
361
var target = { x : 1028 , y : 290 } ;
328
362
You can’t perform that action at this time.
0 commit comments