Procházet zdrojové kódy

added support for looped presentations

Hakim El Hattab před 14 roky
rodič
revize
cde5362db3
4 změnil soubory, kde provedl 32 přidání a 9 odebrání
  1. 4 0
      README.md
  2. 3 0
      index.html
  3. 25 9
      js/reveal.js
  4. 0 0
      js/reveal.min.js

+ 4 - 0
README.md

@@ -58,6 +58,9 @@ Reveal.initialize({
 	// If true; each slide will be pushed to the browser history
 	history: true,
 
+	// Loops the presentation, defaults to false
+	loop: false,
+
 	// Flags if mouse wheel navigation should be enabled
 	mouseWheel: true,
 
@@ -98,6 +101,7 @@ document.addEventListener( 'someState', function() {
 
 #### 1.3 (master)
 - Revised keyboard shortcuts, including ESC for overview, N for next, P for previous. Thanks [mahemoff](https://github.com/mahemoff)
+- Added support for looped presentations via config
 
 #### 1.2
 

+ 3 - 0
index.html

@@ -260,6 +260,9 @@
 				// If true; each slide will be pushed to the browser history
 				history: true,
 
+				// Loops the presentation, defaults to false
+				loop: false,
+
 				// Flags if mouse wheel navigation should be enabled
 				mouseWheel: true,
 

+ 25 - 9
js/reveal.js

@@ -19,10 +19,11 @@ var Reveal = (function(){
 			controls: false,
 			progress: false,
 			history: false,
-			transition: 'default',
-			theme: 'default',
+			loop: false,
 			mouseWheel: true,
-			rollingLinks: true
+			rollingLinks: true,
+			transition: 'default',
+			theme: 'default'
 		},
 
 		// Slides may hold a data-state attribute which we pick up and apply 
@@ -406,19 +407,34 @@ var Reveal = (function(){
 		
 		// Select all slides and convert the NodeList result to
 		// an array
-		var slides = Array.prototype.slice.call( document.querySelectorAll( selector ) );
+		var slides = Array.prototype.slice.call( document.querySelectorAll( selector ) ),
+			slidesLength = slides.length;
 		
-		if( slides.length ) {
-			// Enforce max and minimum index bounds
-			index = Math.max(Math.min(index, slides.length - 1), 0);
+		if( slidesLength ) {
 
-			for( var i = 0; i < slides.length; i++ ) {
+			// Should the index loop?
+			if( config.loop ) {
+				index %= slidesLength;
+
+				if( index < 0 ) {
+					index = slidesLength + index;
+				}
+			}
+			
+			// Enforce max and minimum index bounds
+			index = Math.max( Math.min( index, slidesLength - 1 ), 0 );
+			
+			for( var i = 0; i < slidesLength; i++ ) {
 				var slide = slides[i];
 
 				// Optimization; hide all slides that are three or more steps 
 				// away from the present slide
 				if( overviewIsActive() === false ) {
-					slide.style.display = Math.abs( index - i ) > 3 ? 'none' : 'block';
+					// The distance loops so that it measures 1 between the first
+					// and last slides
+					var distance = Math.abs( ( index - i ) % ( slidesLength - 3 ) ) || 0;
+
+					slide.style.display = distance > 3 ? 'none' : 'block';
 				}
 
 				slides[i].classList.remove( 'past' );

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
js/reveal.min.js


Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů

PANIC: session(release): write data/sessions/e/c/ecd709503c8904e0: no space left on device

PANIC

session(release): write data/sessions/e/c/ecd709503c8904e0: no space left on device
/my/cache/.heroku/go/go-path/pkg/mod/github.com/go-macaron/session@v1.0.3/session.go:204 (0xb13e07)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/context.go:80 (0x967b75)
/my/cache/.heroku/go/go-path/pkg/mod/github.com/go-macaron/inject@v0.0.0-20200308113650-138e5925c53b/inject.go:157 (0x9512ee)
/my/cache/.heroku/go/go-path/pkg/mod/github.com/go-macaron/inject@v0.0.0-20200308113650-138e5925c53b/inject.go:135 (0x951205)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/context.go:124 (0x967cc4)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/context.go:114 (0x967bf6)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/recovery.go:161 (0x15baec4)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/logger.go:40 (0x96b257)
/my/cache/.heroku/go/go-path/pkg/mod/github.com/go-macaron/inject@v0.0.0-20200308113650-138e5925c53b/inject.go:157 (0x9512ee)
/my/cache/.heroku/go/go-path/pkg/mod/github.com/go-macaron/inject@v0.0.0-20200308113650-138e5925c53b/inject.go:135 (0x951205)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/context.go:124 (0x967cc4)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/router.go:187 (0x972959)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/router.go:304 (0x973a01)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/macaron.go:218 (0x96c572)
/my/cache/.heroku/go/go1.26.3/go/src/net/http/server.go:3311 (0x85a5cd)
/my/cache/.heroku/go/go1.26.3/go/src/net/http/server.go:2073 (0x837f6f)
/my/cache/.heroku/go/go1.26.3/go/src/runtime/asm_amd64.s:1771 (0x493380)