• Jump To … +
    ./source/core/animationloop.js ./source/core/component.js ./source/core/document.js ./source/core/events.js ./source/core/init.js ./source/core/library.js ./source/core/userInteraction.js ./source/core/utilities.js ./source/factory/action.js ./source/factory/anchor.js ./source/factory/animation.js ./source/factory/bezier.js ./source/factory/block.js ./source/factory/canvas.js ./source/factory/cell.js ./source/factory/cog.js ./source/factory/color.js ./source/factory/coordinate.js ./source/factory/element.js ./source/factory/emitter.js ./source/factory/filter.js ./source/factory/fontAttributes.js ./source/factory/gradient.js ./source/factory/grid.js ./source/factory/group.js ./source/factory/imageAsset.js ./source/factory/line.js ./source/factory/loom.js ./source/factory/mesh.js ./source/factory/net.js ./source/factory/noise.js ./source/factory/oval.js ./source/factory/palette.js ./source/factory/particle.js ./source/factory/particleForce.js ./source/factory/particleHistory.js ./source/factory/particleSpring.js ./source/factory/particleWorld.js ./source/factory/pattern.js ./source/factory/phrase.js ./source/factory/picture.js ./source/factory/polygon.js ./source/factory/polyline.js ./source/factory/quadratic.js ./source/factory/quaternion.js ./source/factory/radialGradient.js ./source/factory/rectangle.js ./source/factory/renderAnimation.js ./source/factory/shape.js ./source/factory/spiral.js ./source/factory/spriteAsset.js ./source/factory/stack.js ./source/factory/star.js ./source/factory/state.js ./source/factory/tetragon.js ./source/factory/ticker.js ./source/factory/tracer.js ./source/factory/tween.js ./source/factory/unstackedElement.js ./source/factory/vector.js ./source/factory/videoAsset.js ./source/factory/wheel.js ./source/mixin/anchor.js ./source/mixin/asset.js ./source/mixin/assetConsumer.js ./source/mixin/base.js ./source/mixin/cascade.js ./source/mixin/delta.js ./source/mixin/displayShape.js ./source/mixin/dom.js ./source/mixin/entity.js ./source/mixin/filter.js ./source/mixin/mimic.js ./source/mixin/path.js ./source/mixin/pattern.js ./source/mixin/pivot.js ./source/mixin/position.js ./source/mixin/shapeBasic.js ./source/mixin/shapeCurve.js ./source/mixin/shapePathCalculation.js ./source/mixin/styles.js ./source/mixin/tween.js ./source/worker/filter-string.js ./source/worker/filter.js
  • ¶

    Core initialization

    A single, exported function (to modules). This needs to run once after the scrawl.js module (or equivalent) loads

  • ¶

    Imports

    import { startCoreAnimationLoop } from './animationloop.js';
    import { getCanvases, getStacks } from './document.js';
    import { startCoreListeners, applyCoreResizeListener, applyCoreScrollListener } from './userInteraction.js';
    
    
    const init = function () {
  • ¶

    Environment checks

  • ¶

    Flags to indicate if Scrawl-canvas is running in a touch-enabled environment. We lodge the results in the window object so other parts of the Scrawl-canvas code base can quickly check them

  • ¶

    Flag to indicate whether the device is touch-enabled

        window.scrawlEnvironmentTouchSupported = ('ontouchstart' in window || (window.DocumentTouch && document instanceof DocumentTouch)) ? true : false;
  • ¶

    Flag to indicate if Scrawl-canvas can use OffscreenCanvas interface

        window.scrawlEnvironmentOffscreenCanvasSupported = ('OffscreenCanvas' in window) ? true : false;
  • ¶

    Initialization

  • ¶

    Discovery phase - collect all canvas elements present in the DOM, and any other elements with a ‘data-stack’ attribute

        getStacks();
        getCanvases();
  • ¶

    Start the core animation loop

        startCoreAnimationLoop();
  • ¶

    Start the core listeners on the window object

        applyCoreResizeListener();
        applyCoreScrollListener();
        startCoreListeners();
    };
  • ¶

    Exports

    export {
        init,
    };