Skip to content

Commit

Permalink
few plugin registration tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
hakimel committed Mar 1, 2019
1 parent 4862de2 commit 46f8f86
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions js/reveal.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,24 +519,25 @@
if( typeof s.callback === 'function' ) s.callback();

if( --scriptsToLoad === 0 ) {
loadPlugins();
initPlugins();
}

} );
} );
}
else {
loadPlugins();
initPlugins();
}

}

/**
* Loads all plugins that require preloading.
* Initializes our plugins and waits for them to be ready
* before proceeding.
*/
function loadPlugins() {
function initPlugins() {

var pluginsToLoad = Object.keys( plugins ).length;
var pluginsToInitialize = Object.keys( plugins ).length;

for( var i in plugins ) {

Expand All @@ -546,18 +547,18 @@
// wait for the callback
if( typeof plugin.init === 'function' ) {
plugin.init( function() {
if( --pluginsToLoad === 0 ) {
if( --pluginsToInitialize === 0 ) {
loadAsyncDependencies();
}
} );
}
else {
pluginsToLoad -= 1;
pluginsToInitialize -= 1;
}

}

if( pluginsToLoad === 0 ) {
if( pluginsToInitialize === 0 ) {
loadAsyncDependencies();
}

Expand Down Expand Up @@ -5894,7 +5895,7 @@
addKeyBinding: addKeyBinding,
removeKeyBinding: removeKeyBinding,

// Called by plugins to register/unregister themselves
// Called by plugins to register themselves
registerPlugin: registerPlugin,

// Programatically triggers a keyboard event
Expand Down

0 comments on commit 46f8f86

Please sign in to comment.