瀏覽代碼

adjustments to reveal.js initialization flow

Hakim El Hattab 5 年之前
父節點
當前提交
ddbe06eb7e
共有 4 個文件被更改,包括 29 次插入24 次删除
  1. 17 7
      demo.html
  2. 0 0
      dist/reveal.min.js
  3. 11 16
      js/index.js
  4. 1 1
      js/reveal.js

+ 17 - 7
demo.html

@@ -410,13 +410,6 @@ Reveal.addEventListener( 'customevent', function() {
 
 		<script type="module">
 
-			// WIP support for multiple reveal.js instances
-			// window.a = new Reveal(document.querySelector( '.reveal' ), {controls: false});
-			// a.initialize();
-			// window.b = new Reveal(document.querySelector( '.reveal' ), {controls: true});
-			// b.initialize();
-			// console.log(a.getConfig().controls,b.getConfig().controls);
-
 			// More info https://github.com/hakimel/reveal.js#configuration
 			Reveal.initialize({
 				controls: true,
@@ -439,5 +432,22 @@ Reveal.addEventListener( 'customevent', function() {
 
 		</script>
 
+		<!--
+		<script type="module">
+
+			// WIP support for multiple reveal.js instances
+			import Reveal from '/js/reveal.js'
+
+			window.a = new Reveal(document.querySelector( '.reveal' ), {controls: false});
+			a.initialize();
+
+			window.b = new Reveal(document.querySelector( '.reveal' ), {controls: true});
+			b.initialize();
+
+			console.log(a.getConfig().controls,b.getConfig().controls);
+
+		</script>
+		-->
+
 	</body>
 </html>

文件差異過大導致無法顯示
+ 0 - 0
dist/reveal.min.js


+ 11 - 16
js/index.js

@@ -1,21 +1,16 @@
 import Presentation from './reveal.js'
 
-// The Reveal class can be instantiated to run multiple
-// presentations on the same page
-//
-// let rvl = new Reveal( <HTMLElement>, { controls: false } )
-// rvl.initialize()
-// rvl.slide(2)
-window.Reveal = Presentation;
-
-// Simplified way to create a reveal.js instance on
-// a page with only one presentation, makes us backwards
-// compatible with reveal.js pre 4.0
+// Provides a backwards compatible way to initialize
+// reveal.js when there is only one presentation on
+// the page.
 //
 // Reveal.initialize({ controls: false })
-// Revea.slide(2)
-window.Reveal.initialize = options => {
-	window.Reveal = new Presentation( document.querySelector( '.reveal' ), options );
-	window.Reveal.initialize();
-	return new Promise( resolve => window.Reveal.addEventListener( 'ready', resolve ) );
+// Reveal.slide(2)
+window.Reveal = {
+
+	initialize: options => {
+		window.Reveal = new Presentation( document.querySelector( '.reveal' ), options );
+		return window.Reveal.initialize();
+	}
+
 }

+ 1 - 1
js/reveal.js

@@ -153,7 +153,7 @@ export default function( revealElement, options ) {
 		// Load plugins then move on to #start()
 		plugins.load( config.dependencies ).then( start )
 
-		return Reveal;
+		return new Promise( resolve => Reveal.addEventListener( 'ready', resolve ) );
 
 	}
 

部分文件因文件數量過多而無法顯示