Mercurial > hg > Members > anatofuz > slideshow-s6cr
view s6/js/jquery.slideshow.autoplay.js @ 1:05d802167c0c
Apply cr-style from Members/kaito/slides
author | Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 21 Dec 2015 22:13:17 +0900 |
parents | |
children |
line wrap: on
line source
/*********** * * autoplay addon: * * - use key-a/p/s to toggle autoplay (in projection mode) */ Slideshow.playInit = function() { this.debug( 'calling playInit()' ); this.playInterval = null; } Slideshow.playStart = function() { this.debug( 'calling playStart()' ); if( this.settings.mode == 'autoplay' ) this.playToggle(); } Slideshow.playKeys = function( event, key ) { this.debug( 'calling playKeys()' ); switch( key.which ) { case 65: //a case 80: //p case 83: //s this.playToggle(); break; } } // ------------------------------------------------ Slideshow.playWorker = function() { this.debug( 'calling playWorker()' ); // suspend autoplay in outline view (just slideshow view) if( !this.isProjection ) return; // next slide/step, please var csteps = this.steps[this.snum-1]; // current slide steps array if( !csteps || this.incpos >= csteps.length ) { if( this.snum >= this.smax ) this.goTo( 1 ); // reached end of show? start with 1st slide again (for endless cycle) else this.go(1); } else { this.subgo(1); } } Slideshow.playToggle = function() { this.debug( 'calling playToggle()' ); if( this.playInterval ) { this.debug( 'stopping autoplay' ); clearInterval( this.playInterval ); this.playInterval = null; } else { this.debug( 'starting autoplay' ); this.playInterval = setInterval( $.proxy( Slideshow.playWorker, this), 2000 ); } } // ------------------------------------------------ Slideshow.playAddEvents = function() { $( document ).on( 'slideshow.init', $.proxy( Slideshow.playInit, this )); $( document ).on( 'slideshow.start', $.proxy( Slideshow.playStart, this )); $( document ).on( 'slideshow.keys', $.proxy( Slideshow.playKeys, this )); } Slideshow.playAddEvents();