@@ -274,7 +274,7 @@ standard javascript anonymous function:
274274 (function ( document, window ) {
275275
276276 // Plugin implementation...
277-
277+
278278 })(document, window);
279279
280280
@@ -288,6 +288,41 @@ An init plugin is the simplest kind of plugin. It simply listens for the
288288the plugin can initialize itself and start doing whatever it does, for example
289289by calling methods in the public api returned by ` impress() ` .
290290
291+ The ` impress:init ` event has the ` div#impress ` element as its ` target ` attribute,
292+ whereas ` event.detail.api ` contains the same object that is returned by calling
293+ ` impress() ` . It is customary to store the api object sent by the event rather than
294+ calling ` impress() ` from the global namespace.
295+
296+ Example:
297+
298+ /**
299+ * Plugin A - An example plugin
300+ *
301+ * Description...
302+ *
303+ * Copyright 2016 Firstname Lastname, email or github handle
304+ * Released under the MIT license.
305+ */
306+ (function ( document, window ) {
307+ var root;
308+ var api;
309+ var lib;
310+
311+ document.addEventListener( "impress:init", function( event ) {
312+ root = event.target;
313+ api = event.detail.api;
314+ lib = api.lib;
315+
316+ // Element attributes starting with "data-", become available under
317+ // element.dataset. In addition hyphenized words become camelCased.
318+ var data = root.dataset;
319+ // Get value of `<div id="impress" data-plugina-foo="...">`
320+ var foo = data.pluginaFoo;
321+ // ...
322+ }
323+ })(document, window);
324+
325+
291326Both [ Navigation] ( navigation/navigation.js ) and [ Autoplay] ( autoplay/autoplay.js )
292327are init plugins.
293328
0 commit comments