Some more progress on comments

This commit is contained in:
janis
2024-01-16 10:25:35 +01:00
parent 2efd14b392
commit 587be5ee61
2 changed files with 9 additions and 5 deletions

View File

@@ -38,8 +38,7 @@
* This function is used to initialize impress. It calls some prep functions and then loads * This function is used to initialize impress. It calls some prep functions and then loads
* all plugins that are registered. By default, these are the built-in plugins. You can define * all plugins that are registered. By default, these are the built-in plugins. You can define
* which plugins are loaded by passing in an array of plugin-functions into the init function * which plugins are loaded by passing in an array of plugin-functions into the init function
* @param {Array<String>|undefined} [pluginsToLoad] An array of plugins to load when initializing impress. * @param {Array<String>|undefined} [pluginsToLoad] An array of plugins to load when initializing impress. Defaults to the built-in plugins that require explicit initialization.
* Defaults to the built-in plugins.
* @returns {undefined} * @returns {undefined}
*/ */
const init = ( pluginsToLoad?: Array<Function> ): undefined => { const init = ( pluginsToLoad?: Array<Function> ): undefined => {
@@ -48,6 +47,7 @@
toBeLoadedPlugins = pluginsToLoad; toBeLoadedPlugins = pluginsToLoad;
} }
// Let's initialize all plugins that have to be initialized
for ( let plugin in toBeLoadedPlugins ) { for ( let plugin in toBeLoadedPlugins ) {
try { try {
toBeLoadedPlugins[ plugin ](); toBeLoadedPlugins[ plugin ]();
@@ -57,9 +57,11 @@
return; return;
} }
} }
// TODO: Load plugins, check if impress is supported // TODO: Load plugins, check if impress is supported
// Finally, with init done, send out the 'impress:init' event // Finally, with init done, send out the 'impress:init' event.
// All plugins which use this event to initialize will now be initialized
document.dispatchEvent( new Event( 'impress:init' ) ); document.dispatchEvent( new Event( 'impress:init' ) );
}; };

View File

@@ -22,7 +22,9 @@
</div> </div>
</div> </div>
<script src="/built/impress.js"/> <script src="/built/impress.js"></script>
<script>impress().init()</script> <script>
impress().init();
</script>
</body> </body>
</html> </html>