Skip to content
Snippets Groups Projects
reveal.js 113 KiB
Newer Older
  • Learn to ignore specific revisions
  • 		var startAngle = ( - Math.PI / 2 ) + ( this.progressOffset * ( Math.PI * 2 ) );
    
    
    		this.context.save();
    
    		this.context.clearRect( 0, 0, this.diameter, this.diameter );
    
    
    		// Solid background color
    		this.context.beginPath();
    
    		this.context.arc( x, y, radius + 2, 0, Math.PI * 2, false );
    		this.context.fillStyle = 'rgba( 0, 0, 0, 0.4 )';
    
    		this.context.fill();
    
    		// Draw progress track
    		this.context.beginPath();
    		this.context.arc( x, y, radius, 0, Math.PI * 2, false );
    		this.context.lineWidth = this.thickness;
    		this.context.strokeStyle = '#666';
    		this.context.stroke();
    
    
    		if( this.playing ) {
    			// Draw progress on top of track
    			this.context.beginPath();
    			this.context.arc( x, y, radius, startAngle, endAngle, false );
    			this.context.lineWidth = this.thickness;
    			this.context.strokeStyle = '#fff';
    			this.context.stroke();
    		}
    
    		this.context.translate( x - ( iconSize / 2 ), y - ( iconSize / 2 ) );
    
    		// Draw play/pause icons
    		if( this.playing ) {
    			this.context.fillStyle = '#fff';
    			this.context.fillRect( 0, 0, iconSize / 2 - 2, iconSize );
    			this.context.fillRect( iconSize / 2 + 2, 0, iconSize / 2 - 2, iconSize );
    		}
    		else {
    			this.context.beginPath();
    			this.context.translate( 2, 0 );
    			this.context.moveTo( 0, 0 );
    			this.context.lineTo( iconSize - 2, iconSize / 2 );
    			this.context.lineTo( 0, iconSize );
    			this.context.fillStyle = '#fff';
    			this.context.fill();
    		}
    
    
    		this.context.restore();
    
    	};
    
    
    	Playback.prototype.on = function( type, listener ) {
    		this.canvas.addEventListener( type, listener, false );
    	};
    
    	Playback.prototype.off = function( type, listener ) {
    		this.canvas.removeEventListener( type, listener, false );
    	};
    
    
    	Playback.prototype.destroy = function() {
    
    		this.playing = false;
    
    		if( this.canvas.parentNode ) {
    			this.container.removeChild( this.canvas );
    		}
    
    	};
    
    
    	// --------------------------------------------------------------------//
    	// ------------------------------- API --------------------------------//
    	// --------------------------------------------------------------------//
    
    
    
    	Reveal = {
    
    Hakim El Hattab's avatar
    Hakim El Hattab committed
    		sync: sync,
    
    		// Navigation methods
    		slide: slide,
    		left: navigateLeft,
    		right: navigateRight,
    		up: navigateUp,
    		down: navigateDown,
    		prev: navigatePrev,
    		next: navigateNext,
    
    
    		// Fragment methods
    		navigateFragment: navigateFragment,
    
    		prevFragment: previousFragment,
    		nextFragment: nextFragment,
    
    Hakim El Hattab's avatar
    Hakim El Hattab committed
    		navigateLeft: navigateLeft,
    		navigateRight: navigateRight,
    		navigateUp: navigateUp,
    
    		navigatePrev: navigatePrev,
    		navigateNext: navigateNext,
    
    		// Forces an update in slide layout
    		layout: layout,
    
    
    		// Returns an object with the available routes as booleans (left/right/top/bottom)
    		availableRoutes: availableRoutes,
    
    
    		// Returns an object with the available fragments as booleans (prev/next)
    		availableFragments: availableFragments,
    
    
    		toggleOverview: toggleOverview,
    
    		// Toggles the "black screen" mode on/off
    		togglePause: togglePause,
    
    
    		// Toggles the auto slide mode on/off
    		toggleAutoSlide: toggleAutoSlide,
    
    
    		// State checks
    		isOverview: isOverview,
    		isPaused: isPaused,
    
    		isAutoSliding: isAutoSliding,
    
    		// Adds or removes all internal event listeners (such as keyboard)
    
    		addEventListeners: addEventListeners,
    		removeEventListeners: removeEventListeners,
    
    
    		// Facility for persisting and restoring the presentation state
    		getState: getState,
    		setState: setState,
    
    
    		// Presentation progress on range of 0-1
    		getProgress: getProgress,
    
    
    		// Returns the indices of the current, or specified, slide
    
    Hakim El Hattab's avatar
    Hakim El Hattab committed
    		getTotalSlides: getTotalSlides,
    
    
    		// Returns the slide element at the specified index
    		getSlide: getSlide,
    
    		// Returns the slide background element at the specified index
    		getSlideBackground: getSlideBackground,
    
    		// Returns the previous slide element, may be null
    		getPreviousSlide: function() {
    
    		},
    
    		// Returns the current slide element
    		getCurrentSlide: function() {
    
    		// Returns the current scale of the presentation content
    		getScale: function() {
    			return scale;
    		},
    
    
    		// Returns the current configuration object
    		getConfig: function() {
    			return config;
    		},
    
    
    		// Helper method, retrieves query string as a key/value hash
    		getQueryHash: function() {
    			var query = {};
    
    
    			location.search.replace( /[A-Z0-9]+?=([\w\.%-]*)/gi, function(a) {
    
    				query[ a.split( '=' ).shift() ] = a.split( '=' ).pop();
    			} );
    
    
    			// Basic deserialization
    			for( var i in query ) {
    				var value = query[ i ];
    
    				query[ i ] = deserialize( unescape( value ) );
    
    		// Returns true if we're currently on the first slide
    		isFirstSlide: function() {
    
    fabiano's avatar
    fabiano committed
    			return ( indexh === 0 && indexv === 0 );
    
    		},
    
    		// Returns true if we're currently on the last slide
    		isLastSlide: function() {
    
    			if( currentSlide ) {
    				// Does this slide has next a sibling?
    				if( currentSlide.nextElementSibling ) return false;
    
    				// If it's vertical, does its parent have a next sibling?
    				if( isVerticalSlide( currentSlide ) && currentSlide.parentNode.nextElementSibling ) return false;
    
    				return true;
    
    		// Checks if reveal.js has been loaded and is ready for use
    		isReady: function() {
    			return loaded;
    		},
    
    
    		// Forward event binding to the reveal DOM element
    		addEventListener: function( type, listener, useCapture ) {
    
    hakimel's avatar
    hakimel committed
    			if( 'addEventListener' in window ) {
    				( dom.wrapper || document.querySelector( '.reveal' ) ).addEventListener( type, listener, useCapture );
    			}
    
    		},
    		removeEventListener: function( type, listener, useCapture ) {
    
    hakimel's avatar
    hakimel committed
    			if( 'addEventListener' in window ) {
    				( dom.wrapper || document.querySelector( '.reveal' ) ).removeEventListener( type, listener, useCapture );
    			}
    
    		},
    
    		// Programatically triggers a keyboard event
    		triggerKey: function( keyCode ) {
    			onDocumentKeyDown( { keyCode: keyCode } );
    
    Hakim El Hattab's avatar
    Hakim El Hattab committed
    	};
    
    	return Reveal;
    
    }));