소스 검색

add overviewshown and overviewhidden events (closes #298)

hakimel 11 년 전
부모
커밋
d489ec2f9d
3개의 변경된 파일30개의 추가작업 그리고 4개의 파일을 삭제
  1. 9 1
      README.md
  2. 20 2
      js/reveal.js
  3. 1 1
      js/reveal.min.js

+ 9 - 1
README.md

@@ -256,7 +256,15 @@ Reveal.addEventListener( 'fragmenthidden', function( event ) {
 ### Overview mode
 ### Overview mode
 
 
 Press "Esc" key to toggle the overview mode on and off. While you're in this mode, you can still navigate between slides,
 Press "Esc" key to toggle the overview mode on and off. While you're in this mode, you can still navigate between slides,
-as if you were at 1,000 feet above your presentation.
+as if you were at 1,000 feet above your presentation. The overview mode comes with a few API hooks:
+
+```javascript
+Reveal.addEventListener( 'overviewshown', function( event ) { /* ... */ } );
+Reveal.addEventListener( 'overviewhidden', function( event ) { /* ... */ } );
+
+// Toggle the overview mode programmatically
+Reveal.toggleOverview();
+```
 
 
 ### Fullscreen mode
 ### Fullscreen mode
 Just press »F« on your keyboard to show your presentation in fullscreen mode. Press the »ESC« key to exit fullscreen mode.
 Just press »F« on your keyboard to show your presentation in fullscreen mode. Press the »ESC« key to exit fullscreen mode.

+ 20 - 2
js/reveal.js

@@ -622,14 +622,16 @@ var Reveal = (function(){
 		// Only proceed if enabled in config
 		// Only proceed if enabled in config
 		if( config.overview ) {
 		if( config.overview ) {
 
 
+			var wasActive = dom.wrapper.classList.contains( 'overview' );
+
 			dom.wrapper.classList.add( 'overview' );
 			dom.wrapper.classList.add( 'overview' );
 			dom.wrapper.classList.remove( 'exit-overview' );
 			dom.wrapper.classList.remove( 'exit-overview' );
 
 
 			clearTimeout( activateOverviewTimeout );
 			clearTimeout( activateOverviewTimeout );
 			clearTimeout( deactivateOverviewTimeout );
 			clearTimeout( deactivateOverviewTimeout );
 
 
-			// Not the pretties solution, but need to let the overview 
-			// class apply first so that slides are measured accurately 
+			// Not the pretties solution, but need to let the overview
+			// class apply first so that slides are measured accurately
 			// before we can position them
 			// before we can position them
 			activateOverviewTimeout = setTimeout( function(){
 			activateOverviewTimeout = setTimeout( function(){
 
 
@@ -681,6 +683,15 @@ var Reveal = (function(){
 
 
 				layout();
 				layout();
 
 
+				if( !wasActive ) {
+					// Notify observers of the overview showing
+					dispatchEvent( 'overviewshown', {
+						'indexh': indexh,
+						'indexv': indexv,
+						'currentSlide': currentSlide
+					} );
+				}
+
 			}, 10 );
 			}, 10 );
 
 
 		}
 		}
@@ -730,6 +741,13 @@ var Reveal = (function(){
 
 
 			slide( indexh, indexv );
 			slide( indexh, indexv );
 
 
+			// Notify observers of the overview hiding
+			dispatchEvent( 'overviewhidden', {
+				'indexh': indexh,
+				'indexv': indexv,
+				'currentSlide': currentSlide
+			} );
+
 		}
 		}
 	}
 	}
 
 

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1 - 1
js/reveal.min.js


이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.