MCPcopy
hub / github.com/impress/impress.js / init

Function init

js/impress.js:342–407  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

340
341 // `init` API function that initializes (and runs) the presentation.
342 var init = function() {
343 if ( initialized ) { return; }
344
345 // Initialize the configuration object, so it can be used by pre-init plugins.
346 config = buildConfig();
347 execPreInitPlugins( root );
348
349 // First we set up the viewport for mobile devices.
350 // For some reason iPad goes nuts when it is not done properly.
351 var meta = lib.util.$( "meta[name='viewport']" ) || document.createElement( "meta" );
352 meta.content = "width=device-width, minimum-scale=1, maximum-scale=1, user-scalable=no";
353 if ( meta.parentNode !== document.head ) {
354 meta.name = "viewport";
355 document.head.appendChild( meta );
356 }
357
358 windowScale = computeWindowScale( config );
359
360 // Wrap steps with "canvas" element
361 lib.util.arrayify( root.childNodes ).forEach( function( el ) {
362 canvas.appendChild( el );
363 } );
364 root.appendChild( canvas );
365
366 // Set initial styles
367 document.documentElement.style.height = "100%";
368
369 css( body, {
370 height: "100%",
371 overflow: "hidden"
372 } );
373
374 var rootStyles = {
375 position: "absolute",
376 transformOrigin: "top left",
377 transition: "all 0s ease-in-out",
378 transformStyle: "preserve-3d"
379 };
380
381 css( root, rootStyles );
382 css( root, {
383 top: "50%",
384 left: "50%",
385 perspective: ( config.perspective / windowScale ) + "px",
386 transform: scale( windowScale )
387 } );
388 css( canvas, rootStyles );
389
390 body.classList.remove( "impress-disabled" );
391 body.classList.add( "impress-enabled" );
392
393 // Get and init steps
394 initAllSteps();
395
396 // Set a default initial state of the canvas
397 currentState = {
398 translate: { x: 0, y: 0, z: 0 },
399 rotate: { x: 0, y: 0, z: 0, order: "xyz" },

Callers

nothing calls this directly

Calls 7

buildConfigFunction · 0.70
execPreInitPluginsFunction · 0.70
computeWindowScaleFunction · 0.70
cssFunction · 0.70
scaleFunction · 0.70
initAllStepsFunction · 0.70
_initFunction · 0.70

Tested by

no test coverage detected