UNPKG

gsap

Version:

GSAP is a JavaScript library for building high-performance animations that work in **every** major browser. Animate CSS, SVG, canvas, React, Vue, WebGL, colors, strings, motion paths, generic objects...anything JavaScript can touch! No other library deliv

1,767 lines (1,482 loc) 143 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = global || self, factory(global.window = global.window || {})); }(this, (function (exports) { 'use strict'; function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } /*! * GSAP 3.0.4 * https://greensock.com * * @license Copyright 2008-2019, GreenSock. All rights reserved. * Subject to the terms at https://greensock.com/standard-license or for * Club GreenSock members, the agreement issued with that membership. * @author: Jack Doyle, jack@greensock.com */ var _config = { autoSleep: 120, force3D: "auto", nullTargetWarn: 1, units: { lineHeight: "" } }, _defaults = { duration: .5, overwrite: false, delay: 0 }, _bigNum = 1e8, _tinyNum = 1 / _bigNum, _2PI = Math.PI * 2, _HALF_PI = _2PI / 4, _gsID = 0, _sqrt = Math.sqrt, _cos = Math.cos, _sin = Math.sin, _isString = function _isString(value) { return typeof value === "string"; }, _isFunction = function _isFunction(value) { return typeof value === "function"; }, _isNumber = function _isNumber(value) { return typeof value === "number"; }, _isUndefined = function _isUndefined(value) { return typeof value === "undefined"; }, _isObject = function _isObject(value) { return typeof value === "object"; }, _isNotFalse = function _isNotFalse(value) { return value !== false; }, _windowExists = function _windowExists() { return typeof window !== "undefined"; }, _isFuncOrString = function _isFuncOrString(value) { return _isFunction(value) || _isString(value); }, _isArray = Array.isArray, _strictNumExp = /(?:-?\.?\d|\.)+/gi, _numExp = /[-+=\.]*\d+[\.e\-\+]*\d*[e\-\+]*\d*/gi, _complexStringNumExp = /[-+=\.]*\d+(?:\.|e-|e)*\d*/gi, _parenthesesExp = /\(([^()]+)\)/i, _relExp = /[\+-]=-?[\.\d]+/, _delimitedValueExp = /[#\-+\.]*\b[a-z\d-=+%.]+/gi, _globalTimeline, _win, _coreInitted, _doc, _globals = {}, _installScope = {}, _coreReady, _install = function _install(scope) { return (_installScope = _merge(scope, _globals)) && gsap; }, _missingPlugin = function _missingPlugin(property, value) { return console.warn("Invalid property", property, "set to", value, "Missing plugin? gsap.registerPlugin()"); }, _warn = function _warn(message, suppress) { return !suppress && console.warn(message); }, _addGlobal = function _addGlobal(name, obj) { return name && (_globals[name] = obj) && _installScope && (_installScope[name] = obj) || _globals; }, _emptyFunc = function _emptyFunc() { return 0; }, _reservedProps = {}, _lazyTweens = [], _lazyLookup = {}, _plugins = {}, _effects = {}, _nextGCFrame = 30, _harnessPlugins = [], _callbackNames = "onComplete,onUpdate,onStart,onRepeat,onReverseComplete,onInterrupt", _harness = function _harness(targets) { var target = targets[0], harnessPlugin, i; if (!_isObject(target) && !_isFunction(target)) { targets = [targets]; } if (!(harnessPlugin = (target._gsap || {}).harness)) { i = _harnessPlugins.length; while (i-- && !_harnessPlugins[i].targetTest(target)) {} harnessPlugin = _harnessPlugins[i]; } i = targets.length; while (i--) { targets[i] && (targets[i]._gsap || (targets[i]._gsap = new GSCache(targets[i], harnessPlugin))) || targets.splice(i, 1); } return targets; }, _getCache = function _getCache(target) { return target._gsap || _harness(toArray(target))[0]._gsap; }, _getProperty = function _getProperty(target, property) { var currentValue = target[property]; return _isFunction(currentValue) ? target[property]() : _isUndefined(currentValue) && target.getAttribute(property) || currentValue; }, _forEachName = function _forEachName(names, func) { return (names = names.split(",")).forEach(func) || names; }, _round = function _round(value) { return Math.round(value * 10000) / 10000; }, _arrayContainsAny = function _arrayContainsAny(toSearch, toFind) { var l = toFind.length, i = 0; for (; toSearch.indexOf(toFind[i]) < 0 && ++i < l;) {} return i < l; }, _parseVars = function _parseVars(params, type, parent) { var isLegacy = _isNumber(params[1]), varsIndex = (isLegacy ? 2 : 1) + (type < 2 ? 0 : 1), vars = params[varsIndex], i; if (isLegacy) { vars.duration = params[1]; } if (type === 1) { vars.runBackwards = 1; vars.immediateRender = _isNotFalse(vars.immediateRender); } else if (type === 2) { i = params[varsIndex - 1]; vars.startAt = i; vars.immediateRender = _isNotFalse(vars.immediateRender); } vars.parent = parent; return vars; }, _lazyRender = function _lazyRender() { var l = _lazyTweens.length, a = _lazyTweens.slice(0), i, tween; _lazyLookup = {}; _lazyTweens.length = 0; for (i = 0; i < l; i++) { tween = a[i]; if (tween && tween._lazy) { tween.render(tween._lazy[0], tween._lazy[1], true)._lazy = 0; } } }, _lazySafeRender = function _lazySafeRender(animation, time, suppressEvents, force) { if (_lazyTweens.length) { _lazyRender(); } animation.render(time, suppressEvents, force); if (_lazyTweens.length) { _lazyRender(); } }, _numericIfPossible = function _numericIfPossible(value) { var n = parseFloat(value); return n || n === 0 ? n : value; }, _passThrough = function _passThrough(p) { return p; }, _setDefaults = function _setDefaults(obj, defaults) { for (var p in defaults) { if (!(p in obj)) { obj[p] = defaults[p]; } } return obj; }, _setKeyframeDefaults = function _setKeyframeDefaults(obj, defaults) { for (var p in defaults) { if (!(p in obj) && p !== "duration" && p !== "ease") { obj[p] = defaults[p]; } } }, _merge = function _merge(base, toMerge) { for (var p in toMerge) { base[p] = toMerge[p]; } return base; }, _mergeDeep = function _mergeDeep(base, toMerge) { for (var p in toMerge) { base[p] = _isObject(toMerge[p]) ? _mergeDeep(base[p] || (base[p] = {}), toMerge[p]) : toMerge[p]; } return base; }, _copyExcluding = function _copyExcluding(obj, excluding) { var copy = {}, p; for (p in obj) { if (!(p in excluding)) { copy[p] = obj[p]; } } return copy; }, _inheritDefaults = function _inheritDefaults(vars) { var parent = vars.parent || _globalTimeline, func = vars.keyframes ? _setKeyframeDefaults : _setDefaults; if (_isNotFalse(vars.inherit)) { while (parent) { func(vars, parent.vars.defaults); parent = parent.parent; } } return vars; }, _arraysMatch = function _arraysMatch(a1, a2) { var i = a1.length, match = i === a2.length; while (match && i-- && a1[i] === a2[i]) {} return i < 0; }, _addLinkedListItem = function _addLinkedListItem(parent, child, firstProp, lastProp, sortBy) { if (firstProp === void 0) { firstProp = "_first"; } if (lastProp === void 0) { lastProp = "_last"; } var prev = parent[lastProp], t; if (sortBy) { t = child[sortBy]; while (prev && prev[sortBy] > t) { prev = prev._prev; } } if (prev) { child._next = prev._next; prev._next = child; } else { child._next = parent[firstProp]; parent[firstProp] = child; } if (child._next) { child._next._prev = child; } else { parent[lastProp] = child; } child._prev = prev; child.parent = parent; return child; }, _removeLinkedListItem = function _removeLinkedListItem(parent, child, firstProp, lastProp) { if (firstProp === void 0) { firstProp = "_first"; } if (lastProp === void 0) { lastProp = "_last"; } var prev = child._prev, next = child._next; if (prev) { prev._next = next; } else if (parent[firstProp] === child) { parent[firstProp] = next; } if (next) { next._prev = prev; } else if (parent[lastProp] === child) { parent[lastProp] = prev; } child._dp = parent; child._next = child._prev = child.parent = null; }, _removeFromParent = function _removeFromParent(child, onlyIfParentHasAutoRemove) { if (child.parent && (!onlyIfParentHasAutoRemove || child.parent.autoRemoveChildren)) { child.parent.remove(child); } child._act = 0; }, _uncache = function _uncache(animation) { var a = animation; while (a) { a._dirty = 1; a = a.parent; } return animation; }, _recacheAncestors = function _recacheAncestors(animation) { var parent = animation.parent; while (parent && parent.parent) { parent._dirty = 1; parent.totalDuration(); parent = parent.parent; } return animation; }, _hasNoPausedAncestors = function _hasNoPausedAncestors(animation) { return !animation || animation._ts && _hasNoPausedAncestors(animation.parent); }, _elapsedCycleDuration = function _elapsedCycleDuration(animation) { return animation._repeat ? _animationCycle(animation._tTime, animation = animation.duration() + animation._rDelay) * animation : 0; }, _animationCycle = function _animationCycle(tTime, cycleDuration) { return (tTime /= cycleDuration) && ~~tTime === tTime ? ~~tTime - 1 : ~~tTime; }, _parentToChildTotalTime = function _parentToChildTotalTime(parentTime, child) { return child._ts > 0 ? (parentTime - child._start) * child._ts : (child._dirty ? child.totalDuration() : child._tDur) + (parentTime - child._start) * child._ts; }, _addToTimeline = function _addToTimeline(timeline, child, position) { child.parent && _removeFromParent(child); child._start = position + child._delay; child._end = child._start + (child.totalDuration() / child._ts || 0); _addLinkedListItem(timeline, child, "_first", "_last", timeline._sort ? "_start" : 0); timeline._recent = child; if (child._time || !child._dur && child._initted) { var curTime = (timeline.rawTime() - child._start) * child._ts; if (!child._dur || _clamp(0, child.totalDuration(), curTime) - child._tTime > _tinyNum) { child.render(curTime, true); } } _uncache(timeline); if (timeline._dp && timeline._time >= timeline._dur && timeline._ts && timeline._dur < timeline.duration()) { var tl = timeline; while (tl._dp) { tl.totalTime(tl._tTime, true); tl = tl._dp; } } return timeline; }, _attemptInitTween = function _attemptInitTween(tween, totalTime, force, suppressEvents) { _initTween(tween, totalTime); if (!tween._initted) { return 1; } if (!force && tween._pt && (tween._dur && tween.vars.lazy !== false || !tween._dur && tween.vars.lazy)) { _lazyTweens.push(tween); tween._lazy = [totalTime, suppressEvents]; return 1; } }, _renderZeroDurationTween = function _renderZeroDurationTween(tween, totalTime, suppressEvents, force) { var prevRatio = tween._zTime < 0 ? 0 : 1, ratio = totalTime < 0 ? 0 : 1, repeatDelay = tween._rDelay, tTime = 0, pt, iteration, prevIteration; if (repeatDelay && tween._repeat) { tTime = _clamp(0, tween._tDur, totalTime); iteration = _animationCycle(tTime, repeatDelay); prevIteration = _animationCycle(tween._tTime, repeatDelay); if (iteration !== prevIteration) { prevRatio = 1 - ratio; if (tween.vars.repeatRefresh && tween._initted) { tween.invalidate(); } } } if (!tween._initted && _attemptInitTween(tween, totalTime, force, suppressEvents)) { return; } if (ratio !== prevRatio || force || tween._zTime === _tinyNum || !totalTime && tween._zTime) { tween._zTime = totalTime || (suppressEvents ? _tinyNum : 0); tween.ratio = ratio; if (tween._from) { ratio = 1 - ratio; } tween._time = 0; tween._tTime = tTime; if (!suppressEvents) { _callback(tween, "onStart"); } pt = tween._pt; while (pt) { pt.r(ratio, pt.d); pt = pt._next; } if (!ratio && tween._startAt && !tween._onUpdate && tween._start) { tween._startAt.render(totalTime, true, force); } if (tween._onUpdate && !suppressEvents) { _callback(tween, "onUpdate"); } if (tTime && tween._repeat && !suppressEvents && tween.parent) { _callback(tween, "onRepeat"); } if ((totalTime >= tween._tDur || totalTime < 0) && tween.ratio === ratio) { tween.ratio && _removeFromParent(tween, 1); if (!suppressEvents) { _callback(tween, tween.ratio ? "onComplete" : "onReverseComplete", true); tween._prom && tween._prom(); } } } }, _findNextPauseTween = function _findNextPauseTween(animation, prevTime, time) { var child; if (time > prevTime) { child = animation._first; while (child && child._start <= time) { if (!child._dur && child.data === "isPause" && child._start > prevTime) { return child; } child = child._next; } } else { child = animation._last; while (child && child._start >= time) { if (!child._dur && child.data === "isPause" && child._start < prevTime) { return child; } child = child._prev; } } }, _onUpdateTotalDuration = function _onUpdateTotalDuration(animation) { if (animation instanceof Timeline) { return _uncache(animation); } var repeat = animation._repeat; animation._tDur = !repeat ? animation._dur : repeat < 0 ? 1e20 : _round(animation._dur * (repeat + 1) + animation._rDelay * repeat); _uncache(animation.parent); return animation; }, _zeroPosition = { _start: 0, endTime: _emptyFunc }, _parsePosition = function _parsePosition(animation, position, useBuildFrom) { var labels = animation.labels, recent = animation._recent || _zeroPosition, clippedDuration = animation.duration() >= _bigNum ? recent.endTime(false) : animation._dur, i, offset; if (_isString(position) && (isNaN(position) || position in labels)) { i = position.charAt(0); if (i === "<" || i === ">") { return (i === "<" ? recent._start : recent.endTime(recent._repeat >= 0)) + (parseFloat(position.substr(1)) || 0); } i = position.indexOf("="); if (i < 0) { if (!(position in labels)) { labels[position] = clippedDuration; } return labels[position]; } offset = +(position.charAt(i - 1) + position.substr(i + 1)); return i > 1 ? _parsePosition(animation, position.substr(0, i - 1)) + offset : clippedDuration + offset; } return position == null ? clippedDuration : +position; }, _conditionalReturn = function _conditionalReturn(value, func) { return value || value === 0 ? func(value) : func; }, _clamp = function _clamp(min, max, value) { return value < min ? min : value > max ? max : value; }, getUnit = function getUnit(value) { return (value + "").substr((parseFloat(value) + "").length); }, clamp = function clamp(min, max, value) { return _conditionalReturn(value, function (v) { return _clamp(min, max, v); }); }, _slice = [].slice, _isArrayLike = function _isArrayLike(value) { return value && _isObject(value) && "length" in value && value.length - 1 in value && _isObject(value[0]) && !value.nodeType && value !== _win; }, _flatten = function _flatten(ar, leaveStrings, accumulator) { if (accumulator === void 0) { accumulator = []; } return ar.forEach(function (value) { var _accumulator; return _isString(value) && !leaveStrings || _isArrayLike(value) ? (_accumulator = accumulator).push.apply(_accumulator, toArray(value)) : accumulator.push(value); }) || accumulator; }, toArray = function toArray(value, leaveStrings) { return _isString(value) && !leaveStrings && (_coreInitted || !_wake()) ? _slice.call(_doc.querySelectorAll(value), 0) : _isArray(value) ? _flatten(value, leaveStrings) : _isArrayLike(value) ? _slice.call(value, 0) : value ? [value] : []; }, distribute = function distribute(v) { if (_isFunction(v)) { return v; } var vars = _isObject(v) ? v : { each: v }, ease = _parseEase(vars.ease), from = vars.from || 0, base = parseFloat(vars.base) || 0, cache = {}, isDecimal = from > 0 && from < 1, ratios = isNaN(from) || isDecimal, axis = vars.axis, ratioX = from, ratioY = from; if (_isString(from)) { ratioX = ratioY = { center: .5, edges: .5, end: 1 }[from] || 0; } else if (!isDecimal && ratios) { ratioX = from[0]; ratioY = from[1]; } return function (i, target, a) { var l = (a || vars).length, distances = cache[l], originX, originY, x, y, d, j, max, min, wrapAt; if (!distances) { wrapAt = vars.grid === "auto" ? 0 : (vars.grid || [1, _bigNum])[1]; if (!wrapAt) { max = -_bigNum; while (max < (max = a[wrapAt++].getBoundingClientRect().left) && wrapAt < l) {} wrapAt--; } distances = cache[l] = []; originX = ratios ? Math.min(wrapAt, l) * ratioX - .5 : from % wrapAt; originY = ratios ? l * ratioY / wrapAt - .5 : from / wrapAt | 0; max = 0; min = _bigNum; for (j = 0; j < l; j++) { x = j % wrapAt - originX; y = originY - (j / wrapAt | 0); distances[j] = d = !axis ? _sqrt(x * x + y * y) : Math.abs(axis === "y" ? y : x); if (d > max) { max = d; } if (d < min) { min = d; } } distances.max = max - min; distances.min = min; distances.v = l = (parseFloat(vars.amount) || parseFloat(vars.each) * (wrapAt > l ? l - 1 : !axis ? Math.max(wrapAt, l / wrapAt) : axis === "y" ? l / wrapAt : wrapAt) || 0) * (from === "edges" ? -1 : 1); distances.b = l < 0 ? base - l : base; distances.u = getUnit(vars.amount || vars.each) || 0; ease = ease && l < 0 ? _invertEase(ease) : ease; } l = (distances[i] - distances.min) / distances.max || 0; return _round(distances.b + (ease ? ease(l) : l) * distances.v) + distances.u; }; }, _roundModifier = function _roundModifier(v) { var p = v < 1 ? Math.pow(10, (v + "").length - 2) : 1; return function (raw) { return ~~(Math.round(parseFloat(raw) / v) * v * p) / p + (_isNumber(raw) ? 0 : getUnit(raw)); }; }, snap = function snap(snapTo, value) { var isArray = _isArray(snapTo), radius, is2D; if (!isArray && _isObject(snapTo)) { radius = isArray = snapTo.radius || _bigNum; snapTo = toArray(snapTo.values); if (is2D = !_isNumber(snapTo[0])) { radius *= radius; } } return _conditionalReturn(value, !isArray ? _roundModifier(snapTo) : function (raw) { var x = parseFloat(is2D ? raw.x : raw), y = parseFloat(is2D ? raw.y : 0), min = _bigNum, closest = 0, i = snapTo.length, dx, dy; while (i--) { if (is2D) { dx = snapTo[i].x - x; dy = snapTo[i].y - y; dx = dx * dx + dy * dy; } else { dx = Math.abs(snapTo[i] - x); } if (dx < min) { min = dx; closest = i; } } closest = !radius || min <= radius ? snapTo[closest] : raw; return is2D || closest === raw || _isNumber(raw) ? closest : closest + getUnit(raw); }); }, random = function random(min, max, roundingIncrement, returnFunction) { return _conditionalReturn(_isArray(min) ? !max : roundingIncrement === true ? !!(roundingIncrement = 0) : !returnFunction, function () { return _isArray(min) ? min[~~(Math.random() * min.length)] : (roundingIncrement = roundingIncrement || 1e-5) && (returnFunction = roundingIncrement < 1 ? Math.pow(10, (roundingIncrement + "").length - 2) : 1) && ~~(Math.round((min + Math.random() * (max - min)) / roundingIncrement) * roundingIncrement * returnFunction) / returnFunction; }); }, pipe = function pipe() { for (var _len = arguments.length, functions = new Array(_len), _key = 0; _key < _len; _key++) { functions[_key] = arguments[_key]; } return function (value) { return functions.reduce(function (v, f) { return f(v); }, value); }; }, unitize = function unitize(func, unit) { return function (value) { return func(parseFloat(value)) + (unit || getUnit(value)); }; }, normalize = function normalize(min, max, value) { return mapRange(min, max, 0, 1, value); }, _wrapArray = function _wrapArray(a, wrapper, value) { return _conditionalReturn(value, function (index) { return a[~~wrapper(index)]; }); }, wrap = function wrap(min, max, value) { var range = max - min; return _isArray(min) ? _wrapArray(min, wrap(0, min.length), max) : _conditionalReturn(value, function (value) { return (range + (value - min) % range) % range + min; }); }, wrapYoyo = function wrapYoyo(min, max, value) { var range = max - min, total = range * 2; return _isArray(min) ? _wrapArray(min, wrapYoyo(0, min.length - 1), max) : _conditionalReturn(value, function (value) { value = (total + (value - min) % total) % total; return min + (value > range ? total - value : value); }); }, _replaceRandom = function _replaceRandom(value) { var prev = 0, s = "", i, nums, end, isArray; while (~(i = value.indexOf("random(", prev))) { end = value.indexOf(")", i); isArray = value.charAt(i + 7) === "["; nums = value.substr(i + 7, end - i - 7).match(isArray ? _delimitedValueExp : _strictNumExp); s += value.substr(prev, i - prev) + random(isArray ? nums : +nums[0], +nums[1], +nums[2] || 1e-5); prev = end + 1; } return s + value.substr(prev, value.length - prev); }, mapRange = function mapRange(inMin, inMax, outMin, outMax, value) { var inRange = inMax - inMin, outRange = outMax - outMin; return _conditionalReturn(value, function (value) { return outMin + (value - inMin) / inRange * outRange; }); }, interpolate = function interpolate(start, end, progress, mutate) { var func = isNaN(start + end) ? 0 : function (p) { return (1 - p) * start + p * end; }; if (!func) { var isString = _isString(start), master = {}, p, i, interpolators, l, il; progress === true && (mutate = 1) && (progress = null); if (isString) { start = { p: start }; end = { p: end }; } else if (_isArray(start) && !_isArray(end)) { interpolators = []; l = start.length; il = l - 2; for (i = 1; i < l; i++) { interpolators.push(interpolate(start[i - 1], start[i])); } l--; func = function func(p) { p *= l; var i = Math.min(il, ~~p); return interpolators[i](p - i); }; progress = end; } else if (!mutate) { start = _merge(_isArray(start) ? [] : {}, start); } if (!interpolators) { for (p in end) { _addPropTween.call(master, start, p, "get", end[p]); } func = function func(p) { return _renderPropTweens(p, master) || (isString ? start.p : start); }; } } return _conditionalReturn(progress, func); }, _getLabelInDirection = function _getLabelInDirection(timeline, fromTime, backward) { var labels = timeline.labels, min = _bigNum, p, distance, label; for (p in labels) { distance = labels[p] - fromTime; if (distance < 0 === !!backward && distance && min > (distance = Math.abs(distance))) { label = p; min = distance; } } return label; }, _callback = function _callback(animation, type, executeLazyFirst) { var v = animation.vars, callback = v[type], params, scope; if (!callback) { return; } params = v[type + "Params"]; scope = v.callbackScope || animation; if (executeLazyFirst && _lazyTweens.length) { _lazyRender(); } return params ? callback.apply(scope, params) : callback.call(scope); }, _interrupt = function _interrupt(animation) { _removeFromParent(animation); if (animation.progress() < 1) { _callback(animation, "onInterrupt"); } return animation; }, _quickTween, _createPlugin = function _createPlugin(config) { config = !config.name && config["default"] || config; var name = config.name, isFunc = _isFunction(config), Plugin = name && !isFunc && config.init ? function () { this._props = []; } : config, instanceDefaults = { init: _emptyFunc, render: _renderPropTweens, add: _addPropTween, kill: _killPropTweensOf, modifier: _addPluginModifier, rawVars: 0 }, statics = { targetTest: 0, get: 0, getSetter: _getSetter, aliases: {}, register: 0 }; _wake(); if (config !== Plugin) { if (_plugins[name]) { return; } _setDefaults(Plugin, _setDefaults(_copyExcluding(config, instanceDefaults), statics)); _merge(Plugin.prototype, _merge(instanceDefaults, _copyExcluding(config, statics))); _plugins[Plugin.prop = name] = Plugin; if (config.targetTest) { _harnessPlugins.push(Plugin); _reservedProps[name] = 1; } name = (name === "css" ? "CSS" : name.charAt(0).toUpperCase() + name.substr(1)) + "Plugin"; } _addGlobal(name, Plugin); if (config.register) { config.register(gsap, Plugin, PropTween); } }, _255 = 255, _colorLookup = { aqua: [0, _255, _255], lime: [0, _255, 0], silver: [192, 192, 192], black: [0, 0, 0], maroon: [128, 0, 0], teal: [0, 128, 128], blue: [0, 0, _255], navy: [0, 0, 128], white: [_255, _255, _255], olive: [128, 128, 0], yellow: [_255, _255, 0], orange: [_255, 165, 0], gray: [128, 128, 128], purple: [128, 0, 128], green: [0, 128, 0], red: [_255, 0, 0], pink: [_255, 192, 203], cyan: [0, _255, _255], transparent: [_255, _255, _255, 0] }, _hue = function _hue(h, m1, m2) { h = h < 0 ? h + 1 : h > 1 ? h - 1 : h; return (h * 6 < 1 ? m1 + (m2 - m1) * h * 6 : h < .5 ? m2 : h * 3 < 2 ? m1 + (m2 - m1) * (2 / 3 - h) * 6 : m1) * _255 + .5 | 0; }, splitColor = function splitColor(v, toHSL) { var a = !v ? _colorLookup.black : _isNumber(v) ? [v >> 16, v >> 8 & _255, v & _255] : 0, r, g, b, h, s, l, max, min, d, wasHSL; if (!a) { if (v.substr(-1) === ",") { v = v.substr(0, v.length - 1); } if (_colorLookup[v]) { a = _colorLookup[v]; } else if (v.charAt(0) === "#") { if (v.length === 4) { r = v.charAt(1); g = v.charAt(2); b = v.charAt(3); v = "#" + r + r + g + g + b + b; } v = parseInt(v.substr(1), 16); a = [v >> 16, v >> 8 & _255, v & _255]; } else if (v.substr(0, 3) === "hsl") { a = wasHSL = v.match(_strictNumExp); if (!toHSL) { h = +a[0] % 360 / 360; s = +a[1] / 100; l = +a[2] / 100; g = l <= .5 ? l * (s + 1) : l + s - l * s; r = l * 2 - g; if (a.length > 3) { a[3] *= 1; } a[0] = _hue(h + 1 / 3, r, g); a[1] = _hue(h, r, g); a[2] = _hue(h - 1 / 3, r, g); } else if (~v.indexOf("=")) { return v.match(_numExp); } } else { a = v.match(_strictNumExp) || _colorLookup.transparent; } a = a.map(Number); } if (toHSL && !wasHSL) { r = a[0] / _255; g = a[1] / _255; b = a[2] / _255; max = Math.max(r, g, b); min = Math.min(r, g, b); l = (max + min) / 2; if (max === min) { h = s = 0; } else { d = max - min; s = l > 0.5 ? d / (2 - max - min) : d / (max + min); h = max === r ? (g - b) / d + (g < b ? 6 : 0) : max === g ? (b - r) / d + 2 : (r - g) / d + 4; h *= 60; } a[0] = h + .5 | 0; a[1] = s * 100 + .5 | 0; a[2] = l * 100 + .5 | 0; } return a; }, _formatColors = function _formatColors(s, toHSL) { var colors = (s + "").match(_colorExp), charIndex = 0, parsed = "", i, color, temp; if (!colors) { return s; } for (i = 0; i < colors.length; i++) { color = colors[i]; temp = s.substr(charIndex, s.indexOf(color, charIndex) - charIndex); charIndex += temp.length + color.length; color = splitColor(color, toHSL); if (color.length === 3) { color.push(1); } parsed += temp + (toHSL ? "hsla(" + color[0] + "," + color[1] + "%," + color[2] + "%," + color[3] : "rgba(" + color.join(",")) + ")"; } return parsed + s.substr(charIndex); }, _colorExp = function () { var s = "(?:\\b(?:(?:rgb|rgba|hsl|hsla)\\(.+?\\))|\\B#(?:[0-9a-f]{3}){1,2}\\b", p; for (p in _colorLookup) { s += "|" + p + "\\b"; } return new RegExp(s + ")", "gi"); }(), _hslExp = /hsl[a]?\(/, _colorStringFilter = function _colorStringFilter(a) { var combined = a.join(" "), toHSL; _colorExp.lastIndex = 0; if (_colorExp.test(combined)) { toHSL = _hslExp.test(combined); a[0] = _formatColors(a[0], toHSL); a[1] = _formatColors(a[1], toHSL); } }, _tickerActive, _ticker = function () { var _getTime = Date.now, _lagThreshold = 500, _adjustedLag = 33, _startTime = _getTime(), _lastUpdate = _startTime, _gap = 1 / 60, _nextTime = _gap, _listeners = [], _id, _req, _raf, _self, _tick = function _tick(v) { var elapsed = _getTime() - _lastUpdate, manual = v === true, overlap, dispatch; if (elapsed > _lagThreshold) { _startTime += elapsed - _adjustedLag; } _lastUpdate += elapsed; _self.time = (_lastUpdate - _startTime) / 1000; overlap = _self.time - _nextTime; if (overlap > 0 || manual) { _self.frame++; _nextTime += overlap + (overlap >= _gap ? 0.004 : _gap - overlap); dispatch = 1; } if (!manual) { _id = _req(_tick); } if (dispatch) { _listeners.forEach(function (l) { return l(_self.time, elapsed, _self.frame, v); }); } }; _self = { time: 0, frame: 0, tick: function tick() { _tick(true); }, wake: function wake() { if (_coreReady) { if (!_coreInitted && _windowExists()) { _win = _coreInitted = window; _doc = _win.document || {}; _globals.gsap = gsap; (_win.gsapVersions || (_win.gsapVersions = [])).push(gsap.version); _install(_installScope || _win.GreenSockGlobals || !_win.gsap && _win || {}); _raf = _win.requestAnimationFrame; } _id && _self.sleep(); _req = _raf || function (f) { return setTimeout(f, (_nextTime - _self.time) * 1000 + 1 | 0); }; _tickerActive = 1; _tick(2); } }, sleep: function sleep() { (_raf ? _win.cancelAnimationFrame : clearTimeout)(_id); _tickerActive = 0; _req = _emptyFunc; }, lagSmoothing: function lagSmoothing(threshold, adjustedLag) { _lagThreshold = threshold || 1 / _tinyNum; _adjustedLag = Math.min(adjustedLag, _lagThreshold, 0); }, fps: function fps(_fps) { _gap = 1 / (_fps || 60); _nextTime = _self.time + _gap; }, add: function add(callback) { _listeners.indexOf(callback) < 0 && _listeners.push(callback); _wake(); }, remove: function remove(callback) { var i; ~(i = _listeners.indexOf(callback)) && _listeners.splice(i, 1); }, _listeners: _listeners }; return _self; }(), _wake = function _wake() { return !_tickerActive && _ticker.wake(); }, _easeMap = {}, _customEaseExp = /^[\d.\-M][\d.\-,\s]/, _quotesExp = /["']/g, _parseObjectInString = function _parseObjectInString(value) { var obj = {}, split = value.substr(1, value.length - 3).split(":"), key = split[0], i = 1, l = split.length, index, val, parsedVal; for (; i < l; i++) { val = split[i]; index = i !== l - 1 ? val.lastIndexOf(",") : val.length; parsedVal = val.substr(0, index); obj[key] = isNaN(parsedVal) ? parsedVal.replace(_quotesExp, "").trim() : +parsedVal; key = val.substr(index + 1).trim(); } return obj; }, _configEaseFromString = function _configEaseFromString(name) { var split = (name + "").split("("), ease = _easeMap[split[0]]; return ease && split.length > 1 && ease.config ? ease.config.apply(null, ~name.indexOf("{") ? [_parseObjectInString(split[1])] : _parenthesesExp.exec(name)[1].split(",").map(_numericIfPossible)) : _easeMap._CE && _customEaseExp.test(name) ? _easeMap._CE("", name) : ease; }, _invertEase = function _invertEase(ease) { return function (p) { return 1 - ease(1 - p); }; }, _parseEase = function _parseEase(ease, defaultEase) { return !ease ? defaultEase : (_isFunction(ease) ? ease : _easeMap[ease] || _configEaseFromString(ease)) || defaultEase; }, _insertEase = function _insertEase(names, easeIn, easeOut, easeInOut) { if (easeOut === void 0) { easeOut = function easeOut(p) { return 1 - easeIn(1 - p); }; } if (easeInOut === void 0) { easeInOut = function easeInOut(p) { return p < .5 ? easeIn(p * 2) / 2 : 1 - easeIn((1 - p) * 2) / 2; }; } var ease = { easeIn: easeIn, easeOut: easeOut, easeInOut: easeInOut }, lowercaseName; _forEachName(names, function (name) { _easeMap[name] = _globals[name] = ease; _easeMap[lowercaseName = name.toLowerCase()] = easeOut; for (var p in ease) { _easeMap[lowercaseName + (p === "easeIn" ? ".in" : p === "easeOut" ? ".out" : ".inOut")] = _easeMap[name + "." + p] = ease[p]; } }); return ease; }, _easeInOutFromOut = function _easeInOutFromOut(easeOut) { return function (p) { return p < .5 ? (1 - easeOut(1 - p * 2)) / 2 : .5 + easeOut((p - .5) * 2) / 2; }; }, _configElastic = function _configElastic(type, amplitude, period) { var p1 = amplitude >= 1 ? amplitude : 1, p2 = (period || (type ? .3 : .45)) / (amplitude < 1 ? amplitude : 1), p3 = p2 / _2PI * (Math.asin(1 / p1) || 0), easeOut = function easeOut(p) { return p === 1 ? 1 : p1 * Math.pow(2, -10 * p) * _sin((p - p3) * p2) + 1; }, ease = type === "out" ? easeOut : type === "in" ? function (p) { return 1 - easeOut(1 - p); } : _easeInOutFromOut(easeOut); p2 = _2PI / p2; ease.config = function (amplitude, period) { return _configElastic(type, amplitude, period); }; return ease; }, _configBack = function _configBack(type, overshoot) { if (overshoot === void 0) { overshoot = 1.70158; } var easeOut = function easeOut(p) { return --p * p * ((overshoot + 1) * p + overshoot) + 1; }, ease = type === "out" ? easeOut : type === "in" ? function (p) { return 1 - easeOut(1 - p); } : _easeInOutFromOut(easeOut); ease.config = function (overshoot) { return _configBack(type, overshoot); }; return ease; }; _forEachName("Linear,Quad,Cubic,Quart,Quint,Strong", function (name, i) { var power = i < 5 ? i + 1 : i; _insertEase(name + ",Power" + (power - 1), i ? function (p) { return Math.pow(p, power); } : function (p) { return p; }, function (p) { return 1 - Math.pow(1 - p, power); }, function (p) { return p < .5 ? Math.pow(p * 2, power) / 2 : 1 - Math.pow((1 - p) * 2, power) / 2; }); }); _easeMap.Linear.easeNone = _easeMap.none = _easeMap.Linear.easeIn; _insertEase("Elastic", _configElastic("in"), _configElastic("out"), _configElastic()); (function (n, c) { var n1 = 1 / c, n2 = 2 * n1, n3 = 2.5 * n1, easeOut = function easeOut(p) { return p < n1 ? n * p * p : p < n2 ? n * Math.pow(p - 1.5 / c, 2) + .75 : p < n3 ? n * (p -= 2.25 / c) * p + .9375 : n * Math.pow(p - 2.625 / c, 2) + .984375; }; _insertEase("Bounce", function (p) { return 1 - easeOut(1 - p); }, easeOut); })(7.5625, 2.75); _insertEase("Expo", function (p) { return p ? Math.pow(2, 10 * (p - 1)) : 0; }); _insertEase("Circ", function (p) { return -(_sqrt(1 - p * p) - 1); }); _insertEase("Sine", function (p) { return -_cos(p * _HALF_PI) + 1; }); _insertEase("Back", _configBack("in"), _configBack("out"), _configBack()); _easeMap.SteppedEase = _easeMap.steps = _globals.SteppedEase = { config: function config(steps, immediateStart) { if (steps === void 0) { steps = 1; } var p1 = 1 / steps, p2 = steps + (immediateStart ? 0 : 1), p3 = immediateStart ? 1 : 0, max = 1 - _tinyNum; return function (p) { return ((p2 * _clamp(0, max, p) | 0) + p3) * p1; }; } }; _defaults.ease = _easeMap["quad.out"]; var GSCache = function GSCache(target, harness) { this.id = _gsID++; target._gsap = this; this.target = target; this.harness = harness; this.get = harness ? harness.get : _getProperty; this.set = harness ? harness.getSetter : _getSetter; }; var Animation = function () { function Animation(vars, time) { var parent = vars.parent || _globalTimeline; this.vars = vars; this._dur = this._tDur = +vars.duration || 0; this._delay = +vars.delay || 0; if (this._repeat = vars.repeat || 0) { this._rDelay = vars.repeatDelay || 0; this._yoyo = !!vars.yoyo || !!vars.yoyoEase; _onUpdateTotalDuration(this); } this._ts = 1; this.data = vars.data; if (!_tickerActive) { _ticker.wake(); } if (parent) { _addToTimeline(parent, this, time || time === 0 ? time : parent._time); } if (vars.reversed) { this.reversed(true); } if (vars.paused) { this.paused(true); } } var _proto = Animation.prototype; _proto.delay = function delay(value) { if (value || value === 0) { this._delay = value; return this; } return this._delay; }; _proto.duration = function duration(value) { var isSetter = arguments.length, repeat = this._repeat, repeatCycles = repeat > 0 ? repeat * ((isSetter ? value : this._dur) + this._rDelay) : 0; return isSetter ? this.totalDuration(repeat < 0 ? value : value + repeatCycles) : this.totalDuration() && this._dur; }; _proto.totalDuration = function totalDuration(value) { if (!arguments.length) { return this._tDur; } var repeat = this._repeat, isInfinite = (value || this._rDelay) && repeat < 0; this._tDur = isInfinite ? 1e20 : value; this._dur = isInfinite ? value : (value - repeat * this._rDelay) / (repeat + 1); this._dirty = 0; _uncache(this.parent); return this; }; _proto.totalTime = function totalTime(_totalTime, suppressEvents) { _wake(); if (!arguments.length) { return this._tTime; } var parent = this.parent || this._dp, start; if (parent && parent.smoothChildTiming && this._ts) { start = this._start; this._start = parent._time - (this._ts > 0 ? _totalTime / this._ts : ((this._dirty ? this.totalDuration() : this._tDur) - _totalTime) / -this._ts); this._end += this._start - start; if (!parent._dirty) { _uncache(parent); } while (parent.parent) { if (parent.parent._time !== parent._start + (parent._ts > 0 ? parent._tTime / parent._ts : (parent.totalDuration() - parent._tTime) / -parent._ts)) { parent.totalTime(parent._tTime, true); } parent = parent.parent; } if (!this.parent) { _addToTimeline(this._dp, this, this._start - this._delay); } } if (this._tTime !== _totalTime || !this._dur) { this._ts || (this._pTime = _totalTime); _lazySafeRender(this, _totalTime, suppressEvents); } return this; }; _proto.time = function time(value, suppressEvents) { return arguments.length ? this.totalTime((value + _elapsedCycleDuration(this)) % this.duration() || (value ? this._dur : 0), suppressEvents) : this._time; }; _proto.totalProgress = function totalProgress(value, suppressEvents) { return arguments.length ? this.totalTime(this.totalDuration() * value, suppressEvents) : this._tTime / this.totalDuration(); }; _proto.progress = function progress(value, suppressEvents) { return arguments.length ? this.totalTime(this.duration() * (this._yoyo && !(this.iteration() & 1) ? 1 - value : value) + _elapsedCycleDuration(this), suppressEvents) : this.duration() ? this._time / this._dur : this.ratio; }; _proto.iteration = function iteration(value, suppressEvents) { var cycleDuration = this.duration() + this._rDelay; return arguments.length ? this.totalTime(this._time + (value - 1) * cycleDuration, suppressEvents) : this._repeat ? _animationCycle(this._tTime, cycleDuration) + 1 : 1; }; _proto.timeScale = function timeScale(value) { if (!arguments.length) { return this._ts || this._pauseTS || 0; } if (this._pauseTS !== null) { this._pauseTS = value; return this; } this._ts = value; return _recacheAncestors(this).totalTime(this._tTime, true); }; _proto.paused = function paused(value) { var isPaused = !this._ts; if (!arguments.length) { return isPaused; } if (isPaused !== value) { if (value) { this._pauseTS = this._ts; this._pTime = this._tTime || Math.max(-this._delay, this.rawTime()); this._ts = this._act = 0; } else { this._ts = this._pauseTS || 1; this._pauseTS = null; value = this._tTime || this._pTime; if (this.progress() === 1) { this._tTime -= _tinyNum; } this.totalTime(value, true); } } return this; }; _proto.startTime = function startTime(value) { if (arguments.length) { if (this.parent && this.parent._sort) { _addToTimeline(this.parent, this, value - this._delay); } return this; } return this._start; }; _proto.endTime = function endTime(includeRepeats) { return this._start + (_isNotFalse(includeRepeats) ? this.totalDuration() : this.duration()) / Math.abs(this._ts); }; _proto.rawTime = function rawTime(wrapRepeats) { var parent = this.parent || this._dp; return !parent ? this._tTime : wrapRepeats && (!this._ts || this._repeat && this._time && this.totalProgress() < 1) ? this._tTime % (this._dur + this._rDelay) : !this._ts ? this._tTime : _parentToChildTotalTime(parent.rawTime(wrapRepeats), this); }; _proto.repeat = function repeat(value) { if (arguments.length) { this._repeat = value; return _onUpdateTotalDuration(this); } return this._repeat; }; _proto.repeatDelay = function repeatDelay(value) { if (arguments.length) { this._rDelay = value; return _onUpdateTotalDuration(this); } return this._rDelay; }; _proto.yoyo = function yoyo(value) { if (arguments.length) { this._yoyo = value; return this; } return this._yoyo; }; _proto.seek = function seek(position, suppressEvents) { return this.totalTime(_parsePosition(this, position), _isNotFalse(suppressEvents)); }; _proto.restart = function restart(includeDelay, suppressEvents) { return this.play().totalTime(includeDelay ? -this._delay : 0, _isNotFalse(suppressEvents)); }; _proto.play = function play(from, suppressEvents) { if (from != null) { this.seek(from, suppressEvents); } return this.reversed(false).paused(false); }; _proto.reverse = function reverse(from, suppressEvents) { if (from != null) { this.seek(from || this.totalDuration(), suppressEvents); } return this.reversed(true).paused(false); }; _proto.pause = function pause(atTime, suppressEvents) { if (atTime != null) { this.seek(atTime, suppressEvents); } return this.paused(true); }; _proto.resume = function resume() { return this.paused(false); }; _proto.reversed = function reversed(value) { var ts = this._ts || this._pauseTS || 0; if (arguments.length) { if (value !== this.reversed()) { this[this._pauseTS === null ? "_ts" : "_pauseTS"] = Math.abs(ts) * (value ? -1 : 1); this.totalTime(this._tTime, true); } return this; } return ts < 0; }; _proto.invalidate = function invalidate() { this._initted = 0; return this; }; _proto.isActive = function isActive(hasStarted) { var parent = this.parent || this._dp, start = this._start, rawTime; return !parent || this._ts && (this._initted || !hasStarted) && parent.isActive(hasStarted) && (rawTime = parent.rawTime(true)) >= start && rawTime < this.endTime(true) - _tinyNum; }; _proto.eventCallback = function eventCallback(type, callback, params) { var vars = this.vars; if (arguments.length > 1) { if (!callback) { delete vars[type]; } else { vars[type] = callback; if (params) { vars[type + "Params"] = params; } if (type === "onUpdate") { this._onUpdate = callback; } } return this; } return vars[type]; }; _proto.then = function then(onFulfilled) { var _this = this; return new Promise(function (resolve) { var f = onFulfilled || _passThrough, _resolve = function _resolve() { var _then = _this.then; _this.then = null; f = f(_this); if (f && (f.then || f === _this)) { _this._prom = f; _this.then = _then; } resolve(f); _this.then = _then; }; if (_this._initted && _this.totalProgress() === 1 && _this._ts >= 0 || !_this._tTime && _this._ts < 0) { _resolve(); } else { _this._prom = _resolve; } }); }; _proto.kill = function kill() { _interrupt(this); }; return Animation; }(); _setDefaults(Animation.prototype, { _time: 0, _start: 0, _end: 0, _tTime: 0, _tDur: 0, _dirty: 0, _repeat: 0, _yoyo: false, parent: 0, _initted: false, _rDelay: 0, _ts: 1, _dp: 0, ratio: 0, _zTime: -_tinyNum, _prom: 0, _pauseTS: null }); var Timeline = function (_Animation) { _inheritsLoose(Timeline, _Animation); function Timeline(vars, time) { var _this2; if (vars === void 0) { vars = {}; }