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;;;;;AA+DX,0CAAgB;;AAEd,QAAI,OAAO,IAAI,cAAJ,EAAP,CAFU;;AAId,SAAK,gBAAL,CAAsB,UAAtB,EAAkC,UAAC,MAAD,EAAY;AAC5C,UAAI,OAAO,gBAAP,EAAyB;;AAE3B,YAAI,UAAU,KAAK,IAAL,CAAU,OAAO,MAAP,GAAgB,OAAO,KAAP,GAAe,GAA/B,CAApB,CAFuB;AAG3B,gBAAQ,GAAR,CAAY,qBAAZ,EAAmC,OAAnC;;;;AAH2B,YAO3B,CAAK,MAAL,CAAY,WAAZ,CAAwB,UAAU,IAAV,CAAxB,CAP2B;OAA7B;KADgC,CAAlC,CAJc;;AAgBd,SAAK,gBAAL,CAAsB,MAAtB,EAA8B,UAAC,CAAD,EAAO;;AAEnC,WAAK,OAAL,CAAa,WAAb,GAFmC;KAAP,CAA9B,CAhBc;;AAqBd,SAAK,IAAL,CAAU,KAAV,EAAiB,oBAAjB,EArBc;AAsBd,SAAK,IAAL,GAtBc;GA/DL;CAAP","file":"main.js","sourcesContent":["// Rebound\n// =======\n// **Rebound** is a simple library that models Spring dynamics for the\n// purpose of driving physical animations.\n//\n// Origin\n// ------\n// [Rebound](http://facebook.github.io/rebound) was originally written\n// in Java to provide a lightweight physics system for\n// [Home](https://play.google.com/store/apps/details?id=com.facebook.home) and\n// [Chat Heads](https://play.google.com/store/apps/details?id=com.facebook.orca)\n// on Android. It's now been adopted by several other Android\n// applications. This JavaScript port was written to provide a quick\n// way to demonstrate Rebound animations on the web for a\n// [conference talk](https://www.youtube.com/watch?v=s5kNm-DgyjY). Since then\n// the JavaScript version has been used to build some really nice interfaces.\n// Check out [brandonwalkin.com](http://brandonwalkin.com) for an\n// example.\n//\n// Overview\n// --------\n// The Library provides a SpringSystem for maintaining a set of Spring\n// objects and iterating those Springs through a physics solver loop\n// until equilibrium is achieved. The Spring class is the basic\n// animation driver provided by Rebound. By attaching a listener to\n// a Spring, you can observe its motion. The observer function is\n// notified of position changes on the spring as it solves for\n// equilibrium. These position updates can be mapped to an animation\n// range to drive animated property updates on your user interface\n// elements (translation, rotation, scale, etc).\n//\n// Example\n// -------\n// Here's a simple example. Pressing and releasing on the logo below\n// will cause it to scale up and down with a springy animation.\n//\n//
\n// \n//
\n// \n// \n//\n// Here's how it works.\n//\n// ```\n// // Get a reference to the logo element.\n// var el = document.getElementById('logo');\n//\n// // create a SpringSystem and a Spring with a bouncy config.\n// var springSystem = new rebound.SpringSystem();\n// var spring = springSystem.createSpring(50, 3);\n//\n// // Add a listener to the spring. Every time the physics\n// // solver updates the Spring's value onSpringUpdate will\n// // be called.\n// spring.addListener({\n// onSpringUpdate: function(spring) {\n// var val = spring.getCurrentValue();\n// val = rebound.MathUtil\n// .mapValueInRange(val, 0, 1, 1, 0.5);\n// scale(el, val);\n// }\n// });\n//\n// // Listen for mouse down/up/out and toggle the\n// //springs endValue from 0 to 1.\n// el.addEventListener('mousedown', function() {\n// spring.setEndValue(1);\n// });\n//\n// el.addEventListener('mouseout', function() {\n// spring.setEndValue(0);\n// });\n//\n// el.addEventListener('mouseup', function() {\n// spring.setEndValue(0);\n// });\n//\n// // Helper for scaling an element with css transforms.\n// function scale(el, val) {\n// el.style.mozTransform =\n// el.style.msTransform =\n// el.style.webkitTransform =\n// el.style.transform = 'scale3d(' +\n// val + ', ' + val + ', 1)';\n// }\n// ```\n\n(function() {\n var rebound = {};\n var util = rebound.util = {};\n var concat = Array.prototype.concat;\n var slice = Array.prototype.slice;\n\n // Bind a function to a context object.\n util.bind = function bind(func, context) {\n var args = slice.call(arguments, 2);\n return function() {\n func.apply(context, concat.call(args, slice.call(arguments)));\n };\n };\n\n // Add all the properties in the source to the target.\n util.extend = function extend(target, source) {\n for (var key in source) {\n if (source.hasOwnProperty(key)) {\n target[key] = source[key];\n }\n }\n };\n\n // SpringSystem\n // ------------\n // **SpringSystem** is a set of Springs that all run on the same physics\n // timing loop. To get started with a Rebound animation you first\n // create a new SpringSystem and then add springs to it.\n var SpringSystem = rebound.SpringSystem = function SpringSystem(looper) {\n this._springRegistry = {};\n this._activeSprings = [];\n this.listeners = [];\n this._idleSpringIndices = [];\n this.looper = looper || new AnimationLooper();\n this.looper.springSystem = this;\n };\n\n util.extend(SpringSystem.prototype, {\n\n _springRegistry: null,\n\n _isIdle: true,\n\n _lastTimeMillis: -1,\n\n _activeSprings: null,\n\n listeners: null,\n\n _idleSpringIndices: null,\n\n // A SpringSystem is iterated by a looper. The looper is responsible\n // for executing each frame as the SpringSystem is resolved to idle.\n // There are three types of Loopers described below AnimationLooper,\n // SimulationLooper, and SteppingSimulationLooper. AnimationLooper is\n // the default as it is the most useful for common UI animations.\n setLooper: function(looper) {\n this.looper = looper;\n looper.springSystem = this;\n },\n\n // Add a new spring to this SpringSystem. This Spring will now be solved for\n // during the physics iteration loop. By default the spring will use the\n // default Origami spring config with 40 tension and 7 friction, but you can\n // also provide your own values here.\n createSpring: function(tension, friction) {\n var springConfig;\n if (tension === undefined || friction === undefined) {\n springConfig = SpringConfig.DEFAULT_ORIGAMI_SPRING_CONFIG;\n } else {\n springConfig =\n SpringConfig.fromOrigamiTensionAndFriction(tension, friction);\n }\n return this.createSpringWithConfig(springConfig);\n },\n\n // Add a spring with a specified bounciness and speed. To replicate Origami\n // compositions based on PopAnimation patches, use this factory method to\n // create matching springs.\n createSpringWithBouncinessAndSpeed: function(bounciness, speed) {\n var springConfig;\n if (bounciness === undefined || speed === undefined) {\n springConfig = SpringConfig.DEFAULT_ORIGAMI_SPRING_CONFIG;\n } else {\n springConfig =\n SpringConfig.fromBouncinessAndSpeed(bounciness, speed);\n }\n return this.createSpringWithConfig(springConfig);\n },\n\n // Add a spring with the provided SpringConfig.\n createSpringWithConfig: function(springConfig) {\n var spring = new Spring(this);\n this.registerSpring(spring);\n spring.setSpringConfig(springConfig);\n return spring;\n },\n\n // You can check if a SpringSystem is idle or active by calling\n // getIsIdle. If all of the Springs in the SpringSystem are at rest,\n // i.e. the physics forces have reached equilibrium, then this\n // method will return true.\n getIsIdle: function() {\n return this._isIdle;\n },\n\n // Retrieve a specific Spring from the SpringSystem by id. This\n // can be useful for inspecting the state of a spring before\n // or after an integration loop in the SpringSystem executes.\n getSpringById: function (id) {\n return this._springRegistry[id];\n },\n\n // Get a listing of all the springs registered with this\n // SpringSystem.\n getAllSprings: function() {\n var vals = [];\n for (var id in this._springRegistry) {\n if (this._springRegistry.hasOwnProperty(id)) {\n vals.push(this._springRegistry[id]);\n }\n }\n return vals;\n },\n\n // registerSpring is called automatically as soon as you create\n // a Spring with SpringSystem#createSpring. This method sets the\n // spring up in the registry so that it can be solved in the\n // solver loop.\n registerSpring: function(spring) {\n this._springRegistry[spring.getId()] = spring;\n },\n\n // Deregister a spring with this SpringSystem. The SpringSystem will\n // no longer consider this Spring during its integration loop once\n // this is called. This is normally done automatically for you when\n // you call Spring#destroy.\n deregisterSpring: function(spring) {\n removeFirst(this._activeSprings, spring);\n delete this._springRegistry[spring.getId()];\n },\n\n advance: function(time, deltaTime) {\n while(this._idleSpringIndices.length > 0) this._idleSpringIndices.pop();\n for (var i = 0, len = this._activeSprings.length; i < len; i++) {\n var spring = this._activeSprings[i];\n if (spring.systemShouldAdvance()) {\n spring.advance(time / 1000.0, deltaTime / 1000.0);\n } else {\n this._idleSpringIndices.push(this._activeSprings.indexOf(spring));\n }\n }\n while(this._idleSpringIndices.length > 0) {\n var idx = this._idleSpringIndices.pop();\n idx >= 0 && this._activeSprings.splice(idx, 1);\n }\n },\n\n // This is our main solver loop called to move the simulation\n // forward through time. Before each pass in the solver loop\n // onBeforeIntegrate is called on an any listeners that have\n // registered themeselves with the SpringSystem. This gives you\n // an opportunity to apply any constraints or adjustments to\n // the springs that should be enforced before each iteration\n // loop. Next the advance method is called to move each Spring in\n // the systemShouldAdvance forward to the current time. After the\n // integration step runs in advance, onAfterIntegrate is called\n // on any listeners that have registered themselves with the\n // SpringSystem. This gives you an opportunity to run any post\n // integration constraints or adjustments on the Springs in the\n // SpringSystem.\n loop: function(currentTimeMillis) {\n var listener;\n if (this._lastTimeMillis === -1) {\n this._lastTimeMillis = currentTimeMillis -1;\n }\n var ellapsedMillis = currentTimeMillis - this._lastTimeMillis;\n this._lastTimeMillis = currentTimeMillis;\n\n var i = 0, len = this.listeners.length;\n for (i = 0; i < len; i++) {\n listener = this.listeners[i];\n listener.onBeforeIntegrate && listener.onBeforeIntegrate(this);\n }\n\n this.advance(currentTimeMillis, ellapsedMillis);\n if (this._activeSprings.length === 0) {\n this._isIdle = true;\n this._lastTimeMillis = -1;\n }\n\n for (i = 0; i < len; i++) {\n listener = this.listeners[i];\n listener.onAfterIntegrate && listener.onAfterIntegrate(this);\n }\n\n if (!this._isIdle) {\n this.looper.run();\n }\n },\n\n // activateSpring is used to notify the SpringSystem that a Spring\n // has become displaced. The system responds by starting its solver\n // loop up if it is currently idle.\n activateSpring: function(springId) {\n var spring = this._springRegistry[springId];\n if (this._activeSprings.indexOf(spring) == -1) {\n this._activeSprings.push(spring);\n }\n if (this.getIsIdle()) {\n this._isIdle = false;\n this.looper.run();\n }\n },\n\n // Add a listener to the SpringSystem so that you can receive\n // before/after integration notifications allowing Springs to be\n // constrained or adjusted.\n addListener: function(listener) {\n this.listeners.push(listener);\n },\n\n // Remove a previously added listener on the SpringSystem.\n removeListener: function(listener) {\n removeFirst(this.listeners, listener);\n },\n\n // Remove all previously added listeners on the SpringSystem.\n removeAllListeners: function() {\n this.listeners = [];\n }\n\n });\n\n // Spring\n // ------\n // **Spring** provides a model of a classical spring acting to\n // resolve a body to equilibrium. Springs have configurable\n // tension which is a force multipler on the displacement of the\n // spring from its rest point or `endValue` as defined by [Hooke's\n // law](http://en.wikipedia.org/wiki/Hooke's_law). Springs also have\n // configurable friction, which ensures that they do not oscillate\n // infinitely. When a Spring is displaced by updating it's resting\n // or `currentValue`, the SpringSystems that contain that Spring\n // will automatically start looping to solve for equilibrium. As each\n // timestep passes, `SpringListener` objects attached to the Spring\n // will be notified of the updates providing a way to drive an\n // animation off of the spring's resolution curve.\n var Spring = rebound.Spring = function Spring(springSystem) {\n this._id = 's' + Spring._ID++;\n this._springSystem = springSystem;\n this.listeners = [];\n this._currentState = new PhysicsState();\n this._previousState = new PhysicsState();\n this._tempState = new PhysicsState();\n };\n\n util.extend(Spring, {\n _ID: 0,\n\n MAX_DELTA_TIME_SEC: 0.064,\n\n SOLVER_TIMESTEP_SEC: 0.001\n\n });\n\n util.extend(Spring.prototype, {\n\n _id: 0,\n\n _springConfig: null,\n\n _overshootClampingEnabled: false,\n\n _currentState: null,\n\n _previousState: null,\n\n _tempState: null,\n\n _startValue: 0,\n\n _endValue: 0,\n\n _wasAtRest: true,\n\n _restSpeedThreshold: 0.001,\n\n _displacementFromRestThreshold: 0.001,\n\n listeners: null,\n\n _timeAccumulator: 0,\n\n _springSystem: null,\n\n // Remove a Spring from simulation and clear its listeners.\n destroy: function() {\n this.listeners = [];\n this.frames = [];\n this._springSystem.deregisterSpring(this);\n },\n\n // Get the id of the spring, which can be used to retrieve it from\n // the SpringSystems it participates in later.\n getId: function() {\n return this._id;\n },\n\n // Set the configuration values for this Spring. A SpringConfig\n // contains the tension and friction values used to solve for the\n // equilibrium of the Spring in the physics loop.\n setSpringConfig: function(springConfig) {\n this._springConfig = springConfig;\n return this;\n },\n\n // Retrieve the SpringConfig used by this Spring.\n getSpringConfig: function() {\n return this._springConfig;\n },\n\n // Set the current position of this Spring. Listeners will be updated\n // with this value immediately. If the rest or `endValue` is not\n // updated to match this value, then the spring will be dispalced and\n // the SpringSystem will start to loop to restore the spring to the\n // `endValue`.\n //\n // A common pattern is to move a Spring around without animation by\n // calling.\n //\n // ```\n // spring.setCurrentValue(n).setAtRest();\n // ```\n //\n // This moves the Spring to a new position `n`, sets the endValue\n // to `n`, and removes any velocity from the `Spring`. By doing\n // this you can allow the `SpringListener` to manage the position\n // of UI elements attached to the spring even when moving without\n // animation. For example, when dragging an element you can\n // update the position of an attached view through a spring\n // by calling `spring.setCurrentValue(x)`. When\n // the gesture ends you can update the Springs\n // velocity and endValue\n // `spring.setVelocity(gestureEndVelocity).setEndValue(flingTarget)`\n // to cause it to naturally animate the UI element to the resting\n // position taking into account existing velocity. The codepaths for\n // synchronous movement and spring driven animation can\n // be unified using this technique.\n setCurrentValue: function(currentValue, skipSetAtRest) {\n this._startValue = currentValue;\n this._currentState.position = currentValue;\n if (!skipSetAtRest) {\n this.setAtRest();\n }\n this.notifyPositionUpdated(false, false);\n return this;\n },\n\n // Get the position that the most recent animation started at. This\n // can be useful for determining the number off oscillations that\n // have occurred.\n getStartValue: function() {\n return this._startValue;\n },\n\n // Retrieve the current value of the Spring.\n getCurrentValue: function() {\n return this._currentState.position;\n },\n\n // Get the absolute distance of the Spring from it's resting endValue\n // position.\n getCurrentDisplacementDistance: function() {\n return this.getDisplacementDistanceForState(this._currentState);\n },\n\n getDisplacementDistanceForState: function(state) {\n return Math.abs(this._endValue - state.position);\n },\n\n // Set the endValue or resting position of the spring. If this\n // value is different than the current value, the SpringSystem will\n // be notified and will begin running its solver loop to resolve\n // the Spring to equilibrium. Any listeners that are registered\n // for onSpringEndStateChange will also be notified of this update\n // immediately.\n setEndValue: function(endValue) {\n if (this._endValue == endValue && this.isAtRest()) {\n return this;\n }\n this._startValue = this.getCurrentValue();\n this._endValue = endValue;\n this._springSystem.activateSpring(this.getId());\n for (var i = 0, len = this.listeners.length; i < len; i++) {\n var listener = this.listeners[i];\n var onChange = listener.onSpringEndStateChange;\n onChange && onChange(this);\n }\n return this;\n },\n\n // Retrieve the endValue or resting position of this spring.\n getEndValue: function() {\n return this._endValue;\n },\n\n // Set the current velocity of the Spring. As previously mentioned,\n // this can be useful when you are performing a direct manipulation\n // gesture. When a UI element is released you may call setVelocity\n // on its animation Spring so that the Spring continues with the\n // same velocity as the gesture ended with. The friction, tension,\n // and displacement of the Spring will then govern its motion to\n // return to rest on a natural feeling curve.\n setVelocity: function(velocity) {\n if (velocity === this._currentState.velocity) {\n return this;\n }\n this._currentState.velocity = velocity;\n this._springSystem.activateSpring(this.getId());\n return this;\n },\n\n // Get the current velocity of the Spring.\n getVelocity: function() {\n return this._currentState.velocity;\n },\n\n // Set a threshold value for the movement speed of the Spring below\n // which it will be considered to be not moving or resting.\n setRestSpeedThreshold: function(restSpeedThreshold) {\n this._restSpeedThreshold = restSpeedThreshold;\n return this;\n },\n\n // Retrieve the rest speed threshold for this Spring.\n getRestSpeedThreshold: function() {\n return this._restSpeedThreshold;\n },\n\n // Set a threshold value for displacement below which the Spring\n // will be considered to be not displaced i.e. at its resting\n // `endValue`.\n setRestDisplacementThreshold: function(displacementFromRestThreshold) {\n this._displacementFromRestThreshold = displacementFromRestThreshold;\n },\n\n // Retrieve the rest displacement threshold for this spring.\n getRestDisplacementThreshold: function() {\n return this._displacementFromRestThreshold;\n },\n\n // Enable overshoot clamping. This means that the Spring will stop\n // immediately when it reaches its resting position regardless of\n // any existing momentum it may have. This can be useful for certain\n // types of animations that should not oscillate such as a scale\n // down to 0 or alpha fade.\n setOvershootClampingEnabled: function(enabled) {\n this._overshootClampingEnabled = enabled;\n return this;\n },\n\n // Check if overshoot clamping is enabled for this spring.\n isOvershootClampingEnabled: function() {\n return this._overshootClampingEnabled;\n },\n\n // Check if the Spring has gone past its end point by comparing\n // the direction it was moving in when it started to the current\n // position and end value.\n isOvershooting: function() {\n var start = this._startValue;\n var end = this._endValue;\n return this._springConfig.tension > 0 &&\n ((start < end && this.getCurrentValue() > end) ||\n (start > end && this.getCurrentValue() < end));\n },\n\n // Spring.advance is the main solver method for the Spring. It takes\n // the current time and delta since the last time step and performs\n // an RK4 integration to get the new position and velocity state\n // for the Spring based on the tension, friction, velocity, and\n // displacement of the Spring.\n advance: function(time, realDeltaTime) {\n var isAtRest = this.isAtRest();\n\n if (isAtRest && this._wasAtRest) {\n return;\n }\n\n var adjustedDeltaTime = realDeltaTime;\n if (realDeltaTime > Spring.MAX_DELTA_TIME_SEC) {\n adjustedDeltaTime = Spring.MAX_DELTA_TIME_SEC;\n }\n\n this._timeAccumulator += adjustedDeltaTime;\n\n var tension = this._springConfig.tension,\n friction = this._springConfig.friction,\n\n position = this._currentState.position,\n velocity = this._currentState.velocity,\n tempPosition = this._tempState.position,\n tempVelocity = this._tempState.velocity,\n\n aVelocity, aAcceleration,\n bVelocity, bAcceleration,\n cVelocity, cAcceleration,\n dVelocity, dAcceleration,\n\n dxdt, dvdt;\n\n while(this._timeAccumulator >= Spring.SOLVER_TIMESTEP_SEC) {\n\n this._timeAccumulator -= Spring.SOLVER_TIMESTEP_SEC;\n\n if (this._timeAccumulator < Spring.SOLVER_TIMESTEP_SEC) {\n this._previousState.position = position;\n this._previousState.velocity = velocity;\n }\n\n aVelocity = velocity;\n aAcceleration =\n (tension * (this._endValue - tempPosition)) - friction * velocity;\n\n tempPosition = position + aVelocity * Spring.SOLVER_TIMESTEP_SEC * 0.5;\n tempVelocity =\n velocity + aAcceleration * Spring.SOLVER_TIMESTEP_SEC * 0.5;\n bVelocity = tempVelocity;\n bAcceleration =\n (tension * (this._endValue - tempPosition)) - friction * tempVelocity;\n\n tempPosition = position + bVelocity * Spring.SOLVER_TIMESTEP_SEC * 0.5;\n tempVelocity =\n velocity + bAcceleration * Spring.SOLVER_TIMESTEP_SEC * 0.5;\n cVelocity = tempVelocity;\n cAcceleration =\n (tension * (this._endValue - tempPosition)) - friction * tempVelocity;\n\n tempPosition = position + cVelocity * Spring.SOLVER_TIMESTEP_SEC * 0.5;\n tempVelocity =\n velocity + cAcceleration * Spring.SOLVER_TIMESTEP_SEC * 0.5;\n dVelocity = tempVelocity;\n dAcceleration =\n (tension * (this._endValue - tempPosition)) - friction * tempVelocity;\n\n dxdt =\n 1.0/6.0 * (aVelocity + 2.0 * (bVelocity + cVelocity) + dVelocity);\n dvdt = 1.0/6.0 * (\n aAcceleration + 2.0 * (bAcceleration + cAcceleration) + dAcceleration\n );\n\n position += dxdt * Spring.SOLVER_TIMESTEP_SEC;\n velocity += dvdt * Spring.SOLVER_TIMESTEP_SEC;\n }\n\n this._tempState.position = tempPosition;\n this._tempState.velocity = tempVelocity;\n\n this._currentState.position = position;\n this._currentState.velocity = velocity;\n\n if (this._timeAccumulator > 0) {\n this._interpolate(this._timeAccumulator / Spring.SOLVER_TIMESTEP_SEC);\n }\n\n if (this.isAtRest() ||\n this._overshootClampingEnabled && this.isOvershooting()) {\n\n if (this._springConfig.tension > 0) {\n this._startValue = this._endValue;\n this._currentState.position = this._endValue;\n } else {\n this._endValue = this._currentState.position;\n this._startValue = this._endValue;\n }\n this.setVelocity(0);\n isAtRest = true;\n }\n\n var notifyActivate = false;\n if (this._wasAtRest) {\n this._wasAtRest = false;\n notifyActivate = true;\n }\n\n var notifyAtRest = false;\n if (isAtRest) {\n this._wasAtRest = true;\n notifyAtRest = true;\n }\n\n this.notifyPositionUpdated(notifyActivate, notifyAtRest);\n },\n\n notifyPositionUpdated: function(notifyActivate, notifyAtRest) {\n for (var i = 0, len = this.listeners.length; i < len; i++) {\n var listener = this.listeners[i];\n if (notifyActivate && listener.onSpringActivate) {\n listener.onSpringActivate(this);\n }\n\n if (listener.onSpringUpdate) {\n listener.onSpringUpdate(this);\n }\n\n if (notifyAtRest && listener.onSpringAtRest) {\n listener.onSpringAtRest(this);\n }\n }\n },\n\n\n // Check if the SpringSystem should advance. Springs are advanced\n // a final frame after they reach equilibrium to ensure that the\n // currentValue is exactly the requested endValue regardless of the\n // displacement threshold.\n systemShouldAdvance: function() {\n return !this.isAtRest() || !this.wasAtRest();\n },\n\n wasAtRest: function() {\n return this._wasAtRest;\n },\n\n // Check if the Spring is atRest meaning that it's currentValue and\n // endValue are the same and that it has no velocity. The previously\n // described thresholds for speed and displacement define the bounds\n // of this equivalence check. If the Spring has 0 tension, then it will\n // be considered at rest whenever its absolute velocity drops below the\n // restSpeedThreshold.\n isAtRest: function() {\n return Math.abs(this._currentState.velocity) < this._restSpeedThreshold &&\n (this.getDisplacementDistanceForState(this._currentState) <=\n this._displacementFromRestThreshold ||\n this._springConfig.tension === 0);\n },\n\n // Force the spring to be at rest at its current position. As\n // described in the documentation for setCurrentValue, this method\n // makes it easy to do synchronous non-animated updates to ui\n // elements that are attached to springs via SpringListeners.\n setAtRest: function() {\n this._endValue = this._currentState.position;\n this._tempState.position = this._currentState.position;\n this._currentState.velocity = 0;\n return this;\n },\n\n _interpolate: function(alpha) {\n this._currentState.position = this._currentState.position *\n alpha + this._previousState.position * (1 - alpha);\n this._currentState.velocity = this._currentState.velocity *\n alpha + this._previousState.velocity * (1 - alpha);\n },\n\n getListeners: function() {\n return this.listeners;\n },\n\n addListener: function(newListener) {\n this.listeners.push(newListener);\n return this;\n },\n\n removeListener: function(listenerToRemove) {\n removeFirst(this.listeners, listenerToRemove);\n return this;\n },\n\n removeAllListeners: function() {\n this.listeners = [];\n return this;\n },\n\n currentValueIsApproximately: function(value) {\n return Math.abs(this.getCurrentValue() - value) <=\n this.getRestDisplacementThreshold();\n }\n\n });\n\n // PhysicsState\n // ------------\n // **PhysicsState** consists of a position and velocity. A Spring uses\n // this internally to keep track of its current and prior position and\n // velocity values.\n var PhysicsState = function PhysicsState() {};\n\n util.extend(PhysicsState.prototype, {\n position: 0,\n velocity: 0\n });\n\n // SpringConfig\n // ------------\n // **SpringConfig** maintains a set of tension and friction constants\n // for a Spring. You can use fromOrigamiTensionAndFriction to convert\n // values from the [Origami](http://facebook.github.io/origami/)\n // design tool directly to Rebound spring constants.\n var SpringConfig = rebound.SpringConfig =\n function SpringConfig(tension, friction) {\n this.tension = tension;\n this.friction = friction;\n };\n\n // Loopers\n // -------\n // **AnimationLooper** plays each frame of the SpringSystem on animation\n // timing loop. This is the default type of looper for a new spring system\n // as it is the most common when developing UI.\n var AnimationLooper = rebound.AnimationLooper = function AnimationLooper() {\n this.springSystem = null;\n var _this = this;\n var _run = function() {\n _this.springSystem.loop(Date.now());\n };\n\n this.run = function() {\n util.onFrame(_run);\n };\n };\n\n // **SimulationLooper** resolves the SpringSystem to a resting state in a\n // tight and blocking loop. This is useful for synchronously generating\n // pre-recorded animations that can then be played on a timing loop later.\n // Sometimes this lead to better performance to pre-record a single spring\n // curve and use it to drive many animations; however, it can make dynamic\n // response to user input a bit trickier to implement.\n rebound.SimulationLooper = function SimulationLooper(timestep) {\n this.springSystem = null;\n var time = 0;\n var running = false;\n timestep=timestep || 16.667;\n\n this.run = function() {\n if (running) {\n return;\n }\n running = true;\n while(!this.springSystem.getIsIdle()) {\n this.springSystem.loop(time+=timestep);\n }\n running = false;\n };\n };\n\n // **SteppingSimulationLooper** resolves the SpringSystem one step at a\n // time controlled by an outside loop. This is useful for testing and\n // verifying the behavior of a SpringSystem or if you want to control your own\n // timing loop for some reason e.g. slowing down or speeding up the\n // simulation.\n rebound.SteppingSimulationLooper = function(timestep) {\n this.springSystem = null;\n var time = 0;\n\n // this.run is NOOP'd here to allow control from the outside using\n // this.step.\n this.run = function(){};\n\n // Perform one step toward resolving the SpringSystem.\n this.step = function(timestep) {\n this.springSystem.loop(time+=timestep);\n };\n };\n\n // Math for converting from\n // [Origami](http://facebook.github.io/origami/) to\n // [Rebound](http://facebook.github.io/rebound).\n // You mostly don't need to worry about this, just use\n // SpringConfig.fromOrigamiTensionAndFriction(v, v);\n var OrigamiValueConverter = rebound.OrigamiValueConverter = {\n tensionFromOrigamiValue: function(oValue) {\n return (oValue - 30.0) * 3.62 + 194.0;\n },\n\n origamiValueFromTension: function(tension) {\n return (tension - 194.0) / 3.62 + 30.0;\n },\n\n frictionFromOrigamiValue: function(oValue) {\n return (oValue - 8.0) * 3.0 + 25.0;\n },\n\n origamiFromFriction: function(friction) {\n return (friction - 25.0) / 3.0 + 8.0;\n }\n };\n\n // BouncyConversion provides math for converting from Origami PopAnimation\n // config values to regular Origami tension and friction values. If you are\n // trying to replicate prototypes made with PopAnimation patches in Origami,\n // then you should create your springs with\n // SpringSystem.createSpringWithBouncinessAndSpeed, which uses this Math\n // internally to create a spring to match the provided PopAnimation\n // configuration from Origami.\n var BouncyConversion = rebound.BouncyConversion = function(bounciness, speed){\n this.bounciness = bounciness;\n this.speed = speed;\n var b = this.normalize(bounciness / 1.7, 0, 20.0);\n b = this.projectNormal(b, 0.0, 0.8);\n var s = this.normalize(speed / 1.7, 0, 20.0);\n this.bouncyTension = this.projectNormal(s, 0.5, 200)\n this.bouncyFriction = this.quadraticOutInterpolation(\n b,\n this.b3Nobounce(this.bouncyTension),\n 0.01);\n }\n\n util.extend(BouncyConversion.prototype, {\n\n normalize: function(value, startValue, endValue) {\n return (value - startValue) / (endValue - startValue);\n },\n\n projectNormal: function(n, start, end) {\n return start + (n * (end - start));\n },\n\n linearInterpolation: function(t, start, end) {\n return t * end + (1.0 - t) * start;\n },\n\n quadraticOutInterpolation: function(t, start, end) {\n return this.linearInterpolation(2*t - t*t, start, end);\n },\n\n b3Friction1: function(x) {\n return (0.0007 * Math.pow(x, 3)) -\n (0.031 * Math.pow(x, 2)) + 0.64 * x + 1.28;\n },\n\n b3Friction2: function(x) {\n return (0.000044 * Math.pow(x, 3)) -\n (0.006 * Math.pow(x, 2)) + 0.36 * x + 2.;\n },\n\n b3Friction3: function(x) {\n return (0.00000045 * Math.pow(x, 3)) -\n (0.000332 * Math.pow(x, 2)) + 0.1078 * x + 5.84;\n },\n\n b3Nobounce: function(tension) {\n var friction = 0;\n if (tension <= 18) {\n friction = this.b3Friction1(tension);\n } else if (tension > 18 && tension <= 44) {\n friction = this.b3Friction2(tension);\n } else {\n friction = this.b3Friction3(tension);\n }\n return friction;\n }\n });\n\n util.extend(SpringConfig, {\n // Convert an origami Spring tension and friction to Rebound spring\n // constants. If you are prototyping a design with Origami, this\n // makes it easy to make your springs behave exactly the same in\n // Rebound.\n fromOrigamiTensionAndFriction: function(tension, friction) {\n return new SpringConfig(\n OrigamiValueConverter.tensionFromOrigamiValue(tension),\n OrigamiValueConverter.frictionFromOrigamiValue(friction));\n },\n\n // Convert an origami PopAnimation Spring bounciness and speed to Rebound\n // spring constants. If you are using PopAnimation patches in Origami, this\n // utility will provide springs that match your prototype.\n fromBouncinessAndSpeed: function(bounciness, speed) {\n var bouncyConversion = new rebound.BouncyConversion(bounciness, speed);\n return this.fromOrigamiTensionAndFriction(\n bouncyConversion.bouncyTension,\n bouncyConversion.bouncyFriction);\n },\n\n // Create a SpringConfig with no tension or a coasting spring with some\n // amount of Friction so that it does not coast infininitely.\n coastingConfigWithOrigamiFriction: function(friction) {\n return new SpringConfig(\n 0,\n OrigamiValueConverter.frictionFromOrigamiValue(friction)\n );\n }\n });\n\n SpringConfig.DEFAULT_ORIGAMI_SPRING_CONFIG =\n SpringConfig.fromOrigamiTensionAndFriction(40, 7);\n\n util.extend(SpringConfig.prototype, {friction: 0, tension: 0});\n\n // Here are a couple of function to convert colors between hex codes and RGB\n // component values. These are handy when performing color\n // tweening animations.\n var colorCache = {};\n util.hexToRGB = function(color) {\n if (colorCache[color]) {\n return colorCache[color];\n }\n color = color.replace('#', '');\n if (color.length === 3) {\n color = color[0] + color[0] + color[1] + color[1] + color[2] + color[2];\n }\n var parts = color.match(/.{2}/g);\n\n var ret = {\n r: parseInt(parts[0], 16),\n g: parseInt(parts[1], 16),\n b: parseInt(parts[2], 16)\n };\n\n colorCache[color] = ret;\n return ret;\n };\n\n util.rgbToHex = function(r, g, b) {\n r = r.toString(16);\n g = g.toString(16);\n b = b.toString(16);\n r = r.length < 2 ? '0' + r : r;\n g = g.length < 2 ? '0' + g : g;\n b = b.length < 2 ? '0' + b : b;\n return '#' + r + g + b;\n };\n\n var MathUtil = rebound.MathUtil = {\n // This helper function does a linear interpolation of a value from\n // one range to another. This can be very useful for converting the\n // motion of a Spring to a range of UI property values. For example a\n // spring moving from position 0 to 1 could be interpolated to move a\n // view from pixel 300 to 350 and scale it from 0.5 to 1. The current\n // position of the `Spring` just needs to be run through this method\n // taking its input range in the _from_ parameters with the property\n // animation range in the _to_ parameters.\n mapValueInRange: function(value, fromLow, fromHigh, toLow, toHigh) {\n var fromRangeSize = fromHigh - fromLow;\n var toRangeSize = toHigh - toLow;\n var valueScale = (value - fromLow) / fromRangeSize;\n return toLow + (valueScale * toRangeSize);\n },\n\n // Interpolate two hex colors in a 0 - 1 range or optionally provide a\n // custom range with fromLow,fromHight. The output will be in hex by default\n // unless asRGB is true in which case it will be returned as an rgb string.\n interpolateColor:\n function(val, startColor, endColor, fromLow, fromHigh, asRGB) {\n fromLow = fromLow === undefined ? 0 : fromLow;\n fromHigh = fromHigh === undefined ? 1 : fromHigh;\n startColor = util.hexToRGB(startColor);\n endColor = util.hexToRGB(endColor);\n var r = Math.floor(\n util.mapValueInRange(val, fromLow, fromHigh, startColor.r, endColor.r)\n );\n var g = Math.floor(\n util.mapValueInRange(val, fromLow, fromHigh, startColor.g, endColor.g)\n );\n var b = Math.floor(\n util.mapValueInRange(val, fromLow, fromHigh, startColor.b, endColor.b)\n );\n if (asRGB) {\n return 'rgb(' + r + ',' + g + ',' + b + ')';\n } else {\n return util.rgbToHex(r, g, b);\n }\n },\n\n degreesToRadians: function(deg) {\n return (deg * Math.PI) / 180;\n },\n\n radiansToDegrees: function(rad) {\n return (rad * 180) / Math.PI;\n }\n\n }\n\n util.extend(util, MathUtil);\n\n\n // Utilities\n // ---------\n // Here are a few useful JavaScript utilities.\n\n // Lop off the first occurence of the reference in the Array.\n function removeFirst(array, item) {\n var idx = array.indexOf(item);\n idx != -1 && array.splice(idx, 1);\n }\n\n var _onFrame;\n if (typeof window !== 'undefined') {\n _onFrame = window.requestAnimationFrame ||\n window.webkitRequestAnimationFrame ||\n window.mozRequestAnimationFrame ||\n window.msRequestAnimationFrame ||\n window.oRequestAnimationFrame ||\n function(callback) {\n window.setTimeout(callback, 1000 / 60);\n };\n }\n if (!_onFrame && typeof process !== 'undefined' && process.title === 'node') {\n _onFrame = setImmediate;\n }\n\n // Cross browser/node timer functions.\n util.onFrame = function onFrame(func) {\n return _onFrame(func);\n };\n\n // Export the public api using exports for common js or the window for\n // normal browser inclusion.\n if (typeof exports != 'undefined') {\n util.extend(exports, rebound);\n } else if (typeof window != 'undefined') {\n window.rebound = rebound;\n }\n})();\n\n\n// Legal Stuff\n// -----------\n/**\n * Copyright (c) 2013, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n","'use strict';\n\n/**\n * Polygon.\n * Create a regular polygon and provide api to compute inscribed child.\n */\nclass Polygon {\n\n constructor(radius = 100, sides = 3, depth = 0, colors) {\n\n this._radius = radius;\n this._sides = sides;\n this._depth = depth;\n this._colors = colors;\n\n this._x = 0;\n this._y = 0;\n\n this.rotation = 0;\n this.scale = 1;\n\n // Get basePolygon points straight away.\n this.points = this._getRegularPolygonPoints();\n }\n\n /**\n * Get the points of any regular polygon based on\n * the number of sides and radius.\n */\n _getRegularPolygonPoints() {\n\n let points = [];\n\n let i = 0;\n\n while (i < this._sides) {\n // Note that sin and cos are inverted in order to draw\n // polygon pointing down like: ∇\n let x = -this._radius * Math.sin(i * 2 * Math.PI / this._sides);\n let y = this._radius * Math.cos(i * 2 * Math.PI / this._sides);\n\n points.push({x, y});\n\n i++;\n }\n\n return points;\n }\n\n /**\n * Get the inscribed polygon points by calling `getInterpolatedPoint`\n * for the points (start, end) of each side.\n */\n _getInscribedPoints(points, progress) {\n\n let inscribedPoints = [];\n\n points.forEach((item, i) => {\n\n let start = item;\n let end = points[i + 1];\n\n if (!end) {\n end = points[0];\n }\n\n let point = this._getInterpolatedPoint(start, end, progress);\n\n inscribedPoints.push(point);\n });\n\n return inscribedPoints;\n }\n\n /**\n * Get interpolated point using linear interpolation\n * on x and y axis.\n */\n _getInterpolatedPoint(start, end, progress) {\n\n let Ax = start.x;\n let Ay = start.y;\n\n let Bx = end.x;\n let By = end.y;\n\n // Linear interpolation formula:\n // point = start + (end - start) * progress;\n let Cx = Ax + (Bx - Ax) * progress;\n let Cy = Ay + (By - Ay) * progress;\n\n return {\n x: Cx,\n y: Cy\n };\n }\n\n /**\n * Update children points array.\n */\n _getUpdatedChildren(progress) {\n\n let children = [];\n\n for (let i = 0; i < this._depth; i++) {\n\n // Get basePolygon points on first lap\n // then get previous child points.\n let points = children[i - 1] || this.points;\n\n let inscribedPoints = this._getInscribedPoints(points, progress);\n\n children.push(inscribedPoints);\n }\n\n return children;\n }\n\n /**\n * Render children, first update children array,\n * then loop and draw each child.\n */\n renderChildren(context, progress) {\n\n let children = this._getUpdatedChildren(progress);\n\n // child = array of points at a certain progress over the parent sides.\n children.forEach((points, i) => {\n\n // Draw child.\n context.beginPath();\n points.forEach((point) => context.lineTo(point.x, point.y));\n context.closePath();\n\n\n // Set colors.\n let strokeColor = this._colors.stroke;\n let childColor = this._colors.child;\n\n if (strokeColor) {\n context.strokeStyle = strokeColor;\n context.stroke();\n }\n\n if (childColor) {\n let rgb = rebound.util.hexToRGB(childColor);\n\n let alphaUnit = 1 / children.length;\n let alpha = alphaUnit + (alphaUnit * i);\n\n let rgba = `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha})`;\n\n context.fillStyle = rgba;\n\n // Set Shadow.\n context.shadowColor = 'rgba(0,0,0, 0.1)';\n context.shadowBlur = 10;\n context.shadowOffsetX = 0;\n context.shadowOffsetY = 0;\n\n context.fill();\n }\n });\n }\n\n /**\n * Render.\n */\n render(context) {\n\n context.save();\n\n context.translate(this._x, this._y);\n\n if (this.rotation !== 0) {\n context.rotate(rebound.MathUtil.degreesToRadians(this.rotation));\n }\n\n if (this.scale !== 1) {\n context.scale(this.scale, this.scale);\n }\n\n // Draw basePolygon.\n context.beginPath();\n this.points.forEach((point) => context.lineTo(point.x, point.y));\n context.closePath();\n\n // Set colors.\n let strokeColor = this._colors.stroke;\n let childColor = this._colors.base;\n\n if (strokeColor) {\n context.strokeStyle = strokeColor;\n context.stroke();\n }\n\n if (childColor) {\n context.fillStyle = childColor;\n context.fill();\n }\n\n context.restore();\n }\n}\n","'use strict';\n\n/**\n * Spinner.\n * Create a canvas element, append it to the body, render polygon with\n * inscribed children, provide init and complete methods to control spinner.\n */\nclass Spinner {\n\n constructor(params) {\n\n let id = params.id,\n radius = params.radius,\n sides = params.sides,\n depth = params.depth,\n colors = params.colors,\n alwaysForward = params.alwaysForward,\n restAt = params.restAt,\n renderBase = params.renderBase;\n\n if (sides < 3) {\n console.warn('At least 3 sides required.');\n sides = 3;\n }\n\n this._canvas = document.createElement('canvas');\n this._canvas.style.backgroundColor = colors.background;\n\n this._canvasW = null;\n this._canvasH = null;\n this._canvasOpacity = 1;\n\n this._centerX = null;\n this._centerY = null;\n\n this._alwaysForward = alwaysForward;\n this._restThreshold = restAt;\n this._renderBase = renderBase;\n\n this._springRangeLow = 0;\n this._springRangeHigh = this._restThreshold || 1;\n\n // Instantiate basePolygon.\n this._basePolygon = new Polygon(radius, sides, depth, colors);\n\n this._progress = 0;\n\n this._isAutoSpin = null;\n this._isCompleting = null;\n }\n\n /**\n * Init spinner.\n */\n init(spring, autoSpin) {\n\n this._addCanvas();\n\n this._spring = spring;\n this._addSpringListener();\n\n this._isAutoSpin = autoSpin;\n\n if (autoSpin) {\n // Start auto spin.\n this._spin();\n } else {\n // Render first frame only.\n this._spring.setEndValue(0);\n this.render();\n }\n }\n\n _addCanvas() {\n document.body.appendChild(this._canvas);\n this._context = this._canvas.getContext('2d');\n this._setCanvasSize();\n }\n\n _setCanvasSize() {\n this._canvasW = this._canvas.width = window.innerWidth;\n this._canvasH = this._canvas.height = window.innerHeight;\n\n this._canvas.style.position = 'fixed';\n this._canvas.style.top = 0;\n this._canvas.style.left = 0;\n\n this._centerX = this._canvasW / 2;\n this._centerY = this._canvasH / 2;\n }\n\n _addSpringListener() {\n\n let ctx = this;\n\n // Add a listener to the spring. Every time the physics\n // solver updates the Spring's value onSpringUpdate will\n // be called.\n this._spring.addListener({\n onSpringUpdate(spring) {\n\n let val = spring.getCurrentValue();\n\n // Input range in the `from` parameters.\n let fromLow = 0,\n fromHigh = 1,\n // Property animation range in the `to` parameters.\n toLow = ctx._springRangeLow,\n toHigh = ctx._springRangeHigh;\n\n val = rebound.MathUtil.mapValueInRange(val, fromLow, fromHigh, toLow, toHigh);\n\n // Note that the render method is\n // called with the spring motion value.\n ctx.render(val);\n }\n });\n }\n\n /**\n * Start complete animation.\n */\n setComplete() {\n this._isCompleting = true;\n }\n\n _completeAnimation() {\n\n // Fade out the canvas.\n this._canvasOpacity -= 0.1;\n this._canvas.style.opacity = this._canvasOpacity;\n\n // Stop animation and remove canvas.\n if (this._canvasOpacity <= 0) {\n this._isAutoSpin = false;\n this._spring.setAtRest();\n this._canvas.remove();\n }\n }\n\n /**\n * Spin animation.\n */\n _spin() {\n\n if (this._alwaysForward) {\n\n let currentValue = this._spring.getCurrentValue();\n\n // Switch the animation range used to compute the value\n // in the `onSpringUpdate`, so to change the reverse animation\n // of the spring at a certain threshold.\n if (this._restThreshold && currentValue === 1) {\n this._switchSpringRange();\n }\n\n // In order to keep the motion going forward\n // when spring reach 1 reset to 0 at rest.\n if (currentValue === 1) {\n this._spring.setCurrentValue(0).setAtRest();\n }\n }\n\n // Restart the spinner.\n this._spring.setEndValue((this._spring.getCurrentValue() === 1) ? 0 : 1);\n }\n\n _switchSpringRange() {\n\n let threshold = this._restThreshold;\n\n this._springRangeLow = (this._springRangeLow === threshold) ? 0 : threshold;\n this._springRangeHigh = (this._springRangeHigh === threshold) ? 1 : threshold;\n }\n\n /**\n * Render.\n */\n render(progress) {\n\n // Update progess if present and round to 4th decimal.\n if (progress) {\n this._progress = Math.round(progress * 10000) / 10000;\n }\n\n // Restart the spin.\n if (this._isAutoSpin && this._spring.isAtRest()) {\n this._spin();\n }\n\n // Complete the animation.\n if (this._isCompleting) {\n this._completeAnimation();\n }\n\n // Clear canvas and save context.\n this._context.clearRect(0, 0, this._canvasW, this._canvasH);\n this._context.save();\n\n // Move to center.\n this._context.translate(this._centerX, this._centerY);\n\n this._context.lineWidth = 1.5;\n\n // Render basePolygon.\n if (this._renderBase) {\n this._basePolygon.render(this._context);\n }\n\n // Render inscribed polygons.\n this._basePolygon.renderChildren(this._context, this._progress);\n\n this._context.restore();\n }\n}\n","'use strict';\n\n// Custom SETTINGS for each demo in related index.html\nlet settings = SETTINGS || {\n rebound: {\n tension: 2,\n friction: 5\n },\n spinner: {\n radius: 80,\n sides: 3,\n depth: 4,\n colors: {\n background: '#000000',\n stroke: '#000000',\n base: '#222222',\n child: '#FFFFFF'\n },\n alwaysForward: true, // When false the spring will reverse normally.\n restAt: 0.5, // A number from 0.1 to 0.9 || null for full rotation\n renderBase: true // Optionally render basePolygon\n }\n};\n\n/**\n * Demo.\n */\nconst demo = {\n settings: settings,\n\n spring: null,\n spinner: null,\n\n /**\n * Initialize Rebound.js with settings.\n * Rebound is used to generate a spring which\n * is then used to animate the spinner.\n * See more: http://facebook.github.io/rebound-js/docs/rebound.html\n */\n initRebound() {\n\n let settings = demo.settings.rebound;\n\n // Create a SpringSystem.\n let springSystem = new rebound.SpringSystem();\n\n // Add a spring to the system.\n demo.spring = springSystem.createSpring(settings.tension, settings.friction);\n },\n\n /**\n * Initialize Spinner with settings.\n */\n initSpinner() {\n\n let settings = demo.settings.spinner;\n\n // Instantiate Spinner.\n demo.spinner = new Spinner(settings);\n },\n\n /**\n * Initialize demo.\n */\n init() {\n\n let spinnerTypeAutoSpin = true;\n\n // Instantiate animation engine and spinner system.\n demo.initRebound();\n demo.initSpinner();\n\n // Init animation with Rebound Spring System.\n demo.spinner.init(demo.spring, spinnerTypeAutoSpin);\n\n if (spinnerTypeAutoSpin) {\n // Fake loading time, in a real world just call demo.spinner.setComplete();\n // whenever the preload will be completed.\n setTimeout(() => {\n demo.spinner.setComplete();\n }, 6000);\n } else {\n // Perform real ajax request.\n demo.loadSomething();\n }\n },\n\n /**\n * Ajax Request.\n */\n loadSomething() {\n\n let oReq = new XMLHttpRequest();\n\n oReq.addEventListener('progress', (oEvent) => {\n if (oEvent.lengthComputable) {\n\n let percent = Math.ceil(oEvent.loaded / oEvent.total * 100);\n console.log('ajax loding percent', percent);\n\n // By setting the end value with the actual loading percentage\n // the spinner will progress based on the actual ajax loading time.\n demo.spring.setEndValue(percent * 0.01);\n }\n });\n\n oReq.addEventListener('load', (e) => {\n // Complete the loading animation.\n demo.spinner.setComplete();\n });\n\n oReq.open('GET', '/img/something.jpg');\n oReq.send();\n }\n};\n"],"sourceRoot":"/source/"}