浏览代码

allow reveal.js instances to be created with only options

Hakim El Hattab 5 年之前
父节点
当前提交
d03fc04f61
共有 3 个文件被更改,包括 7 次插入6 次删除
  1. 1 1
      demo.html
  2. 0 0
      dist/reveal.min.js
  3. 6 5
      js/reveal.js

+ 1 - 1
demo.html

@@ -420,7 +420,7 @@ Reveal.on( 'customevent', function() {
 			import Highlight from '/plugin/highlight/highlight.js';
 
 			// More info https://github.com/hakimel/reveal.js#configuration
-			let deck = new Reveal( document.querySelector( '.reveal' ), {
+			let deck = new Reveal({
 				controls: true,
 				progress: true,
 				center: true,

文件差异内容过多而无法显示
+ 0 - 0
dist/reveal.min.js


+ 6 - 5
js/reveal.js

@@ -41,6 +41,12 @@ import {
  */
 export default function( revealElement, options ) {
 
+	// Support initialization with only options
+	if( arguments.length === 1 ) {
+		options = arguments[0];
+		revealElement = document.querySelector( '.reveal' );
+	}
+
 	const Reveal = {};
 
 	// The reveal.js version
@@ -117,11 +123,6 @@ export default function( revealElement, options ) {
 	 */
 	function initialize() {
 
-		if( !revealElement ) {
-			console.warn( 'reveal.js can not initialize without a valid .reveal element.' );
-			return;
-		}
-
 		// Cache references to key DOM elements
 		dom.wrapper = revealElement;
 		dom.slides = revealElement.querySelector( '.slides' );

部分文件因为文件数量过多而无法显示