| /* global locationHref:writable, animationManager, subframeEnabled:writable, defaultCurveSegments:writable, roundValues, |
| expressionsPlugin:writable, PropertyFactory, ShapePropertyFactory, Matrix, idPrefix:writable, _useWebWorker:writable */ |
| /* exported locationHref, subframeEnabled, expressionsPlugin, idPrefix, _useWebWorker */ |
| |
| 'use strict'; |
| |
| /* <%= contents %> */ |
| var lottie = {}; |
| |
| function setLocationHref(href) { |
| locationHref = href; |
| } |
| |
| function searchAnimations() { |
| if (standalone === true) { |
| animationManager.searchAnimations(animationData, standalone, renderer); |
| } else { |
| animationManager.searchAnimations(); |
| } |
| } |
| |
| function setSubframeRendering(flag) { |
| subframeEnabled = flag; |
| } |
| |
| function setIDPrefix(prefix) { |
| idPrefix = prefix; |
| } |
| |
| function loadAnimation(params) { |
| if (standalone === true) { |
| params.animationData = JSON.parse(animationData); |
| } |
| return animationManager.loadAnimation(params); |
| } |
| |
| function setQuality(value) { |
| if (typeof value === 'string') { |
| switch (value) { |
| case 'high': |
| defaultCurveSegments = 200; |
| break; |
| default: |
| case 'medium': |
| defaultCurveSegments = 50; |
| break; |
| case 'low': |
| defaultCurveSegments = 10; |
| break; |
| } |
| } else if (!isNaN(value) && value > 1) { |
| defaultCurveSegments = value; |
| } |
| if (defaultCurveSegments >= 50) { |
| roundValues(false); |
| } else { |
| roundValues(true); |
| } |
| } |
| |
| function inBrowser() { |
| return typeof navigator !== 'undefined'; |
| } |
| |
| function installPlugin(type, plugin) { |
| if (type === 'expressions') { |
| expressionsPlugin = plugin; |
| } |
| } |
| |
| function getFactory(name) { |
| switch (name) { |
| case 'propertyFactory': |
| return PropertyFactory; |
| case 'shapePropertyFactory': |
| return ShapePropertyFactory; |
| case 'matrix': |
| return Matrix; |
| default: |
| return null; |
| } |
| } |
| |
| lottie.play = animationManager.play; |
| lottie.pause = animationManager.pause; |
| lottie.setLocationHref = setLocationHref; |
| lottie.togglePause = animationManager.togglePause; |
| lottie.setSpeed = animationManager.setSpeed; |
| lottie.setDirection = animationManager.setDirection; |
| lottie.stop = animationManager.stop; |
| lottie.searchAnimations = searchAnimations; |
| lottie.registerAnimation = animationManager.registerAnimation; |
| lottie.loadAnimation = loadAnimation; |
| lottie.setSubframeRendering = setSubframeRendering; |
| lottie.resize = animationManager.resize; |
| // lottie.start = start; |
| lottie.goToAndStop = animationManager.goToAndStop; |
| lottie.destroy = animationManager.destroy; |
| lottie.setQuality = setQuality; |
| lottie.inBrowser = inBrowser; |
| lottie.installPlugin = installPlugin; |
| lottie.freeze = animationManager.freeze; |
| lottie.unfreeze = animationManager.unfreeze; |
| lottie.setVolume = animationManager.setVolume; |
| lottie.mute = animationManager.mute; |
| lottie.unmute = animationManager.unmute; |
| lottie.getRegisteredAnimations = animationManager.getRegisteredAnimations; |
| lottie.useWebWorker = function (flag) { |
| _useWebWorker = flag; |
| }; |
| lottie.setIDPrefix = setIDPrefix; |
| lottie.__getFactory = getFactory; |
| lottie.version = '[[BM_VERSION]]'; |
| |
| function checkReady() { |
| if (document.readyState === 'complete') { |
| clearInterval(readyStateCheckInterval); |
| searchAnimations(); |
| } |
| } |
| |
| function getQueryVariable(variable) { |
| var vars = queryString.split('&'); |
| for (var i = 0; i < vars.length; i += 1) { |
| var pair = vars[i].split('='); |
| if (decodeURIComponent(pair[0]) == variable) { // eslint-disable-line eqeqeq |
| return decodeURIComponent(pair[1]); |
| } |
| } |
| return null; |
| } |
| var standalone = '__[STANDALONE]__'; |
| var animationData = '__[ANIMATIONDATA]__'; |
| var renderer = ''; |
| var queryString; |
| if (standalone) { |
| var scripts = document.getElementsByTagName('script'); |
| var index = scripts.length - 1; |
| var myScript = scripts[index] || { |
| src: '', |
| }; |
| queryString = myScript.src.replace(/^[^\?]+\??/, ''); // eslint-disable-line no-useless-escape |
| renderer = getQueryVariable('renderer'); |
| } |
| var readyStateCheckInterval = setInterval(checkReady, 100); |