1 | (function (global, factory) {
|
2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
3 | typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
4 | (global = global || self, factory(global.window = global.window || {}));
|
5 | }(this, (function (exports) { 'use strict';
|
6 |
|
7 | function _inheritsLoose(subClass, superClass) {
|
8 | subClass.prototype = Object.create(superClass.prototype);
|
9 | subClass.prototype.constructor = subClass;
|
10 | subClass.__proto__ = superClass;
|
11 | }
|
12 |
|
13 | function _assertThisInitialized(self) {
|
14 | if (self === void 0) {
|
15 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
16 | }
|
17 |
|
18 | return self;
|
19 | }
|
20 |
|
21 | |
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 | var _config = {
|
31 | autoSleep: 120,
|
32 | force3D: "auto",
|
33 | nullTargetWarn: 1,
|
34 | units: {
|
35 | lineHeight: ""
|
36 | }
|
37 | },
|
38 | _defaults = {
|
39 | duration: .5,
|
40 | overwrite: false,
|
41 | delay: 0
|
42 | },
|
43 | _bigNum = 1e8,
|
44 | _tinyNum = 1 / _bigNum,
|
45 | _2PI = Math.PI * 2,
|
46 | _HALF_PI = _2PI / 4,
|
47 | _gsID = 0,
|
48 | _sqrt = Math.sqrt,
|
49 | _cos = Math.cos,
|
50 | _sin = Math.sin,
|
51 | _isString = function _isString(value) {
|
52 | return typeof value === "string";
|
53 | },
|
54 | _isFunction = function _isFunction(value) {
|
55 | return typeof value === "function";
|
56 | },
|
57 | _isNumber = function _isNumber(value) {
|
58 | return typeof value === "number";
|
59 | },
|
60 | _isUndefined = function _isUndefined(value) {
|
61 | return typeof value === "undefined";
|
62 | },
|
63 | _isObject = function _isObject(value) {
|
64 | return typeof value === "object";
|
65 | },
|
66 | _isNotFalse = function _isNotFalse(value) {
|
67 | return value !== false;
|
68 | },
|
69 | _windowExists = function _windowExists() {
|
70 | return typeof window !== "undefined";
|
71 | },
|
72 | _isFuncOrString = function _isFuncOrString(value) {
|
73 | return _isFunction(value) || _isString(value);
|
74 | },
|
75 | _isTypedArray = typeof ArrayBuffer === "function" && ArrayBuffer.isView || function () {},
|
76 | _isArray = Array.isArray,
|
77 | _strictNumExp = /(?:-?\.?\d|\.)+/gi,
|
78 | _numExp = /[-+=.]*\d+[.e\-+]*\d*[e\-\+]*\d*/g,
|
79 | _numWithUnitExp = /[-+=.]*\d+[.e-]*\d*[a-z%]*/g,
|
80 | _complexStringNumExp = /[-+=.]*\d+(?:\.|e-|e)*\d*/gi,
|
81 | _relExp = /[+-]=-?[\.\d]+/,
|
82 | _delimitedValueExp = /[#\-+.]*\b[a-z\d-=+%.]+/gi,
|
83 | _globalTimeline,
|
84 | _win,
|
85 | _coreInitted,
|
86 | _doc,
|
87 | _globals = {},
|
88 | _installScope = {},
|
89 | _coreReady,
|
90 | _install = function _install(scope) {
|
91 | return (_installScope = _merge(scope, _globals)) && gsap;
|
92 | },
|
93 | _missingPlugin = function _missingPlugin(property, value) {
|
94 | return console.warn("Invalid property", property, "set to", value, "Missing plugin? gsap.registerPlugin()");
|
95 | },
|
96 | _warn = function _warn(message, suppress) {
|
97 | return !suppress && console.warn(message);
|
98 | },
|
99 | _addGlobal = function _addGlobal(name, obj) {
|
100 | return name && (_globals[name] = obj) && _installScope && (_installScope[name] = obj) || _globals;
|
101 | },
|
102 | _emptyFunc = function _emptyFunc() {
|
103 | return 0;
|
104 | },
|
105 | _reservedProps = {},
|
106 | _lazyTweens = [],
|
107 | _lazyLookup = {},
|
108 | _lastRenderedFrame,
|
109 | _plugins = {},
|
110 | _effects = {},
|
111 | _nextGCFrame = 30,
|
112 | _harnessPlugins = [],
|
113 | _callbackNames = "",
|
114 | _harness = function _harness(targets) {
|
115 | var target = targets[0],
|
116 | harnessPlugin,
|
117 | i;
|
118 | _isObject(target) || _isFunction(target) || (targets = [targets]);
|
119 |
|
120 | if (!(harnessPlugin = (target._gsap || {}).harness)) {
|
121 | i = _harnessPlugins.length;
|
122 |
|
123 | while (i-- && !_harnessPlugins[i].targetTest(target)) {}
|
124 |
|
125 | harnessPlugin = _harnessPlugins[i];
|
126 | }
|
127 |
|
128 | i = targets.length;
|
129 |
|
130 | while (i--) {
|
131 | targets[i] && (targets[i]._gsap || (targets[i]._gsap = new GSCache(targets[i], harnessPlugin))) || targets.splice(i, 1);
|
132 | }
|
133 |
|
134 | return targets;
|
135 | },
|
136 | _getCache = function _getCache(target) {
|
137 | return target._gsap || _harness(toArray(target))[0]._gsap;
|
138 | },
|
139 | _getProperty = function _getProperty(target, property, v) {
|
140 | return (v = target[property]) && _isFunction(v) ? target[property]() : _isUndefined(v) && target.getAttribute && target.getAttribute(property) || v;
|
141 | },
|
142 | _forEachName = function _forEachName(names, func) {
|
143 | return (names = names.split(",")).forEach(func) || names;
|
144 | },
|
145 | _round = function _round(value) {
|
146 | return Math.round(value * 100000) / 100000 || 0;
|
147 | },
|
148 | _arrayContainsAny = function _arrayContainsAny(toSearch, toFind) {
|
149 | var l = toFind.length,
|
150 | i = 0;
|
151 |
|
152 | for (; toSearch.indexOf(toFind[i]) < 0 && ++i < l;) {}
|
153 |
|
154 | return i < l;
|
155 | },
|
156 | _parseVars = function _parseVars(params, type, parent) {
|
157 | var isLegacy = _isNumber(params[1]),
|
158 | varsIndex = (isLegacy ? 2 : 1) + (type < 2 ? 0 : 1),
|
159 | vars = params[varsIndex],
|
160 | irVars;
|
161 |
|
162 | isLegacy && (vars.duration = params[1]);
|
163 | vars.parent = parent;
|
164 |
|
165 | if (type) {
|
166 | irVars = vars;
|
167 |
|
168 | while (parent && !("immediateRender" in irVars)) {
|
169 | irVars = parent.vars.defaults || {};
|
170 | parent = _isNotFalse(parent.vars.inherit) && parent.parent;
|
171 | }
|
172 |
|
173 | vars.immediateRender = _isNotFalse(irVars.immediateRender);
|
174 | type < 2 ? vars.runBackwards = 1 : vars.startAt = params[varsIndex - 1];
|
175 | }
|
176 |
|
177 | return vars;
|
178 | },
|
179 | _lazyRender = function _lazyRender() {
|
180 | var l = _lazyTweens.length,
|
181 | a = _lazyTweens.slice(0),
|
182 | i,
|
183 | tween;
|
184 |
|
185 | _lazyLookup = {};
|
186 | _lazyTweens.length = 0;
|
187 |
|
188 | for (i = 0; i < l; i++) {
|
189 | tween = a[i];
|
190 | tween && tween._lazy && (tween.render(tween._lazy[0], tween._lazy[1], true)._lazy = 0);
|
191 | }
|
192 | },
|
193 | _lazySafeRender = function _lazySafeRender(animation, time, suppressEvents, force) {
|
194 | _lazyTweens.length && _lazyRender();
|
195 | animation.render(time, suppressEvents, force);
|
196 | _lazyTweens.length && _lazyRender();
|
197 | },
|
198 | _numericIfPossible = function _numericIfPossible(value) {
|
199 | var n = parseFloat(value);
|
200 | return (n || n === 0) && (value + "").match(_delimitedValueExp).length < 2 ? n : _isString(value) ? value.trim() : value;
|
201 | },
|
202 | _passThrough = function _passThrough(p) {
|
203 | return p;
|
204 | },
|
205 | _setDefaults = function _setDefaults(obj, defaults) {
|
206 | for (var p in defaults) {
|
207 | p in obj || (obj[p] = defaults[p]);
|
208 | }
|
209 |
|
210 | return obj;
|
211 | },
|
212 | _setKeyframeDefaults = function _setKeyframeDefaults(obj, defaults) {
|
213 | for (var p in defaults) {
|
214 | p in obj || p === "duration" || p === "ease" || (obj[p] = defaults[p]);
|
215 | }
|
216 | },
|
217 | _merge = function _merge(base, toMerge) {
|
218 | for (var p in toMerge) {
|
219 | base[p] = toMerge[p];
|
220 | }
|
221 |
|
222 | return base;
|
223 | },
|
224 | _mergeDeep = function _mergeDeep(base, toMerge) {
|
225 | for (var p in toMerge) {
|
226 | base[p] = _isObject(toMerge[p]) ? _mergeDeep(base[p] || (base[p] = {}), toMerge[p]) : toMerge[p];
|
227 | }
|
228 |
|
229 | return base;
|
230 | },
|
231 | _copyExcluding = function _copyExcluding(obj, excluding) {
|
232 | var copy = {},
|
233 | p;
|
234 |
|
235 | for (p in obj) {
|
236 | p in excluding || (copy[p] = obj[p]);
|
237 | }
|
238 |
|
239 | return copy;
|
240 | },
|
241 | _inheritDefaults = function _inheritDefaults(vars) {
|
242 | var parent = vars.parent || _globalTimeline,
|
243 | func = vars.keyframes ? _setKeyframeDefaults : _setDefaults;
|
244 |
|
245 | if (_isNotFalse(vars.inherit)) {
|
246 | while (parent) {
|
247 | func(vars, parent.vars.defaults);
|
248 | parent = parent.parent || parent._dp;
|
249 | }
|
250 | }
|
251 |
|
252 | return vars;
|
253 | },
|
254 | _arraysMatch = function _arraysMatch(a1, a2) {
|
255 | var i = a1.length,
|
256 | match = i === a2.length;
|
257 |
|
258 | while (match && i-- && a1[i] === a2[i]) {}
|
259 |
|
260 | return i < 0;
|
261 | },
|
262 | _addLinkedListItem = function _addLinkedListItem(parent, child, firstProp, lastProp, sortBy) {
|
263 | if (firstProp === void 0) {
|
264 | firstProp = "_first";
|
265 | }
|
266 |
|
267 | if (lastProp === void 0) {
|
268 | lastProp = "_last";
|
269 | }
|
270 |
|
271 | var prev = parent[lastProp],
|
272 | t;
|
273 |
|
274 | if (sortBy) {
|
275 | t = child[sortBy];
|
276 |
|
277 | while (prev && prev[sortBy] > t) {
|
278 | prev = prev._prev;
|
279 | }
|
280 | }
|
281 |
|
282 | if (prev) {
|
283 | child._next = prev._next;
|
284 | prev._next = child;
|
285 | } else {
|
286 | child._next = parent[firstProp];
|
287 | parent[firstProp] = child;
|
288 | }
|
289 |
|
290 | if (child._next) {
|
291 | child._next._prev = child;
|
292 | } else {
|
293 | parent[lastProp] = child;
|
294 | }
|
295 |
|
296 | child._prev = prev;
|
297 | child.parent = child._dp = parent;
|
298 | return child;
|
299 | },
|
300 | _removeLinkedListItem = function _removeLinkedListItem(parent, child, firstProp, lastProp) {
|
301 | if (firstProp === void 0) {
|
302 | firstProp = "_first";
|
303 | }
|
304 |
|
305 | if (lastProp === void 0) {
|
306 | lastProp = "_last";
|
307 | }
|
308 |
|
309 | var prev = child._prev,
|
310 | next = child._next;
|
311 |
|
312 | if (prev) {
|
313 | prev._next = next;
|
314 | } else if (parent[firstProp] === child) {
|
315 | parent[firstProp] = next;
|
316 | }
|
317 |
|
318 | if (next) {
|
319 | next._prev = prev;
|
320 | } else if (parent[lastProp] === child) {
|
321 | parent[lastProp] = prev;
|
322 | }
|
323 |
|
324 | child._next = child._prev = child.parent = null;
|
325 | },
|
326 | _removeFromParent = function _removeFromParent(child, onlyIfParentHasAutoRemove) {
|
327 | child.parent && (!onlyIfParentHasAutoRemove || child.parent.autoRemoveChildren) && child.parent.remove(child);
|
328 | child._act = 0;
|
329 | },
|
330 | _uncache = function _uncache(animation, child) {
|
331 | if (animation && (!child || child._end > animation._dur || child._start < 0)) {
|
332 | var a = animation;
|
333 |
|
334 | while (a) {
|
335 | a._dirty = 1;
|
336 | a = a.parent;
|
337 | }
|
338 | }
|
339 |
|
340 | return animation;
|
341 | },
|
342 | _recacheAncestors = function _recacheAncestors(animation) {
|
343 | var parent = animation.parent;
|
344 |
|
345 | while (parent && parent.parent) {
|
346 | parent._dirty = 1;
|
347 | parent.totalDuration();
|
348 | parent = parent.parent;
|
349 | }
|
350 |
|
351 | return animation;
|
352 | },
|
353 | _hasNoPausedAncestors = function _hasNoPausedAncestors(animation) {
|
354 | return !animation || animation._ts && _hasNoPausedAncestors(animation.parent);
|
355 | },
|
356 | _elapsedCycleDuration = function _elapsedCycleDuration(animation) {
|
357 | return animation._repeat ? _animationCycle(animation._tTime, animation = animation.duration() + animation._rDelay) * animation : 0;
|
358 | },
|
359 | _animationCycle = function _animationCycle(tTime, cycleDuration) {
|
360 | return (tTime /= cycleDuration) && ~~tTime === tTime ? ~~tTime - 1 : ~~tTime;
|
361 | },
|
362 | _parentToChildTotalTime = function _parentToChildTotalTime(parentTime, child) {
|
363 | return (parentTime - child._start) * child._ts + (child._ts >= 0 ? 0 : child._dirty ? child.totalDuration() : child._tDur);
|
364 | },
|
365 | _setEnd = function _setEnd(animation) {
|
366 | return animation._end = _round(animation._start + (animation._tDur / Math.abs(animation._ts || animation._rts || _tinyNum) || 0));
|
367 | },
|
368 | _alignPlayhead = function _alignPlayhead(animation, totalTime) {
|
369 | var parent = animation._dp;
|
370 |
|
371 | if (parent && parent.smoothChildTiming && animation._ts) {
|
372 | animation._start = _round(animation._dp._time - (animation._ts > 0 ? totalTime / animation._ts : ((animation._dirty ? animation.totalDuration() : animation._tDur) - totalTime) / -animation._ts));
|
373 |
|
374 | _setEnd(animation);
|
375 |
|
376 | parent._dirty || _uncache(parent, animation);
|
377 | }
|
378 |
|
379 | return animation;
|
380 | },
|
381 | _postAddChecks = function _postAddChecks(timeline, child) {
|
382 | var t;
|
383 |
|
384 | if (child._time || child._initted && !child._dur) {
|
385 | t = _parentToChildTotalTime(timeline.rawTime(), child);
|
386 |
|
387 | if (!child._dur || _clamp(0, child.totalDuration(), t) - child._tTime > _tinyNum) {
|
388 | child.render(t, true);
|
389 | }
|
390 | }
|
391 |
|
392 | if (_uncache(timeline, child)._dp && timeline._initted && timeline._time >= timeline._dur && timeline._ts) {
|
393 | if (timeline._dur < timeline.duration()) {
|
394 | t = timeline;
|
395 |
|
396 | while (t._dp) {
|
397 | t.rawTime() >= 0 && t.totalTime(t._tTime);
|
398 | t = t._dp;
|
399 | }
|
400 | }
|
401 |
|
402 | timeline._zTime = -_tinyNum;
|
403 | }
|
404 | },
|
405 | _addToTimeline = function _addToTimeline(timeline, child, position, skipChecks) {
|
406 | child.parent && _removeFromParent(child);
|
407 | child._start = _round(position + child._delay);
|
408 | child._end = _round(child._start + (child.totalDuration() / Math.abs(child.timeScale()) || 0));
|
409 |
|
410 | _addLinkedListItem(timeline, child, "_first", "_last", timeline._sort ? "_start" : 0);
|
411 |
|
412 | timeline._recent = child;
|
413 | skipChecks || _postAddChecks(timeline, child);
|
414 | return timeline;
|
415 | },
|
416 | _scrollTrigger = function _scrollTrigger(animation, trigger) {
|
417 | return (_globals.ScrollTrigger || _missingPlugin("scrollTrigger", trigger)) && _globals.ScrollTrigger.create(trigger, animation);
|
418 | },
|
419 | _attemptInitTween = function _attemptInitTween(tween, totalTime, force, suppressEvents) {
|
420 | _initTween(tween, totalTime);
|
421 |
|
422 | if (!tween._initted) {
|
423 | return 1;
|
424 | }
|
425 |
|
426 | if (!force && tween._pt && (tween._dur && tween.vars.lazy !== false || !tween._dur && tween.vars.lazy) && _lastRenderedFrame !== _ticker.frame) {
|
427 | _lazyTweens.push(tween);
|
428 |
|
429 | tween._lazy = [totalTime, suppressEvents];
|
430 | return 1;
|
431 | }
|
432 | },
|
433 | _renderZeroDurationTween = function _renderZeroDurationTween(tween, totalTime, suppressEvents, force) {
|
434 | var prevRatio = tween.ratio,
|
435 | ratio = totalTime < 0 || !totalTime && prevRatio && !tween._start && tween._zTime > _tinyNum && !tween._dp._lock || (tween._ts < 0 || tween._dp._ts < 0) && tween.data !== "isFromStart" && tween.data !== "isStart" ? 0 : 1,
|
436 | repeatDelay = tween._rDelay,
|
437 | tTime = 0,
|
438 | pt,
|
439 | iteration,
|
440 | prevIteration;
|
441 |
|
442 | if (repeatDelay && tween._repeat) {
|
443 | tTime = _clamp(0, tween._tDur, totalTime);
|
444 | iteration = _animationCycle(tTime, repeatDelay);
|
445 | prevIteration = _animationCycle(tween._tTime, repeatDelay);
|
446 |
|
447 | if (iteration !== prevIteration) {
|
448 | prevRatio = 1 - ratio;
|
449 | tween.vars.repeatRefresh && tween._initted && tween.invalidate();
|
450 | }
|
451 | }
|
452 |
|
453 | if (ratio !== prevRatio || force || tween._zTime === _tinyNum || !totalTime && tween._zTime) {
|
454 | if (!tween._initted && _attemptInitTween(tween, totalTime, force, suppressEvents)) {
|
455 | return;
|
456 | }
|
457 |
|
458 | prevIteration = tween._zTime;
|
459 | tween._zTime = totalTime || (suppressEvents ? _tinyNum : 0);
|
460 | suppressEvents || (suppressEvents = totalTime && !prevIteration);
|
461 | tween.ratio = ratio;
|
462 | tween._from && (ratio = 1 - ratio);
|
463 | tween._time = 0;
|
464 | tween._tTime = tTime;
|
465 | suppressEvents || _callback(tween, "onStart");
|
466 | pt = tween._pt;
|
467 |
|
468 | while (pt) {
|
469 | pt.r(ratio, pt.d);
|
470 | pt = pt._next;
|
471 | }
|
472 |
|
473 | tween._startAt && totalTime < 0 && tween._startAt.render(totalTime, true, true);
|
474 | tween._onUpdate && !suppressEvents && _callback(tween, "onUpdate");
|
475 | tTime && tween._repeat && !suppressEvents && tween.parent && _callback(tween, "onRepeat");
|
476 |
|
477 | if ((totalTime >= tween._tDur || totalTime < 0) && tween.ratio === ratio) {
|
478 | ratio && _removeFromParent(tween, 1);
|
479 |
|
480 | if (!suppressEvents) {
|
481 | _callback(tween, ratio ? "onComplete" : "onReverseComplete", true);
|
482 |
|
483 | tween._prom && tween._prom();
|
484 | }
|
485 | }
|
486 | } else if (!tween._zTime) {
|
487 | tween._zTime = totalTime;
|
488 | }
|
489 | },
|
490 | _findNextPauseTween = function _findNextPauseTween(animation, prevTime, time) {
|
491 | var child;
|
492 |
|
493 | if (time > prevTime) {
|
494 | child = animation._first;
|
495 |
|
496 | while (child && child._start <= time) {
|
497 | if (!child._dur && child.data === "isPause" && child._start > prevTime) {
|
498 | return child;
|
499 | }
|
500 |
|
501 | child = child._next;
|
502 | }
|
503 | } else {
|
504 | child = animation._last;
|
505 |
|
506 | while (child && child._start >= time) {
|
507 | if (!child._dur && child.data === "isPause" && child._start < prevTime) {
|
508 | return child;
|
509 | }
|
510 |
|
511 | child = child._prev;
|
512 | }
|
513 | }
|
514 | },
|
515 | _setDuration = function _setDuration(animation, duration, skipUncache, leavePlayhead) {
|
516 | var repeat = animation._repeat,
|
517 | dur = _round(duration) || 0,
|
518 | totalProgress = animation._tTime / animation._tDur;
|
519 | totalProgress && !leavePlayhead && (animation._time *= dur / animation._dur);
|
520 | animation._dur = dur;
|
521 | animation._tDur = !repeat ? dur : repeat < 0 ? 1e10 : _round(dur * (repeat + 1) + animation._rDelay * repeat);
|
522 | totalProgress && !leavePlayhead ? _alignPlayhead(animation, animation._tTime = animation._tDur * totalProgress) : animation.parent && _setEnd(animation);
|
523 | skipUncache || _uncache(animation.parent, animation);
|
524 | return animation;
|
525 | },
|
526 | _onUpdateTotalDuration = function _onUpdateTotalDuration(animation) {
|
527 | return animation instanceof Timeline ? _uncache(animation) : _setDuration(animation, animation._dur);
|
528 | },
|
529 | _zeroPosition = {
|
530 | _start: 0,
|
531 | endTime: _emptyFunc
|
532 | },
|
533 | _parsePosition = function _parsePosition(animation, position) {
|
534 | var labels = animation.labels,
|
535 | recent = animation._recent || _zeroPosition,
|
536 | clippedDuration = animation.duration() >= _bigNum ? recent.endTime(false) : animation._dur,
|
537 | i,
|
538 | offset;
|
539 |
|
540 | if (_isString(position) && (isNaN(position) || position in labels)) {
|
541 | i = position.charAt(0);
|
542 |
|
543 | if (i === "<" || i === ">") {
|
544 | return (i === "<" ? recent._start : recent.endTime(recent._repeat >= 0)) + (parseFloat(position.substr(1)) || 0);
|
545 | }
|
546 |
|
547 | i = position.indexOf("=");
|
548 |
|
549 | if (i < 0) {
|
550 | position in labels || (labels[position] = clippedDuration);
|
551 | return labels[position];
|
552 | }
|
553 |
|
554 | offset = +(position.charAt(i - 1) + position.substr(i + 1));
|
555 | return i > 1 ? _parsePosition(animation, position.substr(0, i - 1)) + offset : clippedDuration + offset;
|
556 | }
|
557 |
|
558 | return position == null ? clippedDuration : +position;
|
559 | },
|
560 | _conditionalReturn = function _conditionalReturn(value, func) {
|
561 | return value || value === 0 ? func(value) : func;
|
562 | },
|
563 | _clamp = function _clamp(min, max, value) {
|
564 | return value < min ? min : value > max ? max : value;
|
565 | },
|
566 | getUnit = function getUnit(value) {
|
567 | return (value = (value + "").substr((parseFloat(value) + "").length)) && isNaN(value) ? value : "";
|
568 | },
|
569 | clamp = function clamp(min, max, value) {
|
570 | return _conditionalReturn(value, function (v) {
|
571 | return _clamp(min, max, v);
|
572 | });
|
573 | },
|
574 | _slice = [].slice,
|
575 | _isArrayLike = function _isArrayLike(value, nonEmpty) {
|
576 | return value && _isObject(value) && "length" in value && (!nonEmpty && !value.length || value.length - 1 in value && _isObject(value[0])) && !value.nodeType && value !== _win;
|
577 | },
|
578 | _flatten = function _flatten(ar, leaveStrings, accumulator) {
|
579 | if (accumulator === void 0) {
|
580 | accumulator = [];
|
581 | }
|
582 |
|
583 | return ar.forEach(function (value) {
|
584 | var _accumulator;
|
585 |
|
586 | return _isString(value) && !leaveStrings || _isArrayLike(value, 1) ? (_accumulator = accumulator).push.apply(_accumulator, toArray(value)) : accumulator.push(value);
|
587 | }) || accumulator;
|
588 | },
|
589 | toArray = function toArray(value, leaveStrings) {
|
590 | 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] : [];
|
591 | },
|
592 | shuffle = function shuffle(a) {
|
593 | return a.sort(function () {
|
594 | return .5 - Math.random();
|
595 | });
|
596 | },
|
597 | distribute = function distribute(v) {
|
598 | if (_isFunction(v)) {
|
599 | return v;
|
600 | }
|
601 |
|
602 | var vars = _isObject(v) ? v : {
|
603 | each: v
|
604 | },
|
605 | ease = _parseEase(vars.ease),
|
606 | from = vars.from || 0,
|
607 | base = parseFloat(vars.base) || 0,
|
608 | cache = {},
|
609 | isDecimal = from > 0 && from < 1,
|
610 | ratios = isNaN(from) || isDecimal,
|
611 | axis = vars.axis,
|
612 | ratioX = from,
|
613 | ratioY = from;
|
614 |
|
615 | if (_isString(from)) {
|
616 | ratioX = ratioY = {
|
617 | center: .5,
|
618 | edges: .5,
|
619 | end: 1
|
620 | }[from] || 0;
|
621 | } else if (!isDecimal && ratios) {
|
622 | ratioX = from[0];
|
623 | ratioY = from[1];
|
624 | }
|
625 |
|
626 | return function (i, target, a) {
|
627 | var l = (a || vars).length,
|
628 | distances = cache[l],
|
629 | originX,
|
630 | originY,
|
631 | x,
|
632 | y,
|
633 | d,
|
634 | j,
|
635 | max,
|
636 | min,
|
637 | wrapAt;
|
638 |
|
639 | if (!distances) {
|
640 | wrapAt = vars.grid === "auto" ? 0 : (vars.grid || [1, _bigNum])[1];
|
641 |
|
642 | if (!wrapAt) {
|
643 | max = -_bigNum;
|
644 |
|
645 | while (max < (max = a[wrapAt++].getBoundingClientRect().left) && wrapAt < l) {}
|
646 |
|
647 | wrapAt--;
|
648 | }
|
649 |
|
650 | distances = cache[l] = [];
|
651 | originX = ratios ? Math.min(wrapAt, l) * ratioX - .5 : from % wrapAt;
|
652 | originY = ratios ? l * ratioY / wrapAt - .5 : from / wrapAt | 0;
|
653 | max = 0;
|
654 | min = _bigNum;
|
655 |
|
656 | for (j = 0; j < l; j++) {
|
657 | x = j % wrapAt - originX;
|
658 | y = originY - (j / wrapAt | 0);
|
659 | distances[j] = d = !axis ? _sqrt(x * x + y * y) : Math.abs(axis === "y" ? y : x);
|
660 | d > max && (max = d);
|
661 | d < min && (min = d);
|
662 | }
|
663 |
|
664 | from === "random" && shuffle(distances);
|
665 | distances.max = max - min;
|
666 | distances.min = min;
|
667 | 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);
|
668 | distances.b = l < 0 ? base - l : base;
|
669 | distances.u = getUnit(vars.amount || vars.each) || 0;
|
670 | ease = ease && l < 0 ? _invertEase(ease) : ease;
|
671 | }
|
672 |
|
673 | l = (distances[i] - distances.min) / distances.max || 0;
|
674 | return _round(distances.b + (ease ? ease(l) : l) * distances.v) + distances.u;
|
675 | };
|
676 | },
|
677 | _roundModifier = function _roundModifier(v) {
|
678 | var p = v < 1 ? Math.pow(10, (v + "").length - 2) : 1;
|
679 | return function (raw) {
|
680 | return Math.floor(Math.round(parseFloat(raw) / v) * v * p) / p + (_isNumber(raw) ? 0 : getUnit(raw));
|
681 | };
|
682 | },
|
683 | snap = function snap(snapTo, value) {
|
684 | var isArray = _isArray(snapTo),
|
685 | radius,
|
686 | is2D;
|
687 |
|
688 | if (!isArray && _isObject(snapTo)) {
|
689 | radius = isArray = snapTo.radius || _bigNum;
|
690 |
|
691 | if (snapTo.values) {
|
692 | snapTo = toArray(snapTo.values);
|
693 |
|
694 | if (is2D = !_isNumber(snapTo[0])) {
|
695 | radius *= radius;
|
696 | }
|
697 | } else {
|
698 | snapTo = _roundModifier(snapTo.increment);
|
699 | }
|
700 | }
|
701 |
|
702 | return _conditionalReturn(value, !isArray ? _roundModifier(snapTo) : _isFunction(snapTo) ? function (raw) {
|
703 | is2D = snapTo(raw);
|
704 | return Math.abs(is2D - raw) <= radius ? is2D : raw;
|
705 | } : function (raw) {
|
706 | var x = parseFloat(is2D ? raw.x : raw),
|
707 | y = parseFloat(is2D ? raw.y : 0),
|
708 | min = _bigNum,
|
709 | closest = 0,
|
710 | i = snapTo.length,
|
711 | dx,
|
712 | dy;
|
713 |
|
714 | while (i--) {
|
715 | if (is2D) {
|
716 | dx = snapTo[i].x - x;
|
717 | dy = snapTo[i].y - y;
|
718 | dx = dx * dx + dy * dy;
|
719 | } else {
|
720 | dx = Math.abs(snapTo[i] - x);
|
721 | }
|
722 |
|
723 | if (dx < min) {
|
724 | min = dx;
|
725 | closest = i;
|
726 | }
|
727 | }
|
728 |
|
729 | closest = !radius || min <= radius ? snapTo[closest] : raw;
|
730 | return is2D || closest === raw || _isNumber(raw) ? closest : closest + getUnit(raw);
|
731 | });
|
732 | },
|
733 | random = function random(min, max, roundingIncrement, returnFunction) {
|
734 | return _conditionalReturn(_isArray(min) ? !max : roundingIncrement === true ? !!(roundingIncrement = 0) : !returnFunction, function () {
|
735 | return _isArray(min) ? min[~~(Math.random() * min.length)] : (roundingIncrement = roundingIncrement || 1e-5) && (returnFunction = roundingIncrement < 1 ? Math.pow(10, (roundingIncrement + "").length - 2) : 1) && Math.floor(Math.round((min + Math.random() * (max - min)) / roundingIncrement) * roundingIncrement * returnFunction) / returnFunction;
|
736 | });
|
737 | },
|
738 | pipe = function pipe() {
|
739 | for (var _len = arguments.length, functions = new Array(_len), _key = 0; _key < _len; _key++) {
|
740 | functions[_key] = arguments[_key];
|
741 | }
|
742 |
|
743 | return function (value) {
|
744 | return functions.reduce(function (v, f) {
|
745 | return f(v);
|
746 | }, value);
|
747 | };
|
748 | },
|
749 | unitize = function unitize(func, unit) {
|
750 | return function (value) {
|
751 | return func(parseFloat(value)) + (unit || getUnit(value));
|
752 | };
|
753 | },
|
754 | normalize = function normalize(min, max, value) {
|
755 | return mapRange(min, max, 0, 1, value);
|
756 | },
|
757 | _wrapArray = function _wrapArray(a, wrapper, value) {
|
758 | return _conditionalReturn(value, function (index) {
|
759 | return a[~~wrapper(index)];
|
760 | });
|
761 | },
|
762 | wrap = function wrap(min, max, value) {
|
763 | var range = max - min;
|
764 | return _isArray(min) ? _wrapArray(min, wrap(0, min.length), max) : _conditionalReturn(value, function (value) {
|
765 | return (range + (value - min) % range) % range + min;
|
766 | });
|
767 | },
|
768 | wrapYoyo = function wrapYoyo(min, max, value) {
|
769 | var range = max - min,
|
770 | total = range * 2;
|
771 | return _isArray(min) ? _wrapArray(min, wrapYoyo(0, min.length - 1), max) : _conditionalReturn(value, function (value) {
|
772 | value = (total + (value - min) % total) % total || 0;
|
773 | return min + (value > range ? total - value : value);
|
774 | });
|
775 | },
|
776 | _replaceRandom = function _replaceRandom(value) {
|
777 | var prev = 0,
|
778 | s = "",
|
779 | i,
|
780 | nums,
|
781 | end,
|
782 | isArray;
|
783 |
|
784 | while (~(i = value.indexOf("random(", prev))) {
|
785 | end = value.indexOf(")", i);
|
786 | isArray = value.charAt(i + 7) === "[";
|
787 | nums = value.substr(i + 7, end - i - 7).match(isArray ? _delimitedValueExp : _strictNumExp);
|
788 | s += value.substr(prev, i - prev) + random(isArray ? nums : +nums[0], isArray ? 0 : +nums[1], +nums[2] || 1e-5);
|
789 | prev = end + 1;
|
790 | }
|
791 |
|
792 | return s + value.substr(prev, value.length - prev);
|
793 | },
|
794 | mapRange = function mapRange(inMin, inMax, outMin, outMax, value) {
|
795 | var inRange = inMax - inMin,
|
796 | outRange = outMax - outMin;
|
797 | return _conditionalReturn(value, function (value) {
|
798 | return outMin + ((value - inMin) / inRange * outRange || 0);
|
799 | });
|
800 | },
|
801 | interpolate = function interpolate(start, end, progress, mutate) {
|
802 | var func = isNaN(start + end) ? 0 : function (p) {
|
803 | return (1 - p) * start + p * end;
|
804 | };
|
805 |
|
806 | if (!func) {
|
807 | var isString = _isString(start),
|
808 | master = {},
|
809 | p,
|
810 | i,
|
811 | interpolators,
|
812 | l,
|
813 | il;
|
814 |
|
815 | progress === true && (mutate = 1) && (progress = null);
|
816 |
|
817 | if (isString) {
|
818 | start = {
|
819 | p: start
|
820 | };
|
821 | end = {
|
822 | p: end
|
823 | };
|
824 | } else if (_isArray(start) && !_isArray(end)) {
|
825 | interpolators = [];
|
826 | l = start.length;
|
827 | il = l - 2;
|
828 |
|
829 | for (i = 1; i < l; i++) {
|
830 | interpolators.push(interpolate(start[i - 1], start[i]));
|
831 | }
|
832 |
|
833 | l--;
|
834 |
|
835 | func = function func(p) {
|
836 | p *= l;
|
837 | var i = Math.min(il, ~~p);
|
838 | return interpolators[i](p - i);
|
839 | };
|
840 |
|
841 | progress = end;
|
842 | } else if (!mutate) {
|
843 | start = _merge(_isArray(start) ? [] : {}, start);
|
844 | }
|
845 |
|
846 | if (!interpolators) {
|
847 | for (p in end) {
|
848 | _addPropTween.call(master, start, p, "get", end[p]);
|
849 | }
|
850 |
|
851 | func = function func(p) {
|
852 | return _renderPropTweens(p, master) || (isString ? start.p : start);
|
853 | };
|
854 | }
|
855 | }
|
856 |
|
857 | return _conditionalReturn(progress, func);
|
858 | },
|
859 | _getLabelInDirection = function _getLabelInDirection(timeline, fromTime, backward) {
|
860 | var labels = timeline.labels,
|
861 | min = _bigNum,
|
862 | p,
|
863 | distance,
|
864 | label;
|
865 |
|
866 | for (p in labels) {
|
867 | distance = labels[p] - fromTime;
|
868 |
|
869 | if (distance < 0 === !!backward && distance && min > (distance = Math.abs(distance))) {
|
870 | label = p;
|
871 | min = distance;
|
872 | }
|
873 | }
|
874 |
|
875 | return label;
|
876 | },
|
877 | _callback = function _callback(animation, type, executeLazyFirst) {
|
878 | var v = animation.vars,
|
879 | callback = v[type],
|
880 | params,
|
881 | scope;
|
882 |
|
883 | if (!callback) {
|
884 | return;
|
885 | }
|
886 |
|
887 | params = v[type + "Params"];
|
888 | scope = v.callbackScope || animation;
|
889 | executeLazyFirst && _lazyTweens.length && _lazyRender();
|
890 | return params ? callback.apply(scope, params) : callback.call(scope);
|
891 | },
|
892 | _interrupt = function _interrupt(animation) {
|
893 | _removeFromParent(animation);
|
894 |
|
895 | animation.progress() < 1 && _callback(animation, "onInterrupt");
|
896 | return animation;
|
897 | },
|
898 | _quickTween,
|
899 | _createPlugin = function _createPlugin(config) {
|
900 | config = !config.name && config["default"] || config;
|
901 |
|
902 | var name = config.name,
|
903 | isFunc = _isFunction(config),
|
904 | Plugin = name && !isFunc && config.init ? function () {
|
905 | this._props = [];
|
906 | } : config,
|
907 | instanceDefaults = {
|
908 | init: _emptyFunc,
|
909 | render: _renderPropTweens,
|
910 | add: _addPropTween,
|
911 | kill: _killPropTweensOf,
|
912 | modifier: _addPluginModifier,
|
913 | rawVars: 0
|
914 | },
|
915 | statics = {
|
916 | targetTest: 0,
|
917 | get: 0,
|
918 | getSetter: _getSetter,
|
919 | aliases: {},
|
920 | register: 0
|
921 | };
|
922 |
|
923 | _wake();
|
924 |
|
925 | if (config !== Plugin) {
|
926 | if (_plugins[name]) {
|
927 | return;
|
928 | }
|
929 |
|
930 | _setDefaults(Plugin, _setDefaults(_copyExcluding(config, instanceDefaults), statics));
|
931 |
|
932 | _merge(Plugin.prototype, _merge(instanceDefaults, _copyExcluding(config, statics)));
|
933 |
|
934 | _plugins[Plugin.prop = name] = Plugin;
|
935 |
|
936 | if (config.targetTest) {
|
937 | _harnessPlugins.push(Plugin);
|
938 |
|
939 | _reservedProps[name] = 1;
|
940 | }
|
941 |
|
942 | name = (name === "css" ? "CSS" : name.charAt(0).toUpperCase() + name.substr(1)) + "Plugin";
|
943 | }
|
944 |
|
945 | _addGlobal(name, Plugin);
|
946 |
|
947 | config.register && config.register(gsap, Plugin, PropTween);
|
948 | },
|
949 | _255 = 255,
|
950 | _colorLookup = {
|
951 | aqua: [0, _255, _255],
|
952 | lime: [0, _255, 0],
|
953 | silver: [192, 192, 192],
|
954 | black: [0, 0, 0],
|
955 | maroon: [128, 0, 0],
|
956 | teal: [0, 128, 128],
|
957 | blue: [0, 0, _255],
|
958 | navy: [0, 0, 128],
|
959 | white: [_255, _255, _255],
|
960 | olive: [128, 128, 0],
|
961 | yellow: [_255, _255, 0],
|
962 | orange: [_255, 165, 0],
|
963 | gray: [128, 128, 128],
|
964 | purple: [128, 0, 128],
|
965 | green: [0, 128, 0],
|
966 | red: [_255, 0, 0],
|
967 | pink: [_255, 192, 203],
|
968 | cyan: [0, _255, _255],
|
969 | transparent: [_255, _255, _255, 0]
|
970 | },
|
971 | _hue = function _hue(h, m1, m2) {
|
972 | h = h < 0 ? h + 1 : h > 1 ? h - 1 : h;
|
973 | 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;
|
974 | },
|
975 | splitColor = function splitColor(v, toHSL, forceAlpha) {
|
976 | var a = !v ? _colorLookup.black : _isNumber(v) ? [v >> 16, v >> 8 & _255, v & _255] : 0,
|
977 | r,
|
978 | g,
|
979 | b,
|
980 | h,
|
981 | s,
|
982 | l,
|
983 | max,
|
984 | min,
|
985 | d,
|
986 | wasHSL;
|
987 |
|
988 | if (!a) {
|
989 | if (v.substr(-1) === ",") {
|
990 | v = v.substr(0, v.length - 1);
|
991 | }
|
992 |
|
993 | if (_colorLookup[v]) {
|
994 | a = _colorLookup[v];
|
995 | } else if (v.charAt(0) === "#") {
|
996 | if (v.length === 4) {
|
997 | r = v.charAt(1);
|
998 | g = v.charAt(2);
|
999 | b = v.charAt(3);
|
1000 | v = "#" + r + r + g + g + b + b;
|
1001 | }
|
1002 |
|
1003 | v = parseInt(v.substr(1), 16);
|
1004 | a = [v >> 16, v >> 8 & _255, v & _255];
|
1005 | } else if (v.substr(0, 3) === "hsl") {
|
1006 | a = wasHSL = v.match(_strictNumExp);
|
1007 |
|
1008 | if (!toHSL) {
|
1009 | h = +a[0] % 360 / 360;
|
1010 | s = +a[1] / 100;
|
1011 | l = +a[2] / 100;
|
1012 | g = l <= .5 ? l * (s + 1) : l + s - l * s;
|
1013 | r = l * 2 - g;
|
1014 | a.length > 3 && (a[3] *= 1);
|
1015 | a[0] = _hue(h + 1 / 3, r, g);
|
1016 | a[1] = _hue(h, r, g);
|
1017 | a[2] = _hue(h - 1 / 3, r, g);
|
1018 | } else if (~v.indexOf("=")) {
|
1019 | a = v.match(_numExp);
|
1020 | forceAlpha && a.length < 4 && (a[3] = 1);
|
1021 | return a;
|
1022 | }
|
1023 | } else {
|
1024 | a = v.match(_strictNumExp) || _colorLookup.transparent;
|
1025 | }
|
1026 |
|
1027 | a = a.map(Number);
|
1028 | }
|
1029 |
|
1030 | if (toHSL && !wasHSL) {
|
1031 | r = a[0] / _255;
|
1032 | g = a[1] / _255;
|
1033 | b = a[2] / _255;
|
1034 | max = Math.max(r, g, b);
|
1035 | min = Math.min(r, g, b);
|
1036 | l = (max + min) / 2;
|
1037 |
|
1038 | if (max === min) {
|
1039 | h = s = 0;
|
1040 | } else {
|
1041 | d = max - min;
|
1042 | s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
1043 | h = max === r ? (g - b) / d + (g < b ? 6 : 0) : max === g ? (b - r) / d + 2 : (r - g) / d + 4;
|
1044 | h *= 60;
|
1045 | }
|
1046 |
|
1047 | a[0] = ~~(h + .5);
|
1048 | a[1] = ~~(s * 100 + .5);
|
1049 | a[2] = ~~(l * 100 + .5);
|
1050 | }
|
1051 |
|
1052 | forceAlpha && a.length < 4 && (a[3] = 1);
|
1053 | return a;
|
1054 | },
|
1055 | _colorOrderData = function _colorOrderData(v) {
|
1056 | var values = [],
|
1057 | c = [],
|
1058 | i = -1;
|
1059 | v.split(_colorExp).forEach(function (v) {
|
1060 | var a = v.match(_numWithUnitExp) || [];
|
1061 | values.push.apply(values, a);
|
1062 | c.push(i += a.length + 1);
|
1063 | });
|
1064 | values.c = c;
|
1065 | return values;
|
1066 | },
|
1067 | _formatColors = function _formatColors(s, toHSL, orderMatchData) {
|
1068 | var result = "",
|
1069 | colors = (s + result).match(_colorExp),
|
1070 | type = toHSL ? "hsla(" : "rgba(",
|
1071 | i = 0,
|
1072 | c,
|
1073 | shell,
|
1074 | d,
|
1075 | l;
|
1076 |
|
1077 | if (!colors) {
|
1078 | return s;
|
1079 | }
|
1080 |
|
1081 | colors = colors.map(function (color) {
|
1082 | return (color = splitColor(color, toHSL, 1)) && type + (toHSL ? color[0] + "," + color[1] + "%," + color[2] + "%," + color[3] : color.join(",")) + ")";
|
1083 | });
|
1084 |
|
1085 | if (orderMatchData) {
|
1086 | d = _colorOrderData(s);
|
1087 | c = orderMatchData.c;
|
1088 |
|
1089 | if (c.join(result) !== d.c.join(result)) {
|
1090 | shell = s.replace(_colorExp, "1").split(_numWithUnitExp);
|
1091 | l = shell.length - 1;
|
1092 |
|
1093 | for (; i < l; i++) {
|
1094 | result += shell[i] + (~c.indexOf(i) ? colors.shift() || type + "0,0,0,0)" : (d.length ? d : colors.length ? colors : orderMatchData).shift());
|
1095 | }
|
1096 | }
|
1097 | }
|
1098 |
|
1099 | if (!shell) {
|
1100 | shell = s.split(_colorExp);
|
1101 | l = shell.length - 1;
|
1102 |
|
1103 | for (; i < l; i++) {
|
1104 | result += shell[i] + colors[i];
|
1105 | }
|
1106 | }
|
1107 |
|
1108 | return result + shell[l];
|
1109 | },
|
1110 | _colorExp = function () {
|
1111 | var s = "(?:\\b(?:(?:rgb|rgba|hsl|hsla)\\(.+?\\))|\\B#(?:[0-9a-f]{3}){1,2}\\b",
|
1112 | p;
|
1113 |
|
1114 | for (p in _colorLookup) {
|
1115 | s += "|" + p + "\\b";
|
1116 | }
|
1117 |
|
1118 | return new RegExp(s + ")", "gi");
|
1119 | }(),
|
1120 | _hslExp = /hsl[a]?\(/,
|
1121 | _colorStringFilter = function _colorStringFilter(a) {
|
1122 | var combined = a.join(" "),
|
1123 | toHSL;
|
1124 | _colorExp.lastIndex = 0;
|
1125 |
|
1126 | if (_colorExp.test(combined)) {
|
1127 | toHSL = _hslExp.test(combined);
|
1128 | a[1] = _formatColors(a[1], toHSL);
|
1129 | a[0] = _formatColors(a[0], toHSL, _colorOrderData(a[1]));
|
1130 | return true;
|
1131 | }
|
1132 | },
|
1133 | _tickerActive,
|
1134 | _ticker = function () {
|
1135 | var _getTime = Date.now,
|
1136 | _lagThreshold = 500,
|
1137 | _adjustedLag = 33,
|
1138 | _startTime = _getTime(),
|
1139 | _lastUpdate = _startTime,
|
1140 | _gap = 1000 / 240,
|
1141 | _nextTime = _gap,
|
1142 | _listeners = [],
|
1143 | _id,
|
1144 | _req,
|
1145 | _raf,
|
1146 | _self,
|
1147 | _delta,
|
1148 | _i,
|
1149 | _tick = function _tick(v) {
|
1150 | var elapsed = _getTime() - _lastUpdate,
|
1151 | manual = v === true,
|
1152 | overlap,
|
1153 | dispatch,
|
1154 | time,
|
1155 | frame;
|
1156 |
|
1157 | elapsed > _lagThreshold && (_startTime += elapsed - _adjustedLag);
|
1158 | _lastUpdate += elapsed;
|
1159 | time = _lastUpdate - _startTime;
|
1160 | overlap = time - _nextTime;
|
1161 |
|
1162 | if (overlap > 0 || manual) {
|
1163 | frame = ++_self.frame;
|
1164 | _delta = time - _self.time * 1000;
|
1165 | _self.time = time = time / 1000;
|
1166 | _nextTime += overlap + (overlap >= _gap ? 4 : _gap - overlap);
|
1167 | dispatch = 1;
|
1168 | }
|
1169 |
|
1170 | manual || (_id = _req(_tick));
|
1171 |
|
1172 | if (dispatch) {
|
1173 | for (_i = 0; _i < _listeners.length; _i++) {
|
1174 | _listeners[_i](time, _delta, frame, v);
|
1175 | }
|
1176 | }
|
1177 | };
|
1178 |
|
1179 | _self = {
|
1180 | time: 0,
|
1181 | frame: 0,
|
1182 | tick: function tick() {
|
1183 | _tick(true);
|
1184 | },
|
1185 | deltaRatio: function deltaRatio(fps) {
|
1186 | return _delta / (1000 / (fps || 60));
|
1187 | },
|
1188 | wake: function wake() {
|
1189 | if (_coreReady) {
|
1190 | if (!_coreInitted && _windowExists()) {
|
1191 | _win = _coreInitted = window;
|
1192 | _doc = _win.document || {};
|
1193 | _globals.gsap = gsap;
|
1194 | (_win.gsapVersions || (_win.gsapVersions = [])).push(gsap.version);
|
1195 |
|
1196 | _install(_installScope || _win.GreenSockGlobals || !_win.gsap && _win || {});
|
1197 |
|
1198 | _raf = _win.requestAnimationFrame;
|
1199 | }
|
1200 |
|
1201 | _id && _self.sleep();
|
1202 |
|
1203 | _req = _raf || function (f) {
|
1204 | return setTimeout(f, _nextTime - _self.time * 1000 + 1 | 0);
|
1205 | };
|
1206 |
|
1207 | _tickerActive = 1;
|
1208 |
|
1209 | _tick(2);
|
1210 | }
|
1211 | },
|
1212 | sleep: function sleep() {
|
1213 | (_raf ? _win.cancelAnimationFrame : clearTimeout)(_id);
|
1214 | _tickerActive = 0;
|
1215 | _req = _emptyFunc;
|
1216 | },
|
1217 | lagSmoothing: function lagSmoothing(threshold, adjustedLag) {
|
1218 | _lagThreshold = threshold || 1 / _tinyNum;
|
1219 | _adjustedLag = Math.min(adjustedLag, _lagThreshold, 0);
|
1220 | },
|
1221 | fps: function fps(_fps) {
|
1222 | _gap = 1000 / (_fps || 240);
|
1223 | _nextTime = _self.time * 1000 + _gap;
|
1224 | },
|
1225 | add: function add(callback) {
|
1226 | _listeners.indexOf(callback) < 0 && _listeners.push(callback);
|
1227 |
|
1228 | _wake();
|
1229 | },
|
1230 | remove: function remove(callback) {
|
1231 | var i;
|
1232 | ~(i = _listeners.indexOf(callback)) && _listeners.splice(i, 1) && _i >= i && _i--;
|
1233 | },
|
1234 | _listeners: _listeners
|
1235 | };
|
1236 | return _self;
|
1237 | }(),
|
1238 | _wake = function _wake() {
|
1239 | return !_tickerActive && _ticker.wake();
|
1240 | },
|
1241 | _easeMap = {},
|
1242 | _customEaseExp = /^[\d.\-M][\d.\-,\s]/,
|
1243 | _quotesExp = /["']/g,
|
1244 | _parseObjectInString = function _parseObjectInString(value) {
|
1245 | var obj = {},
|
1246 | split = value.substr(1, value.length - 3).split(":"),
|
1247 | key = split[0],
|
1248 | i = 1,
|
1249 | l = split.length,
|
1250 | index,
|
1251 | val,
|
1252 | parsedVal;
|
1253 |
|
1254 | for (; i < l; i++) {
|
1255 | val = split[i];
|
1256 | index = i !== l - 1 ? val.lastIndexOf(",") : val.length;
|
1257 | parsedVal = val.substr(0, index);
|
1258 | obj[key] = isNaN(parsedVal) ? parsedVal.replace(_quotesExp, "").trim() : +parsedVal;
|
1259 | key = val.substr(index + 1).trim();
|
1260 | }
|
1261 |
|
1262 | return obj;
|
1263 | },
|
1264 | _valueInParentheses = function _valueInParentheses(value) {
|
1265 | var open = value.indexOf("(") + 1,
|
1266 | close = value.indexOf(")"),
|
1267 | nested = value.indexOf("(", open);
|
1268 | return value.substring(open, ~nested && nested < close ? value.indexOf(")", close + 1) : close);
|
1269 | },
|
1270 | _configEaseFromString = function _configEaseFromString(name) {
|
1271 | var split = (name + "").split("("),
|
1272 | ease = _easeMap[split[0]];
|
1273 | return ease && split.length > 1 && ease.config ? ease.config.apply(null, ~name.indexOf("{") ? [_parseObjectInString(split[1])] : _valueInParentheses(name).split(",").map(_numericIfPossible)) : _easeMap._CE && _customEaseExp.test(name) ? _easeMap._CE("", name) : ease;
|
1274 | },
|
1275 | _invertEase = function _invertEase(ease) {
|
1276 | return function (p) {
|
1277 | return 1 - ease(1 - p);
|
1278 | };
|
1279 | },
|
1280 | _propagateYoyoEase = function _propagateYoyoEase(timeline, isYoyo) {
|
1281 | var child = timeline._first,
|
1282 | ease;
|
1283 |
|
1284 | while (child) {
|
1285 | if (child instanceof Timeline) {
|
1286 | _propagateYoyoEase(child, isYoyo);
|
1287 | } else if (child.vars.yoyoEase && (!child._yoyo || !child._repeat) && child._yoyo !== isYoyo) {
|
1288 | if (child.timeline) {
|
1289 | _propagateYoyoEase(child.timeline, isYoyo);
|
1290 | } else {
|
1291 | ease = child._ease;
|
1292 | child._ease = child._yEase;
|
1293 | child._yEase = ease;
|
1294 | child._yoyo = isYoyo;
|
1295 | }
|
1296 | }
|
1297 |
|
1298 | child = child._next;
|
1299 | }
|
1300 | },
|
1301 | _parseEase = function _parseEase(ease, defaultEase) {
|
1302 | return !ease ? defaultEase : (_isFunction(ease) ? ease : _easeMap[ease] || _configEaseFromString(ease)) || defaultEase;
|
1303 | },
|
1304 | _insertEase = function _insertEase(names, easeIn, easeOut, easeInOut) {
|
1305 | if (easeOut === void 0) {
|
1306 | easeOut = function easeOut(p) {
|
1307 | return 1 - easeIn(1 - p);
|
1308 | };
|
1309 | }
|
1310 |
|
1311 | if (easeInOut === void 0) {
|
1312 | easeInOut = function easeInOut(p) {
|
1313 | return p < .5 ? easeIn(p * 2) / 2 : 1 - easeIn((1 - p) * 2) / 2;
|
1314 | };
|
1315 | }
|
1316 |
|
1317 | var ease = {
|
1318 | easeIn: easeIn,
|
1319 | easeOut: easeOut,
|
1320 | easeInOut: easeInOut
|
1321 | },
|
1322 | lowercaseName;
|
1323 |
|
1324 | _forEachName(names, function (name) {
|
1325 | _easeMap[name] = _globals[name] = ease;
|
1326 | _easeMap[lowercaseName = name.toLowerCase()] = easeOut;
|
1327 |
|
1328 | for (var p in ease) {
|
1329 | _easeMap[lowercaseName + (p === "easeIn" ? ".in" : p === "easeOut" ? ".out" : ".inOut")] = _easeMap[name + "." + p] = ease[p];
|
1330 | }
|
1331 | });
|
1332 |
|
1333 | return ease;
|
1334 | },
|
1335 | _easeInOutFromOut = function _easeInOutFromOut(easeOut) {
|
1336 | return function (p) {
|
1337 | return p < .5 ? (1 - easeOut(1 - p * 2)) / 2 : .5 + easeOut((p - .5) * 2) / 2;
|
1338 | };
|
1339 | },
|
1340 | _configElastic = function _configElastic(type, amplitude, period) {
|
1341 | var p1 = amplitude >= 1 ? amplitude : 1,
|
1342 | p2 = (period || (type ? .3 : .45)) / (amplitude < 1 ? amplitude : 1),
|
1343 | p3 = p2 / _2PI * (Math.asin(1 / p1) || 0),
|
1344 | easeOut = function easeOut(p) {
|
1345 | return p === 1 ? 1 : p1 * Math.pow(2, -10 * p) * _sin((p - p3) * p2) + 1;
|
1346 | },
|
1347 | ease = type === "out" ? easeOut : type === "in" ? function (p) {
|
1348 | return 1 - easeOut(1 - p);
|
1349 | } : _easeInOutFromOut(easeOut);
|
1350 |
|
1351 | p2 = _2PI / p2;
|
1352 |
|
1353 | ease.config = function (amplitude, period) {
|
1354 | return _configElastic(type, amplitude, period);
|
1355 | };
|
1356 |
|
1357 | return ease;
|
1358 | },
|
1359 | _configBack = function _configBack(type, overshoot) {
|
1360 | if (overshoot === void 0) {
|
1361 | overshoot = 1.70158;
|
1362 | }
|
1363 |
|
1364 | var easeOut = function easeOut(p) {
|
1365 | return p ? --p * p * ((overshoot + 1) * p + overshoot) + 1 : 0;
|
1366 | },
|
1367 | ease = type === "out" ? easeOut : type === "in" ? function (p) {
|
1368 | return 1 - easeOut(1 - p);
|
1369 | } : _easeInOutFromOut(easeOut);
|
1370 |
|
1371 | ease.config = function (overshoot) {
|
1372 | return _configBack(type, overshoot);
|
1373 | };
|
1374 |
|
1375 | return ease;
|
1376 | };
|
1377 |
|
1378 | _forEachName("Linear,Quad,Cubic,Quart,Quint,Strong", function (name, i) {
|
1379 | var power = i < 5 ? i + 1 : i;
|
1380 |
|
1381 | _insertEase(name + ",Power" + (power - 1), i ? function (p) {
|
1382 | return Math.pow(p, power);
|
1383 | } : function (p) {
|
1384 | return p;
|
1385 | }, function (p) {
|
1386 | return 1 - Math.pow(1 - p, power);
|
1387 | }, function (p) {
|
1388 | return p < .5 ? Math.pow(p * 2, power) / 2 : 1 - Math.pow((1 - p) * 2, power) / 2;
|
1389 | });
|
1390 | });
|
1391 |
|
1392 | _easeMap.Linear.easeNone = _easeMap.none = _easeMap.Linear.easeIn;
|
1393 |
|
1394 | _insertEase("Elastic", _configElastic("in"), _configElastic("out"), _configElastic());
|
1395 |
|
1396 | (function (n, c) {
|
1397 | var n1 = 1 / c,
|
1398 | n2 = 2 * n1,
|
1399 | n3 = 2.5 * n1,
|
1400 | easeOut = function easeOut(p) {
|
1401 | 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;
|
1402 | };
|
1403 |
|
1404 | _insertEase("Bounce", function (p) {
|
1405 | return 1 - easeOut(1 - p);
|
1406 | }, easeOut);
|
1407 | })(7.5625, 2.75);
|
1408 |
|
1409 | _insertEase("Expo", function (p) {
|
1410 | return p ? Math.pow(2, 10 * (p - 1)) : 0;
|
1411 | });
|
1412 |
|
1413 | _insertEase("Circ", function (p) {
|
1414 | return -(_sqrt(1 - p * p) - 1);
|
1415 | });
|
1416 |
|
1417 | _insertEase("Sine", function (p) {
|
1418 | return p === 1 ? 1 : -_cos(p * _HALF_PI) + 1;
|
1419 | });
|
1420 |
|
1421 | _insertEase("Back", _configBack("in"), _configBack("out"), _configBack());
|
1422 |
|
1423 | _easeMap.SteppedEase = _easeMap.steps = _globals.SteppedEase = {
|
1424 | config: function config(steps, immediateStart) {
|
1425 | if (steps === void 0) {
|
1426 | steps = 1;
|
1427 | }
|
1428 |
|
1429 | var p1 = 1 / steps,
|
1430 | p2 = steps + (immediateStart ? 0 : 1),
|
1431 | p3 = immediateStart ? 1 : 0,
|
1432 | max = 1 - _tinyNum;
|
1433 | return function (p) {
|
1434 | return ((p2 * _clamp(0, max, p) | 0) + p3) * p1;
|
1435 | };
|
1436 | }
|
1437 | };
|
1438 | _defaults.ease = _easeMap["quad.out"];
|
1439 |
|
1440 | _forEachName("onComplete,onUpdate,onStart,onRepeat,onReverseComplete,onInterrupt", function (name) {
|
1441 | return _callbackNames += name + "," + name + "Params,";
|
1442 | });
|
1443 |
|
1444 | var GSCache = function GSCache(target, harness) {
|
1445 | this.id = _gsID++;
|
1446 | target._gsap = this;
|
1447 | this.target = target;
|
1448 | this.harness = harness;
|
1449 | this.get = harness ? harness.get : _getProperty;
|
1450 | this.set = harness ? harness.getSetter : _getSetter;
|
1451 | };
|
1452 | var Animation = function () {
|
1453 | function Animation(vars, time) {
|
1454 | var parent = vars.parent || _globalTimeline;
|
1455 | this.vars = vars;
|
1456 | this._delay = +vars.delay || 0;
|
1457 |
|
1458 | if (this._repeat = vars.repeat || 0) {
|
1459 | this._rDelay = vars.repeatDelay || 0;
|
1460 | this._yoyo = !!vars.yoyo || !!vars.yoyoEase;
|
1461 | }
|
1462 |
|
1463 | this._ts = 1;
|
1464 |
|
1465 | _setDuration(this, +vars.duration, 1, 1);
|
1466 |
|
1467 | this.data = vars.data;
|
1468 | _tickerActive || _ticker.wake();
|
1469 | parent && _addToTimeline(parent, this, time || time === 0 ? time : parent._time, 1);
|
1470 | vars.reversed && this.reverse();
|
1471 | vars.paused && this.paused(true);
|
1472 | }
|
1473 |
|
1474 | var _proto = Animation.prototype;
|
1475 |
|
1476 | _proto.delay = function delay(value) {
|
1477 | if (value || value === 0) {
|
1478 | this.parent && this.parent.smoothChildTiming && this.startTime(this._start + value - this._delay);
|
1479 | this._delay = value;
|
1480 | return this;
|
1481 | }
|
1482 |
|
1483 | return this._delay;
|
1484 | };
|
1485 |
|
1486 | _proto.duration = function duration(value) {
|
1487 | return arguments.length ? this.totalDuration(this._repeat > 0 ? value + (value + this._rDelay) * this._repeat : value) : this.totalDuration() && this._dur;
|
1488 | };
|
1489 |
|
1490 | _proto.totalDuration = function totalDuration(value) {
|
1491 | if (!arguments.length) {
|
1492 | return this._tDur;
|
1493 | }
|
1494 |
|
1495 | this._dirty = 0;
|
1496 | return _setDuration(this, this._repeat < 0 ? value : (value - this._repeat * this._rDelay) / (this._repeat + 1));
|
1497 | };
|
1498 |
|
1499 | _proto.totalTime = function totalTime(_totalTime, suppressEvents) {
|
1500 | _wake();
|
1501 |
|
1502 | if (!arguments.length) {
|
1503 | return this._tTime;
|
1504 | }
|
1505 |
|
1506 | var parent = this._dp;
|
1507 |
|
1508 | if (parent && parent.smoothChildTiming && this._ts) {
|
1509 | _alignPlayhead(this, _totalTime);
|
1510 |
|
1511 | while (parent.parent) {
|
1512 | if (parent.parent._time !== parent._start + (parent._ts >= 0 ? parent._tTime / parent._ts : (parent.totalDuration() - parent._tTime) / -parent._ts)) {
|
1513 | parent.totalTime(parent._tTime, true);
|
1514 | }
|
1515 |
|
1516 | parent = parent.parent;
|
1517 | }
|
1518 |
|
1519 | if (!this.parent && this._dp.autoRemoveChildren && (this._ts > 0 && _totalTime < this._tDur || this._ts < 0 && _totalTime > 0 || !this._tDur && !_totalTime)) {
|
1520 | _addToTimeline(this._dp, this, this._start - this._delay);
|
1521 | }
|
1522 | }
|
1523 |
|
1524 | if (this._tTime !== _totalTime || !this._dur && !suppressEvents || this._initted && Math.abs(this._zTime) === _tinyNum || !_totalTime && !this._initted && (this.add || this._ptLookup)) {
|
1525 | this._ts || (this._pTime = _totalTime);
|
1526 |
|
1527 | _lazySafeRender(this, _totalTime, suppressEvents);
|
1528 | }
|
1529 |
|
1530 | return this;
|
1531 | };
|
1532 |
|
1533 | _proto.time = function time(value, suppressEvents) {
|
1534 | return arguments.length ? this.totalTime(Math.min(this.totalDuration(), value + _elapsedCycleDuration(this)) % this._dur || (value ? this._dur : 0), suppressEvents) : this._time;
|
1535 | };
|
1536 |
|
1537 | _proto.totalProgress = function totalProgress(value, suppressEvents) {
|
1538 | return arguments.length ? this.totalTime(this.totalDuration() * value, suppressEvents) : this.totalDuration() ? Math.min(1, this._tTime / this._tDur) : this.ratio;
|
1539 | };
|
1540 |
|
1541 | _proto.progress = function progress(value, suppressEvents) {
|
1542 | return arguments.length ? this.totalTime(this.duration() * (this._yoyo && !(this.iteration() & 1) ? 1 - value : value) + _elapsedCycleDuration(this), suppressEvents) : this.duration() ? Math.min(1, this._time / this._dur) : this.ratio;
|
1543 | };
|
1544 |
|
1545 | _proto.iteration = function iteration(value, suppressEvents) {
|
1546 | var cycleDuration = this.duration() + this._rDelay;
|
1547 |
|
1548 | return arguments.length ? this.totalTime(this._time + (value - 1) * cycleDuration, suppressEvents) : this._repeat ? _animationCycle(this._tTime, cycleDuration) + 1 : 1;
|
1549 | };
|
1550 |
|
1551 | _proto.timeScale = function timeScale(value) {
|
1552 | if (!arguments.length) {
|
1553 | return this._rts === -_tinyNum ? 0 : this._rts;
|
1554 | }
|
1555 |
|
1556 | if (this._rts === value) {
|
1557 | return this;
|
1558 | }
|
1559 |
|
1560 | var tTime = this.parent && this._ts ? _parentToChildTotalTime(this.parent._time, this) : this._tTime;
|
1561 | this._rts = +value || 0;
|
1562 | this._ts = this._ps || value === -_tinyNum ? 0 : this._rts;
|
1563 | return _recacheAncestors(this.totalTime(_clamp(-this._delay, this._tDur, tTime), true));
|
1564 | };
|
1565 |
|
1566 | _proto.paused = function paused(value) {
|
1567 | if (!arguments.length) {
|
1568 | return this._ps;
|
1569 | }
|
1570 |
|
1571 | if (this._ps !== value) {
|
1572 | this._ps = value;
|
1573 |
|
1574 | if (value) {
|
1575 | this._pTime = this._tTime || Math.max(-this._delay, this.rawTime());
|
1576 | this._ts = this._act = 0;
|
1577 | } else {
|
1578 | _wake();
|
1579 |
|
1580 | this._ts = this._rts;
|
1581 | this.totalTime(this.parent && !this.parent.smoothChildTiming ? this.rawTime() : this._tTime || this._pTime, this.progress() === 1 && (this._tTime -= _tinyNum) && Math.abs(this._zTime) !== _tinyNum);
|
1582 | }
|
1583 | }
|
1584 |
|
1585 | return this;
|
1586 | };
|
1587 |
|
1588 | _proto.startTime = function startTime(value) {
|
1589 | if (arguments.length) {
|
1590 | this._start = value;
|
1591 | var parent = this.parent || this._dp;
|
1592 | parent && (parent._sort || !this.parent) && _addToTimeline(parent, this, value - this._delay);
|
1593 | return this;
|
1594 | }
|
1595 |
|
1596 | return this._start;
|
1597 | };
|
1598 |
|
1599 | _proto.endTime = function endTime(includeRepeats) {
|
1600 | return this._start + (_isNotFalse(includeRepeats) ? this.totalDuration() : this.duration()) / Math.abs(this._ts);
|
1601 | };
|
1602 |
|
1603 | _proto.rawTime = function rawTime(wrapRepeats) {
|
1604 | var parent = this.parent || this._dp;
|
1605 | 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);
|
1606 | };
|
1607 |
|
1608 | _proto.globalTime = function globalTime(rawTime) {
|
1609 | var animation = this,
|
1610 | time = arguments.length ? rawTime : animation.rawTime();
|
1611 |
|
1612 | while (animation) {
|
1613 | time = animation._start + time / (animation._ts || 1);
|
1614 | animation = animation._dp;
|
1615 | }
|
1616 |
|
1617 | return time;
|
1618 | };
|
1619 |
|
1620 | _proto.repeat = function repeat(value) {
|
1621 | if (arguments.length) {
|
1622 | this._repeat = value;
|
1623 | return _onUpdateTotalDuration(this);
|
1624 | }
|
1625 |
|
1626 | return this._repeat;
|
1627 | };
|
1628 |
|
1629 | _proto.repeatDelay = function repeatDelay(value) {
|
1630 | if (arguments.length) {
|
1631 | this._rDelay = value;
|
1632 | return _onUpdateTotalDuration(this);
|
1633 | }
|
1634 |
|
1635 | return this._rDelay;
|
1636 | };
|
1637 |
|
1638 | _proto.yoyo = function yoyo(value) {
|
1639 | if (arguments.length) {
|
1640 | this._yoyo = value;
|
1641 | return this;
|
1642 | }
|
1643 |
|
1644 | return this._yoyo;
|
1645 | };
|
1646 |
|
1647 | _proto.seek = function seek(position, suppressEvents) {
|
1648 | return this.totalTime(_parsePosition(this, position), _isNotFalse(suppressEvents));
|
1649 | };
|
1650 |
|
1651 | _proto.restart = function restart(includeDelay, suppressEvents) {
|
1652 | return this.play().totalTime(includeDelay ? -this._delay : 0, _isNotFalse(suppressEvents));
|
1653 | };
|
1654 |
|
1655 | _proto.play = function play(from, suppressEvents) {
|
1656 | from != null && this.seek(from, suppressEvents);
|
1657 | return this.reversed(false).paused(false);
|
1658 | };
|
1659 |
|
1660 | _proto.reverse = function reverse(from, suppressEvents) {
|
1661 | from != null && this.seek(from || this.totalDuration(), suppressEvents);
|
1662 | return this.reversed(true).paused(false);
|
1663 | };
|
1664 |
|
1665 | _proto.pause = function pause(atTime, suppressEvents) {
|
1666 | atTime != null && this.seek(atTime, suppressEvents);
|
1667 | return this.paused(true);
|
1668 | };
|
1669 |
|
1670 | _proto.resume = function resume() {
|
1671 | return this.paused(false);
|
1672 | };
|
1673 |
|
1674 | _proto.reversed = function reversed(value) {
|
1675 | if (arguments.length) {
|
1676 | !!value !== this.reversed() && this.timeScale(-this._rts || (value ? -_tinyNum : 0));
|
1677 | return this;
|
1678 | }
|
1679 |
|
1680 | return this._rts < 0;
|
1681 | };
|
1682 |
|
1683 | _proto.invalidate = function invalidate() {
|
1684 | this._initted = 0;
|
1685 | this._zTime = -_tinyNum;
|
1686 | return this;
|
1687 | };
|
1688 |
|
1689 | _proto.isActive = function isActive() {
|
1690 | var parent = this.parent || this._dp,
|
1691 | start = this._start,
|
1692 | rawTime;
|
1693 | return !!(!parent || this._ts && this._initted && parent.isActive() && (rawTime = parent.rawTime(true)) >= start && rawTime < this.endTime(true) - _tinyNum);
|
1694 | };
|
1695 |
|
1696 | _proto.eventCallback = function eventCallback(type, callback, params) {
|
1697 | var vars = this.vars;
|
1698 |
|
1699 | if (arguments.length > 1) {
|
1700 | if (!callback) {
|
1701 | delete vars[type];
|
1702 | } else {
|
1703 | vars[type] = callback;
|
1704 | params && (vars[type + "Params"] = params);
|
1705 | type === "onUpdate" && (this._onUpdate = callback);
|
1706 | }
|
1707 |
|
1708 | return this;
|
1709 | }
|
1710 |
|
1711 | return vars[type];
|
1712 | };
|
1713 |
|
1714 | _proto.then = function then(onFulfilled) {
|
1715 | var self = this;
|
1716 | return new Promise(function (resolve) {
|
1717 | var f = _isFunction(onFulfilled) ? onFulfilled : _passThrough,
|
1718 | _resolve = function _resolve() {
|
1719 | var _then = self.then;
|
1720 | self.then = null;
|
1721 | _isFunction(f) && (f = f(self)) && (f.then || f === self) && (self.then = _then);
|
1722 | resolve(f);
|
1723 | self.then = _then;
|
1724 | };
|
1725 |
|
1726 | if (self._initted && self.totalProgress() === 1 && self._ts >= 0 || !self._tTime && self._ts < 0) {
|
1727 | _resolve();
|
1728 | } else {
|
1729 | self._prom = _resolve;
|
1730 | }
|
1731 | });
|
1732 | };
|
1733 |
|
1734 | _proto.kill = function kill() {
|
1735 | _interrupt(this);
|
1736 | };
|
1737 |
|
1738 | return Animation;
|
1739 | }();
|
1740 |
|
1741 | _setDefaults(Animation.prototype, {
|
1742 | _time: 0,
|
1743 | _start: 0,
|
1744 | _end: 0,
|
1745 | _tTime: 0,
|
1746 | _tDur: 0,
|
1747 | _dirty: 0,
|
1748 | _repeat: 0,
|
1749 | _yoyo: false,
|
1750 | parent: null,
|
1751 | _initted: false,
|
1752 | _rDelay: 0,
|
1753 | _ts: 1,
|
1754 | _dp: 0,
|
1755 | ratio: 0,
|
1756 | _zTime: -_tinyNum,
|
1757 | _prom: 0,
|
1758 | _ps: false,
|
1759 | _rts: 1
|
1760 | });
|
1761 |
|
1762 | var Timeline = function (_Animation) {
|
1763 | _inheritsLoose(Timeline, _Animation);
|
1764 |
|
1765 | function Timeline(vars, time) {
|
1766 | var _this;
|
1767 |
|
1768 | if (vars === void 0) {
|
1769 | vars = {};
|
1770 | }
|
1771 |
|
1772 | _this = _Animation.call(this, vars, time) || this;
|
1773 | _this.labels = {};
|
1774 | _this.smoothChildTiming = !!vars.smoothChildTiming;
|
1775 | _this.autoRemoveChildren = !!vars.autoRemoveChildren;
|
1776 | _this._sort = _isNotFalse(vars.sortChildren);
|
1777 | _this.parent && _postAddChecks(_this.parent, _assertThisInitialized(_this));
|
1778 | vars.scrollTrigger && _scrollTrigger(_assertThisInitialized(_this), vars.scrollTrigger);
|
1779 | return _this;
|
1780 | }
|
1781 |
|
1782 | var _proto2 = Timeline.prototype;
|
1783 |
|
1784 | _proto2.to = function to(targets, vars, position) {
|
1785 | new Tween(targets, _parseVars(arguments, 0, this), _parsePosition(this, _isNumber(vars) ? arguments[3] : position));
|
1786 | return this;
|
1787 | };
|
1788 |
|
1789 | _proto2.from = function from(targets, vars, position) {
|
1790 | new Tween(targets, _parseVars(arguments, 1, this), _parsePosition(this, _isNumber(vars) ? arguments[3] : position));
|
1791 | return this;
|
1792 | };
|
1793 |
|
1794 | _proto2.fromTo = function fromTo(targets, fromVars, toVars, position) {
|
1795 | new Tween(targets, _parseVars(arguments, 2, this), _parsePosition(this, _isNumber(fromVars) ? arguments[4] : position));
|
1796 | return this;
|
1797 | };
|
1798 |
|
1799 | _proto2.set = function set(targets, vars, position) {
|
1800 | vars.duration = 0;
|
1801 | vars.parent = this;
|
1802 | _inheritDefaults(vars).repeatDelay || (vars.repeat = 0);
|
1803 | vars.immediateRender = !!vars.immediateRender;
|
1804 | new Tween(targets, vars, _parsePosition(this, position), 1);
|
1805 | return this;
|
1806 | };
|
1807 |
|
1808 | _proto2.call = function call(callback, params, position) {
|
1809 | return _addToTimeline(this, Tween.delayedCall(0, callback, params), _parsePosition(this, position));
|
1810 | };
|
1811 |
|
1812 | _proto2.staggerTo = function staggerTo(targets, duration, vars, stagger, position, onCompleteAll, onCompleteAllParams) {
|
1813 | vars.duration = duration;
|
1814 | vars.stagger = vars.stagger || stagger;
|
1815 | vars.onComplete = onCompleteAll;
|
1816 | vars.onCompleteParams = onCompleteAllParams;
|
1817 | vars.parent = this;
|
1818 | new Tween(targets, vars, _parsePosition(this, position));
|
1819 | return this;
|
1820 | };
|
1821 |
|
1822 | _proto2.staggerFrom = function staggerFrom(targets, duration, vars, stagger, position, onCompleteAll, onCompleteAllParams) {
|
1823 | vars.runBackwards = 1;
|
1824 | _inheritDefaults(vars).immediateRender = _isNotFalse(vars.immediateRender);
|
1825 | return this.staggerTo(targets, duration, vars, stagger, position, onCompleteAll, onCompleteAllParams);
|
1826 | };
|
1827 |
|
1828 | _proto2.staggerFromTo = function staggerFromTo(targets, duration, fromVars, toVars, stagger, position, onCompleteAll, onCompleteAllParams) {
|
1829 | toVars.startAt = fromVars;
|
1830 | _inheritDefaults(toVars).immediateRender = _isNotFalse(toVars.immediateRender);
|
1831 | return this.staggerTo(targets, duration, toVars, stagger, position, onCompleteAll, onCompleteAllParams);
|
1832 | };
|
1833 |
|
1834 | _proto2.render = function render(totalTime, suppressEvents, force) {
|
1835 | var prevTime = this._time,
|
1836 | tDur = this._dirty ? this.totalDuration() : this._tDur,
|
1837 | dur = this._dur,
|
1838 | tTime = this !== _globalTimeline && totalTime > tDur - _tinyNum && totalTime >= 0 ? tDur : totalTime < _tinyNum ? 0 : totalTime,
|
1839 | crossingStart = this._zTime < 0 !== totalTime < 0 && (this._initted || !dur),
|
1840 | time,
|
1841 | child,
|
1842 | next,
|
1843 | iteration,
|
1844 | cycleDuration,
|
1845 | prevPaused,
|
1846 | pauseTween,
|
1847 | timeScale,
|
1848 | prevStart,
|
1849 | prevIteration,
|
1850 | yoyo,
|
1851 | isYoyo;
|
1852 |
|
1853 | if (tTime !== this._tTime || force || crossingStart) {
|
1854 | if (prevTime !== this._time && dur) {
|
1855 | tTime += this._time - prevTime;
|
1856 | totalTime += this._time - prevTime;
|
1857 | }
|
1858 |
|
1859 | time = tTime;
|
1860 | prevStart = this._start;
|
1861 | timeScale = this._ts;
|
1862 | prevPaused = !timeScale;
|
1863 |
|
1864 | if (crossingStart) {
|
1865 | dur || (prevTime = this._zTime);
|
1866 | (totalTime || !suppressEvents) && (this._zTime = totalTime);
|
1867 | }
|
1868 |
|
1869 | if (this._repeat) {
|
1870 | yoyo = this._yoyo;
|
1871 | cycleDuration = dur + this._rDelay;
|
1872 | time = _round(tTime % cycleDuration);
|
1873 |
|
1874 | if (tTime === tDur) {
|
1875 | iteration = this._repeat;
|
1876 | time = dur;
|
1877 | } else {
|
1878 | iteration = ~~(tTime / cycleDuration);
|
1879 |
|
1880 | if (iteration && iteration === tTime / cycleDuration) {
|
1881 | time = dur;
|
1882 | iteration--;
|
1883 | }
|
1884 |
|
1885 | time > dur && (time = dur);
|
1886 | }
|
1887 |
|
1888 | prevIteration = _animationCycle(this._tTime, cycleDuration);
|
1889 | !prevTime && this._tTime && prevIteration !== iteration && (prevIteration = iteration);
|
1890 |
|
1891 | if (yoyo && iteration & 1) {
|
1892 | time = dur - time;
|
1893 | isYoyo = 1;
|
1894 | }
|
1895 |
|
1896 | if (iteration !== prevIteration && !this._lock) {
|
1897 | var rewinding = yoyo && prevIteration & 1,
|
1898 | doesWrap = rewinding === (yoyo && iteration & 1);
|
1899 | iteration < prevIteration && (rewinding = !rewinding);
|
1900 | prevTime = rewinding ? 0 : dur;
|
1901 | this._lock = 1;
|
1902 | this.render(prevTime || (isYoyo ? 0 : _round(iteration * cycleDuration)), suppressEvents, !dur)._lock = 0;
|
1903 | !suppressEvents && this.parent && _callback(this, "onRepeat");
|
1904 | this.vars.repeatRefresh && !isYoyo && (this.invalidate()._lock = 1);
|
1905 |
|
1906 | if (prevTime !== this._time || prevPaused !== !this._ts) {
|
1907 | return this;
|
1908 | }
|
1909 |
|
1910 | dur = this._dur;
|
1911 | tDur = this._tDur;
|
1912 |
|
1913 | if (doesWrap) {
|
1914 | this._lock = 2;
|
1915 | prevTime = rewinding ? dur : -0.0001;
|
1916 | this.render(prevTime, true);
|
1917 | this.vars.repeatRefresh && !isYoyo && this.invalidate();
|
1918 | }
|
1919 |
|
1920 | this._lock = 0;
|
1921 |
|
1922 | if (!this._ts && !prevPaused) {
|
1923 | return this;
|
1924 | }
|
1925 |
|
1926 | _propagateYoyoEase(this, isYoyo);
|
1927 | }
|
1928 | }
|
1929 |
|
1930 | if (this._hasPause && !this._forcing && this._lock < 2) {
|
1931 | pauseTween = _findNextPauseTween(this, _round(prevTime), _round(time));
|
1932 |
|
1933 | if (pauseTween) {
|
1934 | tTime -= time - (time = pauseTween._start);
|
1935 | }
|
1936 | }
|
1937 |
|
1938 | this._tTime = tTime;
|
1939 | this._time = time;
|
1940 | this._act = !timeScale;
|
1941 |
|
1942 | if (!this._initted) {
|
1943 | this._onUpdate = this.vars.onUpdate;
|
1944 | this._initted = 1;
|
1945 | this._zTime = totalTime;
|
1946 | }
|
1947 |
|
1948 | !prevTime && time && !suppressEvents && _callback(this, "onStart");
|
1949 |
|
1950 | if (time >= prevTime && totalTime >= 0) {
|
1951 | child = this._first;
|
1952 |
|
1953 | while (child) {
|
1954 | next = child._next;
|
1955 |
|
1956 | if ((child._act || time >= child._start) && child._ts && pauseTween !== child) {
|
1957 | if (child.parent !== this) {
|
1958 | return this.render(totalTime, suppressEvents, force);
|
1959 | }
|
1960 |
|
1961 | child.render(child._ts > 0 ? (time - child._start) * child._ts : (child._dirty ? child.totalDuration() : child._tDur) + (time - child._start) * child._ts, suppressEvents, force);
|
1962 |
|
1963 | if (time !== this._time || !this._ts && !prevPaused) {
|
1964 | pauseTween = 0;
|
1965 | next && (tTime += this._zTime = -_tinyNum);
|
1966 | break;
|
1967 | }
|
1968 | }
|
1969 |
|
1970 | child = next;
|
1971 | }
|
1972 | } else {
|
1973 | child = this._last;
|
1974 | var adjustedTime = totalTime < 0 ? totalTime : time;
|
1975 |
|
1976 | while (child) {
|
1977 | next = child._prev;
|
1978 |
|
1979 | if ((child._act || adjustedTime <= child._end) && child._ts && pauseTween !== child) {
|
1980 | if (child.parent !== this) {
|
1981 | return this.render(totalTime, suppressEvents, force);
|
1982 | }
|
1983 |
|
1984 | child.render(child._ts > 0 ? (adjustedTime - child._start) * child._ts : (child._dirty ? child.totalDuration() : child._tDur) + (adjustedTime - child._start) * child._ts, suppressEvents, force);
|
1985 |
|
1986 | if (time !== this._time || !this._ts && !prevPaused) {
|
1987 | pauseTween = 0;
|
1988 | next && (tTime += this._zTime = adjustedTime ? -_tinyNum : _tinyNum);
|
1989 | break;
|
1990 | }
|
1991 | }
|
1992 |
|
1993 | child = next;
|
1994 | }
|
1995 | }
|
1996 |
|
1997 | if (pauseTween && !suppressEvents) {
|
1998 | this.pause();
|
1999 | pauseTween.render(time >= prevTime ? 0 : -_tinyNum)._zTime = time >= prevTime ? 1 : -1;
|
2000 |
|
2001 | if (this._ts) {
|
2002 | this._start = prevStart;
|
2003 |
|
2004 | _setEnd(this);
|
2005 |
|
2006 | return this.render(totalTime, suppressEvents, force);
|
2007 | }
|
2008 | }
|
2009 |
|
2010 | this._onUpdate && !suppressEvents && _callback(this, "onUpdate", true);
|
2011 | if (tTime === tDur && tDur >= this.totalDuration() || !tTime && prevTime) if (prevStart === this._start || Math.abs(timeScale) !== Math.abs(this._ts)) if (!this._lock) {
|
2012 | (totalTime || !dur) && (tTime === tDur && this._ts > 0 || !tTime && this._ts < 0) && _removeFromParent(this, 1);
|
2013 |
|
2014 | if (!suppressEvents && !(totalTime < 0 && !prevTime) && (tTime || prevTime)) {
|
2015 | _callback(this, tTime === tDur ? "onComplete" : "onReverseComplete", true);
|
2016 |
|
2017 | this._prom && !(tTime < tDur && this.timeScale() > 0) && this._prom();
|
2018 | }
|
2019 | }
|
2020 | }
|
2021 |
|
2022 | return this;
|
2023 | };
|
2024 |
|
2025 | _proto2.add = function add(child, position) {
|
2026 | var _this2 = this;
|
2027 |
|
2028 | if (!_isNumber(position)) {
|
2029 | position = _parsePosition(this, position);
|
2030 | }
|
2031 |
|
2032 | if (!(child instanceof Animation)) {
|
2033 | if (_isArray(child)) {
|
2034 | child.forEach(function (obj) {
|
2035 | return _this2.add(obj, position);
|
2036 | });
|
2037 | return this;
|
2038 | }
|
2039 |
|
2040 | if (_isString(child)) {
|
2041 | return this.addLabel(child, position);
|
2042 | }
|
2043 |
|
2044 | if (_isFunction(child)) {
|
2045 | child = Tween.delayedCall(0, child);
|
2046 | } else {
|
2047 | return this;
|
2048 | }
|
2049 | }
|
2050 |
|
2051 | return this !== child ? _addToTimeline(this, child, position) : this;
|
2052 | };
|
2053 |
|
2054 | _proto2.getChildren = function getChildren(nested, tweens, timelines, ignoreBeforeTime) {
|
2055 | if (nested === void 0) {
|
2056 | nested = true;
|
2057 | }
|
2058 |
|
2059 | if (tweens === void 0) {
|
2060 | tweens = true;
|
2061 | }
|
2062 |
|
2063 | if (timelines === void 0) {
|
2064 | timelines = true;
|
2065 | }
|
2066 |
|
2067 | if (ignoreBeforeTime === void 0) {
|
2068 | ignoreBeforeTime = -_bigNum;
|
2069 | }
|
2070 |
|
2071 | var a = [],
|
2072 | child = this._first;
|
2073 |
|
2074 | while (child) {
|
2075 | if (child._start >= ignoreBeforeTime) {
|
2076 | if (child instanceof Tween) {
|
2077 | tweens && a.push(child);
|
2078 | } else {
|
2079 | timelines && a.push(child);
|
2080 | nested && a.push.apply(a, child.getChildren(true, tweens, timelines));
|
2081 | }
|
2082 | }
|
2083 |
|
2084 | child = child._next;
|
2085 | }
|
2086 |
|
2087 | return a;
|
2088 | };
|
2089 |
|
2090 | _proto2.getById = function getById(id) {
|
2091 | var animations = this.getChildren(1, 1, 1),
|
2092 | i = animations.length;
|
2093 |
|
2094 | while (i--) {
|
2095 | if (animations[i].vars.id === id) {
|
2096 | return animations[i];
|
2097 | }
|
2098 | }
|
2099 | };
|
2100 |
|
2101 | _proto2.remove = function remove(child) {
|
2102 | if (_isString(child)) {
|
2103 | return this.removeLabel(child);
|
2104 | }
|
2105 |
|
2106 | if (_isFunction(child)) {
|
2107 | return this.killTweensOf(child);
|
2108 | }
|
2109 |
|
2110 | _removeLinkedListItem(this, child);
|
2111 |
|
2112 | if (child === this._recent) {
|
2113 | this._recent = this._last;
|
2114 | }
|
2115 |
|
2116 | return _uncache(this);
|
2117 | };
|
2118 |
|
2119 | _proto2.totalTime = function totalTime(_totalTime2, suppressEvents) {
|
2120 | if (!arguments.length) {
|
2121 | return this._tTime;
|
2122 | }
|
2123 |
|
2124 | this._forcing = 1;
|
2125 |
|
2126 | if (!this._dp && this._ts) {
|
2127 | this._start = _round(_ticker.time - (this._ts > 0 ? _totalTime2 / this._ts : (this.totalDuration() - _totalTime2) / -this._ts));
|
2128 | }
|
2129 |
|
2130 | _Animation.prototype.totalTime.call(this, _totalTime2, suppressEvents);
|
2131 |
|
2132 | this._forcing = 0;
|
2133 | return this;
|
2134 | };
|
2135 |
|
2136 | _proto2.addLabel = function addLabel(label, position) {
|
2137 | this.labels[label] = _parsePosition(this, position);
|
2138 | return this;
|
2139 | };
|
2140 |
|
2141 | _proto2.removeLabel = function removeLabel(label) {
|
2142 | delete this.labels[label];
|
2143 | return this;
|
2144 | };
|
2145 |
|
2146 | _proto2.addPause = function addPause(position, callback, params) {
|
2147 | var t = Tween.delayedCall(0, callback || _emptyFunc, params);
|
2148 | t.data = "isPause";
|
2149 | this._hasPause = 1;
|
2150 | return _addToTimeline(this, t, _parsePosition(this, position));
|
2151 | };
|
2152 |
|
2153 | _proto2.removePause = function removePause(position) {
|
2154 | var child = this._first;
|
2155 | position = _parsePosition(this, position);
|
2156 |
|
2157 | while (child) {
|
2158 | if (child._start === position && child.data === "isPause") {
|
2159 | _removeFromParent(child);
|
2160 | }
|
2161 |
|
2162 | child = child._next;
|
2163 | }
|
2164 | };
|
2165 |
|
2166 | _proto2.killTweensOf = function killTweensOf(targets, props, onlyActive) {
|
2167 | var tweens = this.getTweensOf(targets, onlyActive),
|
2168 | i = tweens.length;
|
2169 |
|
2170 | while (i--) {
|
2171 | _overwritingTween !== tweens[i] && tweens[i].kill(targets, props);
|
2172 | }
|
2173 |
|
2174 | return this;
|
2175 | };
|
2176 |
|
2177 | _proto2.getTweensOf = function getTweensOf(targets, onlyActive) {
|
2178 | var a = [],
|
2179 | parsedTargets = toArray(targets),
|
2180 | child = this._first,
|
2181 | isGlobalTime = _isNumber(onlyActive),
|
2182 | children;
|
2183 |
|
2184 | while (child) {
|
2185 | if (child instanceof Tween) {
|
2186 | if (_arrayContainsAny(child._targets, parsedTargets) && (isGlobalTime ? (!_overwritingTween || child._initted && child._ts) && child.globalTime(0) <= onlyActive && child.globalTime(child.totalDuration()) > onlyActive : !onlyActive || child.isActive())) {
|
2187 | a.push(child);
|
2188 | }
|
2189 | } else if ((children = child.getTweensOf(parsedTargets, onlyActive)).length) {
|
2190 | a.push.apply(a, children);
|
2191 | }
|
2192 |
|
2193 | child = child._next;
|
2194 | }
|
2195 |
|
2196 | return a;
|
2197 | };
|
2198 |
|
2199 | _proto2.tweenTo = function tweenTo(position, vars) {
|
2200 | vars = vars || {};
|
2201 |
|
2202 | var tl = this,
|
2203 | endTime = _parsePosition(tl, position),
|
2204 | _vars = vars,
|
2205 | startAt = _vars.startAt,
|
2206 | _onStart = _vars.onStart,
|
2207 | onStartParams = _vars.onStartParams,
|
2208 | tween = Tween.to(tl, _setDefaults(vars, {
|
2209 | ease: "none",
|
2210 | lazy: false,
|
2211 | time: endTime,
|
2212 | overwrite: "auto",
|
2213 | duration: vars.duration || Math.abs((endTime - (startAt && "time" in startAt ? startAt.time : tl._time)) / tl.timeScale()) || _tinyNum,
|
2214 | onStart: function onStart() {
|
2215 | tl.pause();
|
2216 | var duration = vars.duration || Math.abs((endTime - tl._time) / tl.timeScale());
|
2217 | tween._dur !== duration && _setDuration(tween, duration, 0, 1).render(tween._time, true, true);
|
2218 | _onStart && _onStart.apply(tween, onStartParams || []);
|
2219 | }
|
2220 | }));
|
2221 |
|
2222 | return tween;
|
2223 | };
|
2224 |
|
2225 | _proto2.tweenFromTo = function tweenFromTo(fromPosition, toPosition, vars) {
|
2226 | return this.tweenTo(toPosition, _setDefaults({
|
2227 | startAt: {
|
2228 | time: _parsePosition(this, fromPosition)
|
2229 | }
|
2230 | }, vars));
|
2231 | };
|
2232 |
|
2233 | _proto2.recent = function recent() {
|
2234 | return this._recent;
|
2235 | };
|
2236 |
|
2237 | _proto2.nextLabel = function nextLabel(afterTime) {
|
2238 | if (afterTime === void 0) {
|
2239 | afterTime = this._time;
|
2240 | }
|
2241 |
|
2242 | return _getLabelInDirection(this, _parsePosition(this, afterTime));
|
2243 | };
|
2244 |
|
2245 | _proto2.previousLabel = function previousLabel(beforeTime) {
|
2246 | if (beforeTime === void 0) {
|
2247 | beforeTime = this._time;
|
2248 | }
|
2249 |
|
2250 | return _getLabelInDirection(this, _parsePosition(this, beforeTime), 1);
|
2251 | };
|
2252 |
|
2253 | _proto2.currentLabel = function currentLabel(value) {
|
2254 | return arguments.length ? this.seek(value, true) : this.previousLabel(this._time + _tinyNum);
|
2255 | };
|
2256 |
|
2257 | _proto2.shiftChildren = function shiftChildren(amount, adjustLabels, ignoreBeforeTime) {
|
2258 | if (ignoreBeforeTime === void 0) {
|
2259 | ignoreBeforeTime = 0;
|
2260 | }
|
2261 |
|
2262 | var child = this._first,
|
2263 | labels = this.labels,
|
2264 | p;
|
2265 |
|
2266 | while (child) {
|
2267 | if (child._start >= ignoreBeforeTime) {
|
2268 | child._start += amount;
|
2269 | child._end += amount;
|
2270 | }
|
2271 |
|
2272 | child = child._next;
|
2273 | }
|
2274 |
|
2275 | if (adjustLabels) {
|
2276 | for (p in labels) {
|
2277 | if (labels[p] >= ignoreBeforeTime) {
|
2278 | labels[p] += amount;
|
2279 | }
|
2280 | }
|
2281 | }
|
2282 |
|
2283 | return _uncache(this);
|
2284 | };
|
2285 |
|
2286 | _proto2.invalidate = function invalidate() {
|
2287 | var child = this._first;
|
2288 | this._lock = 0;
|
2289 |
|
2290 | while (child) {
|
2291 | child.invalidate();
|
2292 | child = child._next;
|
2293 | }
|
2294 |
|
2295 | return _Animation.prototype.invalidate.call(this);
|
2296 | };
|
2297 |
|
2298 | _proto2.clear = function clear(includeLabels) {
|
2299 | if (includeLabels === void 0) {
|
2300 | includeLabels = true;
|
2301 | }
|
2302 |
|
2303 | var child = this._first,
|
2304 | next;
|
2305 |
|
2306 | while (child) {
|
2307 | next = child._next;
|
2308 | this.remove(child);
|
2309 | child = next;
|
2310 | }
|
2311 |
|
2312 | this._time = this._tTime = this._pTime = 0;
|
2313 | includeLabels && (this.labels = {});
|
2314 | return _uncache(this);
|
2315 | };
|
2316 |
|
2317 | _proto2.totalDuration = function totalDuration(value) {
|
2318 | var max = 0,
|
2319 | self = this,
|
2320 | child = self._last,
|
2321 | prevStart = _bigNum,
|
2322 | prev,
|
2323 | start,
|
2324 | parent;
|
2325 |
|
2326 | if (arguments.length) {
|
2327 | return self.timeScale((self._repeat < 0 ? self.duration() : self.totalDuration()) / (self.reversed() ? -value : value));
|
2328 | }
|
2329 |
|
2330 | if (self._dirty) {
|
2331 | parent = self.parent;
|
2332 |
|
2333 | while (child) {
|
2334 | prev = child._prev;
|
2335 | child._dirty && child.totalDuration();
|
2336 | start = child._start;
|
2337 |
|
2338 | if (start > prevStart && self._sort && child._ts && !self._lock) {
|
2339 | self._lock = 1;
|
2340 | _addToTimeline(self, child, start - child._delay, 1)._lock = 0;
|
2341 | } else {
|
2342 | prevStart = start;
|
2343 | }
|
2344 |
|
2345 | if (start < 0 && child._ts) {
|
2346 | max -= start;
|
2347 |
|
2348 | if (!parent && !self._dp || parent && parent.smoothChildTiming) {
|
2349 | self._start += start / self._ts;
|
2350 | self._time -= start;
|
2351 | self._tTime -= start;
|
2352 | }
|
2353 |
|
2354 | self.shiftChildren(-start, false, -1e999);
|
2355 | prevStart = 0;
|
2356 | }
|
2357 |
|
2358 | child._end > max && child._ts && (max = child._end);
|
2359 | child = prev;
|
2360 | }
|
2361 |
|
2362 | _setDuration(self, self === _globalTimeline && self._time > max ? self._time : max, 1, 1);
|
2363 |
|
2364 | self._dirty = 0;
|
2365 | }
|
2366 |
|
2367 | return self._tDur;
|
2368 | };
|
2369 |
|
2370 | Timeline.updateRoot = function updateRoot(time) {
|
2371 | if (_globalTimeline._ts) {
|
2372 | _lazySafeRender(_globalTimeline, _parentToChildTotalTime(time, _globalTimeline));
|
2373 |
|
2374 | _lastRenderedFrame = _ticker.frame;
|
2375 | }
|
2376 |
|
2377 | if (_ticker.frame >= _nextGCFrame) {
|
2378 | _nextGCFrame += _config.autoSleep || 120;
|
2379 | var child = _globalTimeline._first;
|
2380 | if (!child || !child._ts) if (_config.autoSleep && _ticker._listeners.length < 2) {
|
2381 | while (child && !child._ts) {
|
2382 | child = child._next;
|
2383 | }
|
2384 |
|
2385 | child || _ticker.sleep();
|
2386 | }
|
2387 | }
|
2388 | };
|
2389 |
|
2390 | return Timeline;
|
2391 | }(Animation);
|
2392 |
|
2393 | _setDefaults(Timeline.prototype, {
|
2394 | _lock: 0,
|
2395 | _hasPause: 0,
|
2396 | _forcing: 0
|
2397 | });
|
2398 |
|
2399 | var _addComplexStringPropTween = function _addComplexStringPropTween(target, prop, start, end, setter, stringFilter, funcParam) {
|
2400 | var pt = new PropTween(this._pt, target, prop, 0, 1, _renderComplexString, null, setter),
|
2401 | index = 0,
|
2402 | matchIndex = 0,
|
2403 | result,
|
2404 | startNums,
|
2405 | color,
|
2406 | endNum,
|
2407 | chunk,
|
2408 | startNum,
|
2409 | hasRandom,
|
2410 | a;
|
2411 | pt.b = start;
|
2412 | pt.e = end;
|
2413 | start += "";
|
2414 | end += "";
|
2415 |
|
2416 | if (hasRandom = ~end.indexOf("random(")) {
|
2417 | end = _replaceRandom(end);
|
2418 | }
|
2419 |
|
2420 | if (stringFilter) {
|
2421 | a = [start, end];
|
2422 | stringFilter(a, target, prop);
|
2423 | start = a[0];
|
2424 | end = a[1];
|
2425 | }
|
2426 |
|
2427 | startNums = start.match(_complexStringNumExp) || [];
|
2428 |
|
2429 | while (result = _complexStringNumExp.exec(end)) {
|
2430 | endNum = result[0];
|
2431 | chunk = end.substring(index, result.index);
|
2432 |
|
2433 | if (color) {
|
2434 | color = (color + 1) % 5;
|
2435 | } else if (chunk.substr(-5) === "rgba(") {
|
2436 | color = 1;
|
2437 | }
|
2438 |
|
2439 | if (endNum !== startNums[matchIndex++]) {
|
2440 | startNum = parseFloat(startNums[matchIndex - 1]) || 0;
|
2441 | pt._pt = {
|
2442 | _next: pt._pt,
|
2443 | p: chunk || matchIndex === 1 ? chunk : ",",
|
2444 | s: startNum,
|
2445 | c: endNum.charAt(1) === "=" ? parseFloat(endNum.substr(2)) * (endNum.charAt(0) === "-" ? -1 : 1) : parseFloat(endNum) - startNum,
|
2446 | m: color && color < 4 ? Math.round : 0
|
2447 | };
|
2448 | index = _complexStringNumExp.lastIndex;
|
2449 | }
|
2450 | }
|
2451 |
|
2452 | pt.c = index < end.length ? end.substring(index, end.length) : "";
|
2453 | pt.fp = funcParam;
|
2454 |
|
2455 | if (_relExp.test(end) || hasRandom) {
|
2456 | pt.e = 0;
|
2457 | }
|
2458 |
|
2459 | this._pt = pt;
|
2460 | return pt;
|
2461 | },
|
2462 | _addPropTween = function _addPropTween(target, prop, start, end, index, targets, modifier, stringFilter, funcParam) {
|
2463 | _isFunction(end) && (end = end(index || 0, target, targets));
|
2464 | var currentValue = target[prop],
|
2465 | parsedStart = start !== "get" ? start : !_isFunction(currentValue) ? currentValue : funcParam ? target[prop.indexOf("set") || !_isFunction(target["get" + prop.substr(3)]) ? prop : "get" + prop.substr(3)](funcParam) : target[prop](),
|
2466 | setter = !_isFunction(currentValue) ? _setterPlain : funcParam ? _setterFuncWithParam : _setterFunc,
|
2467 | pt;
|
2468 |
|
2469 | if (_isString(end)) {
|
2470 | if (~end.indexOf("random(")) {
|
2471 | end = _replaceRandom(end);
|
2472 | }
|
2473 |
|
2474 | if (end.charAt(1) === "=") {
|
2475 | end = parseFloat(parsedStart) + parseFloat(end.substr(2)) * (end.charAt(0) === "-" ? -1 : 1) + (getUnit(parsedStart) || 0);
|
2476 | }
|
2477 | }
|
2478 |
|
2479 | if (parsedStart !== end) {
|
2480 | if (!isNaN(parsedStart * end)) {
|
2481 | pt = new PropTween(this._pt, target, prop, +parsedStart || 0, end - (parsedStart || 0), typeof currentValue === "boolean" ? _renderBoolean : _renderPlain, 0, setter);
|
2482 | funcParam && (pt.fp = funcParam);
|
2483 | modifier && pt.modifier(modifier, this, target);
|
2484 | return this._pt = pt;
|
2485 | }
|
2486 |
|
2487 | !currentValue && !(prop in target) && _missingPlugin(prop, end);
|
2488 | return _addComplexStringPropTween.call(this, target, prop, parsedStart, end, setter, stringFilter || _config.stringFilter, funcParam);
|
2489 | }
|
2490 | },
|
2491 | _processVars = function _processVars(vars, index, target, targets, tween) {
|
2492 | _isFunction(vars) && (vars = _parseFuncOrString(vars, tween, index, target, targets));
|
2493 |
|
2494 | if (!_isObject(vars) || vars.style && vars.nodeType || _isArray(vars) || _isTypedArray(vars)) {
|
2495 | return _isString(vars) ? _parseFuncOrString(vars, tween, index, target, targets) : vars;
|
2496 | }
|
2497 |
|
2498 | var copy = {},
|
2499 | p;
|
2500 |
|
2501 | for (p in vars) {
|
2502 | copy[p] = _parseFuncOrString(vars[p], tween, index, target, targets);
|
2503 | }
|
2504 |
|
2505 | return copy;
|
2506 | },
|
2507 | _checkPlugin = function _checkPlugin(property, vars, tween, index, target, targets) {
|
2508 | var plugin, pt, ptLookup, i;
|
2509 |
|
2510 | if (_plugins[property] && (plugin = new _plugins[property]()).init(target, plugin.rawVars ? vars[property] : _processVars(vars[property], index, target, targets, tween), tween, index, targets) !== false) {
|
2511 | tween._pt = pt = new PropTween(tween._pt, target, property, 0, 1, plugin.render, plugin, 0, plugin.priority);
|
2512 |
|
2513 | if (tween !== _quickTween) {
|
2514 | ptLookup = tween._ptLookup[tween._targets.indexOf(target)];
|
2515 | i = plugin._props.length;
|
2516 |
|
2517 | while (i--) {
|
2518 | ptLookup[plugin._props[i]] = pt;
|
2519 | }
|
2520 | }
|
2521 | }
|
2522 |
|
2523 | return plugin;
|
2524 | },
|
2525 | _overwritingTween,
|
2526 | _initTween = function _initTween(tween, time) {
|
2527 | var vars = tween.vars,
|
2528 | ease = vars.ease,
|
2529 | startAt = vars.startAt,
|
2530 | immediateRender = vars.immediateRender,
|
2531 | lazy = vars.lazy,
|
2532 | onUpdate = vars.onUpdate,
|
2533 | onUpdateParams = vars.onUpdateParams,
|
2534 | callbackScope = vars.callbackScope,
|
2535 | runBackwards = vars.runBackwards,
|
2536 | yoyoEase = vars.yoyoEase,
|
2537 | keyframes = vars.keyframes,
|
2538 | autoRevert = vars.autoRevert,
|
2539 | dur = tween._dur,
|
2540 | prevStartAt = tween._startAt,
|
2541 | targets = tween._targets,
|
2542 | parent = tween.parent,
|
2543 | fullTargets = parent && parent.data === "nested" ? parent.parent._targets : targets,
|
2544 | autoOverwrite = tween._overwrite === "auto",
|
2545 | tl = tween.timeline,
|
2546 | cleanVars,
|
2547 | i,
|
2548 | p,
|
2549 | pt,
|
2550 | target,
|
2551 | hasPriority,
|
2552 | gsData,
|
2553 | harness,
|
2554 | plugin,
|
2555 | ptLookup,
|
2556 | index,
|
2557 | harnessVars,
|
2558 | overwritten;
|
2559 | tl && (!keyframes || !ease) && (ease = "none");
|
2560 | tween._ease = _parseEase(ease, _defaults.ease);
|
2561 | tween._yEase = yoyoEase ? _invertEase(_parseEase(yoyoEase === true ? ease : yoyoEase, _defaults.ease)) : 0;
|
2562 |
|
2563 | if (yoyoEase && tween._yoyo && !tween._repeat) {
|
2564 | yoyoEase = tween._yEase;
|
2565 | tween._yEase = tween._ease;
|
2566 | tween._ease = yoyoEase;
|
2567 | }
|
2568 |
|
2569 | if (!tl) {
|
2570 | harness = targets[0] ? _getCache(targets[0]).harness : 0;
|
2571 | harnessVars = harness && vars[harness.prop];
|
2572 | cleanVars = _copyExcluding(vars, _reservedProps);
|
2573 | prevStartAt && prevStartAt.render(-1, true).kill();
|
2574 |
|
2575 | if (startAt) {
|
2576 | _removeFromParent(tween._startAt = Tween.set(targets, _setDefaults({
|
2577 | data: "isStart",
|
2578 | overwrite: false,
|
2579 | parent: parent,
|
2580 | immediateRender: true,
|
2581 | lazy: _isNotFalse(lazy),
|
2582 | startAt: null,
|
2583 | delay: 0,
|
2584 | onUpdate: onUpdate,
|
2585 | onUpdateParams: onUpdateParams,
|
2586 | callbackScope: callbackScope,
|
2587 | stagger: 0
|
2588 | }, startAt)));
|
2589 |
|
2590 | if (immediateRender) {
|
2591 | if (time > 0) {
|
2592 | autoRevert || (tween._startAt = 0);
|
2593 | } else if (dur && !(time < 0 && prevStartAt)) {
|
2594 | time && (tween._zTime = time);
|
2595 | return;
|
2596 | }
|
2597 | }
|
2598 | } else if (runBackwards && dur) {
|
2599 | if (prevStartAt) {
|
2600 | !autoRevert && (tween._startAt = 0);
|
2601 | } else {
|
2602 | time && (immediateRender = false);
|
2603 | p = _setDefaults({
|
2604 | overwrite: false,
|
2605 | data: "isFromStart",
|
2606 | lazy: immediateRender && _isNotFalse(lazy),
|
2607 | immediateRender: immediateRender,
|
2608 | stagger: 0,
|
2609 | parent: parent
|
2610 | }, cleanVars);
|
2611 | harnessVars && (p[harness.prop] = harnessVars);
|
2612 |
|
2613 | _removeFromParent(tween._startAt = Tween.set(targets, p));
|
2614 |
|
2615 | if (!immediateRender) {
|
2616 | _initTween(tween._startAt, _tinyNum);
|
2617 | } else if (!time) {
|
2618 | return;
|
2619 | }
|
2620 | }
|
2621 | }
|
2622 |
|
2623 | tween._pt = 0;
|
2624 | lazy = dur && _isNotFalse(lazy) || lazy && !dur;
|
2625 |
|
2626 | for (i = 0; i < targets.length; i++) {
|
2627 | target = targets[i];
|
2628 | gsData = target._gsap || _harness(targets)[i]._gsap;
|
2629 | tween._ptLookup[i] = ptLookup = {};
|
2630 | _lazyLookup[gsData.id] && _lazyTweens.length && _lazyRender();
|
2631 | index = fullTargets === targets ? i : fullTargets.indexOf(target);
|
2632 |
|
2633 | if (harness && (plugin = new harness()).init(target, harnessVars || cleanVars, tween, index, fullTargets) !== false) {
|
2634 | tween._pt = pt = new PropTween(tween._pt, target, plugin.name, 0, 1, plugin.render, plugin, 0, plugin.priority);
|
2635 |
|
2636 | plugin._props.forEach(function (name) {
|
2637 | ptLookup[name] = pt;
|
2638 | });
|
2639 |
|
2640 | plugin.priority && (hasPriority = 1);
|
2641 | }
|
2642 |
|
2643 | if (!harness || harnessVars) {
|
2644 | for (p in cleanVars) {
|
2645 | if (_plugins[p] && (plugin = _checkPlugin(p, cleanVars, tween, index, target, fullTargets))) {
|
2646 | plugin.priority && (hasPriority = 1);
|
2647 | } else {
|
2648 | ptLookup[p] = pt = _addPropTween.call(tween, target, p, "get", cleanVars[p], index, fullTargets, 0, vars.stringFilter);
|
2649 | }
|
2650 | }
|
2651 | }
|
2652 |
|
2653 | tween._op && tween._op[i] && tween.kill(target, tween._op[i]);
|
2654 |
|
2655 | if (autoOverwrite && tween._pt) {
|
2656 | _overwritingTween = tween;
|
2657 |
|
2658 | _globalTimeline.killTweensOf(target, ptLookup, tween.globalTime(0));
|
2659 |
|
2660 | overwritten = !tween.parent;
|
2661 | _overwritingTween = 0;
|
2662 | }
|
2663 |
|
2664 | tween._pt && lazy && (_lazyLookup[gsData.id] = 1);
|
2665 | }
|
2666 |
|
2667 | hasPriority && _sortPropTweensByPriority(tween);
|
2668 | tween._onInit && tween._onInit(tween);
|
2669 | }
|
2670 |
|
2671 | tween._from = !tl && !!vars.runBackwards;
|
2672 | tween._onUpdate = onUpdate;
|
2673 | tween._initted = (!tween._op || tween._pt) && !overwritten;
|
2674 | },
|
2675 | _addAliasesToVars = function _addAliasesToVars(targets, vars) {
|
2676 | var harness = targets[0] ? _getCache(targets[0]).harness : 0,
|
2677 | propertyAliases = harness && harness.aliases,
|
2678 | copy,
|
2679 | p,
|
2680 | i,
|
2681 | aliases;
|
2682 |
|
2683 | if (!propertyAliases) {
|
2684 | return vars;
|
2685 | }
|
2686 |
|
2687 | copy = _merge({}, vars);
|
2688 |
|
2689 | for (p in propertyAliases) {
|
2690 | if (p in copy) {
|
2691 | aliases = propertyAliases[p].split(",");
|
2692 | i = aliases.length;
|
2693 |
|
2694 | while (i--) {
|
2695 | copy[aliases[i]] = copy[p];
|
2696 | }
|
2697 | }
|
2698 | }
|
2699 |
|
2700 | return copy;
|
2701 | },
|
2702 | _parseFuncOrString = function _parseFuncOrString(value, tween, i, target, targets) {
|
2703 | return _isFunction(value) ? value.call(tween, i, target, targets) : _isString(value) && ~value.indexOf("random(") ? _replaceRandom(value) : value;
|
2704 | },
|
2705 | _staggerTweenProps = _callbackNames + "repeat,repeatDelay,yoyo,repeatRefresh,yoyoEase",
|
2706 | _staggerPropsToSkip = (_staggerTweenProps + ",id,stagger,delay,duration,paused,scrollTrigger").split(",");
|
2707 |
|
2708 | var Tween = function (_Animation2) {
|
2709 | _inheritsLoose(Tween, _Animation2);
|
2710 |
|
2711 | function Tween(targets, vars, time, skipInherit) {
|
2712 | var _this3;
|
2713 |
|
2714 | if (typeof vars === "number") {
|
2715 | time.duration = vars;
|
2716 | vars = time;
|
2717 | time = null;
|
2718 | }
|
2719 |
|
2720 | _this3 = _Animation2.call(this, skipInherit ? vars : _inheritDefaults(vars), time) || this;
|
2721 | var _this3$vars = _this3.vars,
|
2722 | duration = _this3$vars.duration,
|
2723 | delay = _this3$vars.delay,
|
2724 | immediateRender = _this3$vars.immediateRender,
|
2725 | stagger = _this3$vars.stagger,
|
2726 | overwrite = _this3$vars.overwrite,
|
2727 | keyframes = _this3$vars.keyframes,
|
2728 | defaults = _this3$vars.defaults,
|
2729 | scrollTrigger = _this3$vars.scrollTrigger,
|
2730 | yoyoEase = _this3$vars.yoyoEase,
|
2731 | parent = _this3.parent,
|
2732 | parsedTargets = (_isArray(targets) || _isTypedArray(targets) ? _isNumber(targets[0]) : "length" in vars) ? [targets] : toArray(targets),
|
2733 | tl,
|
2734 | i,
|
2735 | copy,
|
2736 | l,
|
2737 | p,
|
2738 | curTarget,
|
2739 | staggerFunc,
|
2740 | staggerVarsToMerge;
|
2741 | _this3._targets = parsedTargets.length ? _harness(parsedTargets) : _warn("GSAP target " + targets + " not found. https://greensock.com", !_config.nullTargetWarn) || [];
|
2742 | _this3._ptLookup = [];
|
2743 | _this3._overwrite = overwrite;
|
2744 |
|
2745 | if (keyframes || stagger || _isFuncOrString(duration) || _isFuncOrString(delay)) {
|
2746 | vars = _this3.vars;
|
2747 | tl = _this3.timeline = new Timeline({
|
2748 | data: "nested",
|
2749 | defaults: defaults || {}
|
2750 | });
|
2751 | tl.kill();
|
2752 | tl.parent = _assertThisInitialized(_this3);
|
2753 |
|
2754 | if (keyframes) {
|
2755 | _setDefaults(tl.vars.defaults, {
|
2756 | ease: "none"
|
2757 | });
|
2758 |
|
2759 | keyframes.forEach(function (frame) {
|
2760 | return tl.to(parsedTargets, frame, ">");
|
2761 | });
|
2762 | } else {
|
2763 | l = parsedTargets.length;
|
2764 | staggerFunc = stagger ? distribute(stagger) : _emptyFunc;
|
2765 |
|
2766 | if (_isObject(stagger)) {
|
2767 | for (p in stagger) {
|
2768 | if (~_staggerTweenProps.indexOf(p)) {
|
2769 | staggerVarsToMerge || (staggerVarsToMerge = {});
|
2770 | staggerVarsToMerge[p] = stagger[p];
|
2771 | }
|
2772 | }
|
2773 | }
|
2774 |
|
2775 | for (i = 0; i < l; i++) {
|
2776 | copy = {};
|
2777 |
|
2778 | for (p in vars) {
|
2779 | if (_staggerPropsToSkip.indexOf(p) < 0) {
|
2780 | copy[p] = vars[p];
|
2781 | }
|
2782 | }
|
2783 |
|
2784 | copy.stagger = 0;
|
2785 | yoyoEase && (copy.yoyoEase = yoyoEase);
|
2786 | staggerVarsToMerge && _merge(copy, staggerVarsToMerge);
|
2787 | curTarget = parsedTargets[i];
|
2788 | copy.duration = +_parseFuncOrString(duration, _assertThisInitialized(_this3), i, curTarget, parsedTargets);
|
2789 | copy.delay = (+_parseFuncOrString(delay, _assertThisInitialized(_this3), i, curTarget, parsedTargets) || 0) - _this3._delay;
|
2790 |
|
2791 | if (!stagger && l === 1 && copy.delay) {
|
2792 | _this3._delay = delay = copy.delay;
|
2793 | _this3._start += delay;
|
2794 | copy.delay = 0;
|
2795 | }
|
2796 |
|
2797 | tl.to(curTarget, copy, staggerFunc(i, curTarget, parsedTargets));
|
2798 | }
|
2799 |
|
2800 | tl.duration() ? duration = delay = 0 : _this3.timeline = 0;
|
2801 | }
|
2802 |
|
2803 | duration || _this3.duration(duration = tl.duration());
|
2804 | } else {
|
2805 | _this3.timeline = 0;
|
2806 | }
|
2807 |
|
2808 | if (overwrite === true) {
|
2809 | _overwritingTween = _assertThisInitialized(_this3);
|
2810 |
|
2811 | _globalTimeline.killTweensOf(parsedTargets);
|
2812 |
|
2813 | _overwritingTween = 0;
|
2814 | }
|
2815 |
|
2816 | parent && _postAddChecks(parent, _assertThisInitialized(_this3));
|
2817 |
|
2818 | if (immediateRender || !duration && !keyframes && _this3._start === _round(parent._time) && _isNotFalse(immediateRender) && _hasNoPausedAncestors(_assertThisInitialized(_this3)) && parent.data !== "nested") {
|
2819 | _this3._tTime = -_tinyNum;
|
2820 |
|
2821 | _this3.render(Math.max(0, -delay));
|
2822 | }
|
2823 |
|
2824 | scrollTrigger && _scrollTrigger(_assertThisInitialized(_this3), scrollTrigger);
|
2825 | return _this3;
|
2826 | }
|
2827 |
|
2828 | var _proto3 = Tween.prototype;
|
2829 |
|
2830 | _proto3.render = function render(totalTime, suppressEvents, force) {
|
2831 | var prevTime = this._time,
|
2832 | tDur = this._tDur,
|
2833 | dur = this._dur,
|
2834 | tTime = totalTime > tDur - _tinyNum && totalTime >= 0 ? tDur : totalTime < _tinyNum ? 0 : totalTime,
|
2835 | time,
|
2836 | pt,
|
2837 | iteration,
|
2838 | cycleDuration,
|
2839 | prevIteration,
|
2840 | isYoyo,
|
2841 | ratio,
|
2842 | timeline,
|
2843 | yoyoEase;
|
2844 |
|
2845 | if (!dur) {
|
2846 | _renderZeroDurationTween(this, totalTime, suppressEvents, force);
|
2847 | } else if (tTime !== this._tTime || !totalTime || force || this._startAt && this._zTime < 0 !== totalTime < 0) {
|
2848 | time = tTime;
|
2849 | timeline = this.timeline;
|
2850 |
|
2851 | if (this._repeat) {
|
2852 | cycleDuration = dur + this._rDelay;
|
2853 | time = _round(tTime % cycleDuration);
|
2854 |
|
2855 | if (tTime === tDur) {
|
2856 | iteration = this._repeat;
|
2857 | time = dur;
|
2858 | } else {
|
2859 | iteration = ~~(tTime / cycleDuration);
|
2860 |
|
2861 | if (iteration && iteration === tTime / cycleDuration) {
|
2862 | time = dur;
|
2863 | iteration--;
|
2864 | }
|
2865 |
|
2866 | time > dur && (time = dur);
|
2867 | }
|
2868 |
|
2869 | isYoyo = this._yoyo && iteration & 1;
|
2870 |
|
2871 | if (isYoyo) {
|
2872 | yoyoEase = this._yEase;
|
2873 | time = dur - time;
|
2874 | }
|
2875 |
|
2876 | prevIteration = _animationCycle(this._tTime, cycleDuration);
|
2877 |
|
2878 | if (time === prevTime && !force && this._initted) {
|
2879 | return this;
|
2880 | }
|
2881 |
|
2882 | if (iteration !== prevIteration) {
|
2883 | timeline && this._yEase && _propagateYoyoEase(timeline, isYoyo);
|
2884 |
|
2885 | if (this.vars.repeatRefresh && !isYoyo && !this._lock) {
|
2886 | this._lock = force = 1;
|
2887 | this.render(_round(cycleDuration * iteration), true).invalidate()._lock = 0;
|
2888 | }
|
2889 | }
|
2890 | }
|
2891 |
|
2892 | if (!this._initted) {
|
2893 | if (_attemptInitTween(this, totalTime < 0 ? totalTime : time, force, suppressEvents)) {
|
2894 | this._tTime = 0;
|
2895 | return this;
|
2896 | }
|
2897 |
|
2898 | if (dur !== this._dur) {
|
2899 | return this.render(totalTime, suppressEvents, force);
|
2900 | }
|
2901 | }
|
2902 |
|
2903 | this._tTime = tTime;
|
2904 | this._time = time;
|
2905 |
|
2906 | if (!this._act && this._ts) {
|
2907 | this._act = 1;
|
2908 | this._lazy = 0;
|
2909 | }
|
2910 |
|
2911 | this.ratio = ratio = (yoyoEase || this._ease)(time / dur);
|
2912 |
|
2913 | if (this._from) {
|
2914 | this.ratio = ratio = 1 - ratio;
|
2915 | }
|
2916 |
|
2917 | time && !prevTime && !suppressEvents && _callback(this, "onStart");
|
2918 | pt = this._pt;
|
2919 |
|
2920 | while (pt) {
|
2921 | pt.r(ratio, pt.d);
|
2922 | pt = pt._next;
|
2923 | }
|
2924 |
|
2925 | timeline && timeline.render(totalTime < 0 ? totalTime : !time && isYoyo ? -_tinyNum : timeline._dur * ratio, suppressEvents, force) || this._startAt && (this._zTime = totalTime);
|
2926 |
|
2927 | if (this._onUpdate && !suppressEvents) {
|
2928 | totalTime < 0 && this._startAt && this._startAt.render(totalTime, true, force);
|
2929 |
|
2930 | _callback(this, "onUpdate");
|
2931 | }
|
2932 |
|
2933 | this._repeat && iteration !== prevIteration && this.vars.onRepeat && !suppressEvents && this.parent && _callback(this, "onRepeat");
|
2934 |
|
2935 | if ((tTime === this._tDur || !tTime) && this._tTime === tTime) {
|
2936 | totalTime < 0 && this._startAt && !this._onUpdate && this._startAt.render(totalTime, true, true);
|
2937 | (totalTime || !dur) && (tTime === this._tDur && this._ts > 0 || !tTime && this._ts < 0) && _removeFromParent(this, 1);
|
2938 |
|
2939 | if (!suppressEvents && !(totalTime < 0 && !prevTime) && (tTime || prevTime)) {
|
2940 | _callback(this, tTime === tDur ? "onComplete" : "onReverseComplete", true);
|
2941 |
|
2942 | this._prom && !(tTime < tDur && this.timeScale() > 0) && this._prom();
|
2943 | }
|
2944 | }
|
2945 | }
|
2946 |
|
2947 | return this;
|
2948 | };
|
2949 |
|
2950 | _proto3.targets = function targets() {
|
2951 | return this._targets;
|
2952 | };
|
2953 |
|
2954 | _proto3.invalidate = function invalidate() {
|
2955 | this._pt = this._op = this._startAt = this._onUpdate = this._act = this._lazy = 0;
|
2956 | this._ptLookup = [];
|
2957 | this.timeline && this.timeline.invalidate();
|
2958 | return _Animation2.prototype.invalidate.call(this);
|
2959 | };
|
2960 |
|
2961 | _proto3.kill = function kill(targets, vars) {
|
2962 | if (vars === void 0) {
|
2963 | vars = "all";
|
2964 | }
|
2965 |
|
2966 | if (!targets && (!vars || vars === "all")) {
|
2967 | this._lazy = 0;
|
2968 |
|
2969 | if (this.parent) {
|
2970 | return _interrupt(this);
|
2971 | }
|
2972 | }
|
2973 |
|
2974 | if (this.timeline) {
|
2975 | var tDur = this.timeline.totalDuration();
|
2976 | this.timeline.killTweensOf(targets, vars, _overwritingTween && _overwritingTween.vars.overwrite !== true)._first || _interrupt(this);
|
2977 | this.parent && tDur !== this.timeline.totalDuration() && _setDuration(this, this._dur * this.timeline._tDur / tDur, 0, 1);
|
2978 | return this;
|
2979 | }
|
2980 |
|
2981 | var parsedTargets = this._targets,
|
2982 | killingTargets = targets ? toArray(targets) : parsedTargets,
|
2983 | propTweenLookup = this._ptLookup,
|
2984 | firstPT = this._pt,
|
2985 | overwrittenProps,
|
2986 | curLookup,
|
2987 | curOverwriteProps,
|
2988 | props,
|
2989 | p,
|
2990 | pt,
|
2991 | i;
|
2992 |
|
2993 | if ((!vars || vars === "all") && _arraysMatch(parsedTargets, killingTargets)) {
|
2994 | vars === "all" && (this._pt = 0);
|
2995 | return _interrupt(this);
|
2996 | }
|
2997 |
|
2998 | overwrittenProps = this._op = this._op || [];
|
2999 |
|
3000 | if (vars !== "all") {
|
3001 | if (_isString(vars)) {
|
3002 | p = {};
|
3003 |
|
3004 | _forEachName(vars, function (name) {
|
3005 | return p[name] = 1;
|
3006 | });
|
3007 |
|
3008 | vars = p;
|
3009 | }
|
3010 |
|
3011 | vars = _addAliasesToVars(parsedTargets, vars);
|
3012 | }
|
3013 |
|
3014 | i = parsedTargets.length;
|
3015 |
|
3016 | while (i--) {
|
3017 | if (~killingTargets.indexOf(parsedTargets[i])) {
|
3018 | curLookup = propTweenLookup[i];
|
3019 |
|
3020 | if (vars === "all") {
|
3021 | overwrittenProps[i] = vars;
|
3022 | props = curLookup;
|
3023 | curOverwriteProps = {};
|
3024 | } else {
|
3025 | curOverwriteProps = overwrittenProps[i] = overwrittenProps[i] || {};
|
3026 | props = vars;
|
3027 | }
|
3028 |
|
3029 | for (p in props) {
|
3030 | pt = curLookup && curLookup[p];
|
3031 |
|
3032 | if (pt) {
|
3033 | if (!("kill" in pt.d) || pt.d.kill(p) === true) {
|
3034 | _removeLinkedListItem(this, pt, "_pt");
|
3035 | }
|
3036 |
|
3037 | delete curLookup[p];
|
3038 | }
|
3039 |
|
3040 | if (curOverwriteProps !== "all") {
|
3041 | curOverwriteProps[p] = 1;
|
3042 | }
|
3043 | }
|
3044 | }
|
3045 | }
|
3046 |
|
3047 | this._initted && !this._pt && firstPT && _interrupt(this);
|
3048 | return this;
|
3049 | };
|
3050 |
|
3051 | Tween.to = function to(targets, vars) {
|
3052 | return new Tween(targets, vars, arguments[2]);
|
3053 | };
|
3054 |
|
3055 | Tween.from = function from(targets, vars) {
|
3056 | return new Tween(targets, _parseVars(arguments, 1));
|
3057 | };
|
3058 |
|
3059 | Tween.delayedCall = function delayedCall(delay, callback, params, scope) {
|
3060 | return new Tween(callback, 0, {
|
3061 | immediateRender: false,
|
3062 | lazy: false,
|
3063 | overwrite: false,
|
3064 | delay: delay,
|
3065 | onComplete: callback,
|
3066 | onReverseComplete: callback,
|
3067 | onCompleteParams: params,
|
3068 | onReverseCompleteParams: params,
|
3069 | callbackScope: scope
|
3070 | });
|
3071 | };
|
3072 |
|
3073 | Tween.fromTo = function fromTo(targets, fromVars, toVars) {
|
3074 | return new Tween(targets, _parseVars(arguments, 2));
|
3075 | };
|
3076 |
|
3077 | Tween.set = function set(targets, vars) {
|
3078 | vars.duration = 0;
|
3079 | vars.repeatDelay || (vars.repeat = 0);
|
3080 | return new Tween(targets, vars);
|
3081 | };
|
3082 |
|
3083 | Tween.killTweensOf = function killTweensOf(targets, props, onlyActive) {
|
3084 | return _globalTimeline.killTweensOf(targets, props, onlyActive);
|
3085 | };
|
3086 |
|
3087 | return Tween;
|
3088 | }(Animation);
|
3089 |
|
3090 | _setDefaults(Tween.prototype, {
|
3091 | _targets: [],
|
3092 | _lazy: 0,
|
3093 | _startAt: 0,
|
3094 | _op: 0,
|
3095 | _onInit: 0
|
3096 | });
|
3097 |
|
3098 | _forEachName("staggerTo,staggerFrom,staggerFromTo", function (name) {
|
3099 | Tween[name] = function () {
|
3100 | var tl = new Timeline(),
|
3101 | params = _slice.call(arguments, 0);
|
3102 |
|
3103 | params.splice(name === "staggerFromTo" ? 5 : 4, 0, 0);
|
3104 | return tl[name].apply(tl, params);
|
3105 | };
|
3106 | });
|
3107 |
|
3108 | var _setterPlain = function _setterPlain(target, property, value) {
|
3109 | return target[property] = value;
|
3110 | },
|
3111 | _setterFunc = function _setterFunc(target, property, value) {
|
3112 | return target[property](value);
|
3113 | },
|
3114 | _setterFuncWithParam = function _setterFuncWithParam(target, property, value, data) {
|
3115 | return target[property](data.fp, value);
|
3116 | },
|
3117 | _setterAttribute = function _setterAttribute(target, property, value) {
|
3118 | return target.setAttribute(property, value);
|
3119 | },
|
3120 | _getSetter = function _getSetter(target, property) {
|
3121 | return _isFunction(target[property]) ? _setterFunc : _isUndefined(target[property]) && target.setAttribute ? _setterAttribute : _setterPlain;
|
3122 | },
|
3123 | _renderPlain = function _renderPlain(ratio, data) {
|
3124 | return data.set(data.t, data.p, Math.round((data.s + data.c * ratio) * 10000) / 10000, data);
|
3125 | },
|
3126 | _renderBoolean = function _renderBoolean(ratio, data) {
|
3127 | return data.set(data.t, data.p, !!(data.s + data.c * ratio), data);
|
3128 | },
|
3129 | _renderComplexString = function _renderComplexString(ratio, data) {
|
3130 | var pt = data._pt,
|
3131 | s = "";
|
3132 |
|
3133 | if (!ratio && data.b) {
|
3134 | s = data.b;
|
3135 | } else if (ratio === 1 && data.e) {
|
3136 | s = data.e;
|
3137 | } else {
|
3138 | while (pt) {
|
3139 | s = pt.p + (pt.m ? pt.m(pt.s + pt.c * ratio) : Math.round((pt.s + pt.c * ratio) * 10000) / 10000) + s;
|
3140 | pt = pt._next;
|
3141 | }
|
3142 |
|
3143 | s += data.c;
|
3144 | }
|
3145 |
|
3146 | data.set(data.t, data.p, s, data);
|
3147 | },
|
3148 | _renderPropTweens = function _renderPropTweens(ratio, data) {
|
3149 | var pt = data._pt;
|
3150 |
|
3151 | while (pt) {
|
3152 | pt.r(ratio, pt.d);
|
3153 | pt = pt._next;
|
3154 | }
|
3155 | },
|
3156 | _addPluginModifier = function _addPluginModifier(modifier, tween, target, property) {
|
3157 | var pt = this._pt,
|
3158 | next;
|
3159 |
|
3160 | while (pt) {
|
3161 | next = pt._next;
|
3162 | pt.p === property && pt.modifier(modifier, tween, target);
|
3163 | pt = next;
|
3164 | }
|
3165 | },
|
3166 | _killPropTweensOf = function _killPropTweensOf(property) {
|
3167 | var pt = this._pt,
|
3168 | hasNonDependentRemaining,
|
3169 | next;
|
3170 |
|
3171 | while (pt) {
|
3172 | next = pt._next;
|
3173 |
|
3174 | if (pt.p === property && !pt.op || pt.op === property) {
|
3175 | _removeLinkedListItem(this, pt, "_pt");
|
3176 | } else if (!pt.dep) {
|
3177 | hasNonDependentRemaining = 1;
|
3178 | }
|
3179 |
|
3180 | pt = next;
|
3181 | }
|
3182 |
|
3183 | return !hasNonDependentRemaining;
|
3184 | },
|
3185 | _setterWithModifier = function _setterWithModifier(target, property, value, data) {
|
3186 | data.mSet(target, property, data.m.call(data.tween, value, data.mt), data);
|
3187 | },
|
3188 | _sortPropTweensByPriority = function _sortPropTweensByPriority(parent) {
|
3189 | var pt = parent._pt,
|
3190 | next,
|
3191 | pt2,
|
3192 | first,
|
3193 | last;
|
3194 |
|
3195 | while (pt) {
|
3196 | next = pt._next;
|
3197 | pt2 = first;
|
3198 |
|
3199 | while (pt2 && pt2.pr > pt.pr) {
|
3200 | pt2 = pt2._next;
|
3201 | }
|
3202 |
|
3203 | if (pt._prev = pt2 ? pt2._prev : last) {
|
3204 | pt._prev._next = pt;
|
3205 | } else {
|
3206 | first = pt;
|
3207 | }
|
3208 |
|
3209 | if (pt._next = pt2) {
|
3210 | pt2._prev = pt;
|
3211 | } else {
|
3212 | last = pt;
|
3213 | }
|
3214 |
|
3215 | pt = next;
|
3216 | }
|
3217 |
|
3218 | parent._pt = first;
|
3219 | };
|
3220 |
|
3221 | var PropTween = function () {
|
3222 | function PropTween(next, target, prop, start, change, renderer, data, setter, priority) {
|
3223 | this.t = target;
|
3224 | this.s = start;
|
3225 | this.c = change;
|
3226 | this.p = prop;
|
3227 | this.r = renderer || _renderPlain;
|
3228 | this.d = data || this;
|
3229 | this.set = setter || _setterPlain;
|
3230 | this.pr = priority || 0;
|
3231 | this._next = next;
|
3232 |
|
3233 | if (next) {
|
3234 | next._prev = this;
|
3235 | }
|
3236 | }
|
3237 |
|
3238 | var _proto4 = PropTween.prototype;
|
3239 |
|
3240 | _proto4.modifier = function modifier(func, tween, target) {
|
3241 | this.mSet = this.mSet || this.set;
|
3242 | this.set = _setterWithModifier;
|
3243 | this.m = func;
|
3244 | this.mt = target;
|
3245 | this.tween = tween;
|
3246 | };
|
3247 |
|
3248 | return PropTween;
|
3249 | }();
|
3250 |
|
3251 | _forEachName(_callbackNames + "parent,duration,ease,delay,overwrite,runBackwards,startAt,yoyo,immediateRender,repeat,repeatDelay,data,paused,reversed,lazy,callbackScope,stringFilter,id,yoyoEase,stagger,inherit,repeatRefresh,keyframes,autoRevert,scrollTrigger", function (name) {
|
3252 | return _reservedProps[name] = 1;
|
3253 | });
|
3254 |
|
3255 | _globals.TweenMax = _globals.TweenLite = Tween;
|
3256 | _globals.TimelineLite = _globals.TimelineMax = Timeline;
|
3257 | _globalTimeline = new Timeline({
|
3258 | sortChildren: false,
|
3259 | defaults: _defaults,
|
3260 | autoRemoveChildren: true,
|
3261 | id: "root",
|
3262 | smoothChildTiming: true
|
3263 | });
|
3264 | _config.stringFilter = _colorStringFilter;
|
3265 | var _gsap = {
|
3266 | registerPlugin: function registerPlugin() {
|
3267 | for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
3268 | args[_key2] = arguments[_key2];
|
3269 | }
|
3270 |
|
3271 | args.forEach(function (config) {
|
3272 | return _createPlugin(config);
|
3273 | });
|
3274 | },
|
3275 | timeline: function timeline(vars) {
|
3276 | return new Timeline(vars);
|
3277 | },
|
3278 | getTweensOf: function getTweensOf(targets, onlyActive) {
|
3279 | return _globalTimeline.getTweensOf(targets, onlyActive);
|
3280 | },
|
3281 | getProperty: function getProperty(target, property, unit, uncache) {
|
3282 | _isString(target) && (target = toArray(target)[0]);
|
3283 |
|
3284 | var getter = _getCache(target || {}).get,
|
3285 | format = unit ? _passThrough : _numericIfPossible;
|
3286 |
|
3287 | unit === "native" && (unit = "");
|
3288 | return !target ? target : !property ? function (property, unit, uncache) {
|
3289 | return format((_plugins[property] && _plugins[property].get || getter)(target, property, unit, uncache));
|
3290 | } : format((_plugins[property] && _plugins[property].get || getter)(target, property, unit, uncache));
|
3291 | },
|
3292 | quickSetter: function quickSetter(target, property, unit) {
|
3293 | target = toArray(target);
|
3294 |
|
3295 | if (target.length > 1) {
|
3296 | var setters = target.map(function (t) {
|
3297 | return gsap.quickSetter(t, property, unit);
|
3298 | }),
|
3299 | l = setters.length;
|
3300 | return function (value) {
|
3301 | var i = l;
|
3302 |
|
3303 | while (i--) {
|
3304 | setters[i](value);
|
3305 | }
|
3306 | };
|
3307 | }
|
3308 |
|
3309 | target = target[0] || {};
|
3310 |
|
3311 | var Plugin = _plugins[property],
|
3312 | cache = _getCache(target),
|
3313 | p = cache.harness && (cache.harness.aliases || {})[property] || property,
|
3314 | setter = Plugin ? function (value) {
|
3315 | var p = new Plugin();
|
3316 | _quickTween._pt = 0;
|
3317 | p.init(target, unit ? value + unit : value, _quickTween, 0, [target]);
|
3318 | p.render(1, p);
|
3319 | _quickTween._pt && _renderPropTweens(1, _quickTween);
|
3320 | } : cache.set(target, p);
|
3321 |
|
3322 | return Plugin ? setter : function (value) {
|
3323 | return setter(target, p, unit ? value + unit : value, cache, 1);
|
3324 | };
|
3325 | },
|
3326 | isTweening: function isTweening(targets) {
|
3327 | return _globalTimeline.getTweensOf(targets, true).length > 0;
|
3328 | },
|
3329 | defaults: function defaults(value) {
|
3330 | value && value.ease && (value.ease = _parseEase(value.ease, _defaults.ease));
|
3331 | return _mergeDeep(_defaults, value || {});
|
3332 | },
|
3333 | config: function config(value) {
|
3334 | return _mergeDeep(_config, value || {});
|
3335 | },
|
3336 | registerEffect: function registerEffect(_ref) {
|
3337 | var name = _ref.name,
|
3338 | effect = _ref.effect,
|
3339 | plugins = _ref.plugins,
|
3340 | defaults = _ref.defaults,
|
3341 | extendTimeline = _ref.extendTimeline;
|
3342 | (plugins || "").split(",").forEach(function (pluginName) {
|
3343 | return pluginName && !_plugins[pluginName] && !_globals[pluginName] && _warn(name + " effect requires " + pluginName + " plugin.");
|
3344 | });
|
3345 |
|
3346 | _effects[name] = function (targets, vars, tl) {
|
3347 | return effect(toArray(targets), _setDefaults(vars || {}, defaults), tl);
|
3348 | };
|
3349 |
|
3350 | if (extendTimeline) {
|
3351 | Timeline.prototype[name] = function (targets, vars, position) {
|
3352 | return this.add(_effects[name](targets, _isObject(vars) ? vars : (position = vars) && {}, this), position);
|
3353 | };
|
3354 | }
|
3355 | },
|
3356 | registerEase: function registerEase(name, ease) {
|
3357 | _easeMap[name] = _parseEase(ease);
|
3358 | },
|
3359 | parseEase: function parseEase(ease, defaultEase) {
|
3360 | return arguments.length ? _parseEase(ease, defaultEase) : _easeMap;
|
3361 | },
|
3362 | getById: function getById(id) {
|
3363 | return _globalTimeline.getById(id);
|
3364 | },
|
3365 | exportRoot: function exportRoot(vars, includeDelayedCalls) {
|
3366 | if (vars === void 0) {
|
3367 | vars = {};
|
3368 | }
|
3369 |
|
3370 | var tl = new Timeline(vars),
|
3371 | child,
|
3372 | next;
|
3373 | tl.smoothChildTiming = _isNotFalse(vars.smoothChildTiming);
|
3374 |
|
3375 | _globalTimeline.remove(tl);
|
3376 |
|
3377 | tl._dp = 0;
|
3378 | tl._time = tl._tTime = _globalTimeline._time;
|
3379 | child = _globalTimeline._first;
|
3380 |
|
3381 | while (child) {
|
3382 | next = child._next;
|
3383 |
|
3384 | if (includeDelayedCalls || !(!child._dur && child instanceof Tween && child.vars.onComplete === child._targets[0])) {
|
3385 | _addToTimeline(tl, child, child._start - child._delay);
|
3386 | }
|
3387 |
|
3388 | child = next;
|
3389 | }
|
3390 |
|
3391 | _addToTimeline(_globalTimeline, tl, 0);
|
3392 |
|
3393 | return tl;
|
3394 | },
|
3395 | utils: {
|
3396 | wrap: wrap,
|
3397 | wrapYoyo: wrapYoyo,
|
3398 | distribute: distribute,
|
3399 | random: random,
|
3400 | snap: snap,
|
3401 | normalize: normalize,
|
3402 | getUnit: getUnit,
|
3403 | clamp: clamp,
|
3404 | splitColor: splitColor,
|
3405 | toArray: toArray,
|
3406 | mapRange: mapRange,
|
3407 | pipe: pipe,
|
3408 | unitize: unitize,
|
3409 | interpolate: interpolate,
|
3410 | shuffle: shuffle
|
3411 | },
|
3412 | install: _install,
|
3413 | effects: _effects,
|
3414 | ticker: _ticker,
|
3415 | updateRoot: Timeline.updateRoot,
|
3416 | plugins: _plugins,
|
3417 | globalTimeline: _globalTimeline,
|
3418 | core: {
|
3419 | PropTween: PropTween,
|
3420 | globals: _addGlobal,
|
3421 | Tween: Tween,
|
3422 | Timeline: Timeline,
|
3423 | Animation: Animation,
|
3424 | getCache: _getCache,
|
3425 | _removeLinkedListItem: _removeLinkedListItem
|
3426 | }
|
3427 | };
|
3428 |
|
3429 | _forEachName("to,from,fromTo,delayedCall,set,killTweensOf", function (name) {
|
3430 | return _gsap[name] = Tween[name];
|
3431 | });
|
3432 |
|
3433 | _ticker.add(Timeline.updateRoot);
|
3434 |
|
3435 | _quickTween = _gsap.to({}, {
|
3436 | duration: 0
|
3437 | });
|
3438 |
|
3439 | var _getPluginPropTween = function _getPluginPropTween(plugin, prop) {
|
3440 | var pt = plugin._pt;
|
3441 |
|
3442 | while (pt && pt.p !== prop && pt.op !== prop && pt.fp !== prop) {
|
3443 | pt = pt._next;
|
3444 | }
|
3445 |
|
3446 | return pt;
|
3447 | },
|
3448 | _addModifiers = function _addModifiers(tween, modifiers) {
|
3449 | var targets = tween._targets,
|
3450 | p,
|
3451 | i,
|
3452 | pt;
|
3453 |
|
3454 | for (p in modifiers) {
|
3455 | i = targets.length;
|
3456 |
|
3457 | while (i--) {
|
3458 | pt = tween._ptLookup[i][p];
|
3459 |
|
3460 | if (pt && (pt = pt.d)) {
|
3461 | if (pt._pt) {
|
3462 | pt = _getPluginPropTween(pt, p);
|
3463 | }
|
3464 |
|
3465 | pt && pt.modifier && pt.modifier(modifiers[p], tween, targets[i], p);
|
3466 | }
|
3467 | }
|
3468 | }
|
3469 | },
|
3470 | _buildModifierPlugin = function _buildModifierPlugin(name, modifier) {
|
3471 | return {
|
3472 | name: name,
|
3473 | rawVars: 1,
|
3474 | init: function init(target, vars, tween) {
|
3475 | tween._onInit = function (tween) {
|
3476 | var temp, p;
|
3477 |
|
3478 | if (_isString(vars)) {
|
3479 | temp = {};
|
3480 |
|
3481 | _forEachName(vars, function (name) {
|
3482 | return temp[name] = 1;
|
3483 | });
|
3484 |
|
3485 | vars = temp;
|
3486 | }
|
3487 |
|
3488 | if (modifier) {
|
3489 | temp = {};
|
3490 |
|
3491 | for (p in vars) {
|
3492 | temp[p] = modifier(vars[p]);
|
3493 | }
|
3494 |
|
3495 | vars = temp;
|
3496 | }
|
3497 |
|
3498 | _addModifiers(tween, vars);
|
3499 | };
|
3500 | }
|
3501 | };
|
3502 | };
|
3503 |
|
3504 | var gsap = _gsap.registerPlugin({
|
3505 | name: "attr",
|
3506 | init: function init(target, vars, tween, index, targets) {
|
3507 | var p, pt;
|
3508 |
|
3509 | for (p in vars) {
|
3510 | pt = this.add(target, "setAttribute", (target.getAttribute(p) || 0) + "", vars[p], index, targets, 0, 0, p);
|
3511 | pt && (pt.op = p);
|
3512 |
|
3513 | this._props.push(p);
|
3514 | }
|
3515 | }
|
3516 | }, {
|
3517 | name: "endArray",
|
3518 | init: function init(target, value) {
|
3519 | var i = value.length;
|
3520 |
|
3521 | while (i--) {
|
3522 | this.add(target, i, target[i] || 0, value[i]);
|
3523 | }
|
3524 | }
|
3525 | }, _buildModifierPlugin("roundProps", _roundModifier), _buildModifierPlugin("modifiers"), _buildModifierPlugin("snap", snap)) || _gsap;
|
3526 | Tween.version = Timeline.version = gsap.version = "3.5.1";
|
3527 | _coreReady = 1;
|
3528 |
|
3529 | if (_windowExists()) {
|
3530 | _wake();
|
3531 | }
|
3532 |
|
3533 | var Power0 = _easeMap.Power0,
|
3534 | Power1 = _easeMap.Power1,
|
3535 | Power2 = _easeMap.Power2,
|
3536 | Power3 = _easeMap.Power3,
|
3537 | Power4 = _easeMap.Power4,
|
3538 | Linear = _easeMap.Linear,
|
3539 | Quad = _easeMap.Quad,
|
3540 | Cubic = _easeMap.Cubic,
|
3541 | Quart = _easeMap.Quart,
|
3542 | Quint = _easeMap.Quint,
|
3543 | Strong = _easeMap.Strong,
|
3544 | Elastic = _easeMap.Elastic,
|
3545 | Back = _easeMap.Back,
|
3546 | SteppedEase = _easeMap.SteppedEase,
|
3547 | Bounce = _easeMap.Bounce,
|
3548 | Sine = _easeMap.Sine,
|
3549 | Expo = _easeMap.Expo,
|
3550 | Circ = _easeMap.Circ;
|
3551 |
|
3552 | var _win$1,
|
3553 | _doc$1,
|
3554 | _docElement,
|
3555 | _pluginInitted,
|
3556 | _tempDiv,
|
3557 | _tempDivStyler,
|
3558 | _recentSetterPlugin,
|
3559 | _windowExists$1 = function _windowExists() {
|
3560 | return typeof window !== "undefined";
|
3561 | },
|
3562 | _transformProps = {},
|
3563 | _RAD2DEG = 180 / Math.PI,
|
3564 | _DEG2RAD = Math.PI / 180,
|
3565 | _atan2 = Math.atan2,
|
3566 | _bigNum$1 = 1e8,
|
3567 | _capsExp = /([A-Z])/g,
|
3568 | _horizontalExp = /(?:left|right|width|margin|padding|x)/i,
|
3569 | _complexExp = /[\s,\(]\S/,
|
3570 | _propertyAliases = {
|
3571 | autoAlpha: "opacity,visibility",
|
3572 | scale: "scaleX,scaleY",
|
3573 | alpha: "opacity"
|
3574 | },
|
3575 | _renderCSSProp = function _renderCSSProp(ratio, data) {
|
3576 | return data.set(data.t, data.p, Math.round((data.s + data.c * ratio) * 10000) / 10000 + data.u, data);
|
3577 | },
|
3578 | _renderPropWithEnd = function _renderPropWithEnd(ratio, data) {
|
3579 | return data.set(data.t, data.p, ratio === 1 ? data.e : Math.round((data.s + data.c * ratio) * 10000) / 10000 + data.u, data);
|
3580 | },
|
3581 | _renderCSSPropWithBeginning = function _renderCSSPropWithBeginning(ratio, data) {
|
3582 | return data.set(data.t, data.p, ratio ? Math.round((data.s + data.c * ratio) * 10000) / 10000 + data.u : data.b, data);
|
3583 | },
|
3584 | _renderRoundedCSSProp = function _renderRoundedCSSProp(ratio, data) {
|
3585 | var value = data.s + data.c * ratio;
|
3586 | data.set(data.t, data.p, ~~(value + (value < 0 ? -.5 : .5)) + data.u, data);
|
3587 | },
|
3588 | _renderNonTweeningValue = function _renderNonTweeningValue(ratio, data) {
|
3589 | return data.set(data.t, data.p, ratio ? data.e : data.b, data);
|
3590 | },
|
3591 | _renderNonTweeningValueOnlyAtEnd = function _renderNonTweeningValueOnlyAtEnd(ratio, data) {
|
3592 | return data.set(data.t, data.p, ratio !== 1 ? data.b : data.e, data);
|
3593 | },
|
3594 | _setterCSSStyle = function _setterCSSStyle(target, property, value) {
|
3595 | return target.style[property] = value;
|
3596 | },
|
3597 | _setterCSSProp = function _setterCSSProp(target, property, value) {
|
3598 | return target.style.setProperty(property, value);
|
3599 | },
|
3600 | _setterTransform = function _setterTransform(target, property, value) {
|
3601 | return target._gsap[property] = value;
|
3602 | },
|
3603 | _setterScale = function _setterScale(target, property, value) {
|
3604 | return target._gsap.scaleX = target._gsap.scaleY = value;
|
3605 | },
|
3606 | _setterScaleWithRender = function _setterScaleWithRender(target, property, value, data, ratio) {
|
3607 | var cache = target._gsap;
|
3608 | cache.scaleX = cache.scaleY = value;
|
3609 | cache.renderTransform(ratio, cache);
|
3610 | },
|
3611 | _setterTransformWithRender = function _setterTransformWithRender(target, property, value, data, ratio) {
|
3612 | var cache = target._gsap;
|
3613 | cache[property] = value;
|
3614 | cache.renderTransform(ratio, cache);
|
3615 | },
|
3616 | _transformProp = "transform",
|
3617 | _transformOriginProp = _transformProp + "Origin",
|
3618 | _supports3D,
|
3619 | _createElement = function _createElement(type, ns) {
|
3620 | var e = _doc$1.createElementNS ? _doc$1.createElementNS((ns || "http://www.w3.org/1999/xhtml").replace(/^https/, "http"), type) : _doc$1.createElement(type);
|
3621 | return e.style ? e : _doc$1.createElement(type);
|
3622 | },
|
3623 | _getComputedProperty = function _getComputedProperty(target, property, skipPrefixFallback) {
|
3624 | var cs = getComputedStyle(target);
|
3625 | return cs[property] || cs.getPropertyValue(property.replace(_capsExp, "-$1").toLowerCase()) || cs.getPropertyValue(property) || !skipPrefixFallback && _getComputedProperty(target, _checkPropPrefix(property) || property, 1) || "";
|
3626 | },
|
3627 | _prefixes = "O,Moz,ms,Ms,Webkit".split(","),
|
3628 | _checkPropPrefix = function _checkPropPrefix(property, element, preferPrefix) {
|
3629 | var e = element || _tempDiv,
|
3630 | s = e.style,
|
3631 | i = 5;
|
3632 |
|
3633 | if (property in s && !preferPrefix) {
|
3634 | return property;
|
3635 | }
|
3636 |
|
3637 | property = property.charAt(0).toUpperCase() + property.substr(1);
|
3638 |
|
3639 | while (i-- && !(_prefixes[i] + property in s)) {}
|
3640 |
|
3641 | return i < 0 ? null : (i === 3 ? "ms" : i >= 0 ? _prefixes[i] : "") + property;
|
3642 | },
|
3643 | _initCore = function _initCore() {
|
3644 | if (_windowExists$1() && window.document) {
|
3645 | _win$1 = window;
|
3646 | _doc$1 = _win$1.document;
|
3647 | _docElement = _doc$1.documentElement;
|
3648 | _tempDiv = _createElement("div") || {
|
3649 | style: {}
|
3650 | };
|
3651 | _tempDivStyler = _createElement("div");
|
3652 | _transformProp = _checkPropPrefix(_transformProp);
|
3653 | _transformOriginProp = _transformProp + "Origin";
|
3654 | _tempDiv.style.cssText = "border-width:0;line-height:0;position:absolute;padding:0";
|
3655 | _supports3D = !!_checkPropPrefix("perspective");
|
3656 | _pluginInitted = 1;
|
3657 | }
|
3658 | },
|
3659 | _getBBoxHack = function _getBBoxHack(swapIfPossible) {
|
3660 | var svg = _createElement("svg", this.ownerSVGElement && this.ownerSVGElement.getAttribute("xmlns") || "http://www.w3.org/2000/svg"),
|
3661 | oldParent = this.parentNode,
|
3662 | oldSibling = this.nextSibling,
|
3663 | oldCSS = this.style.cssText,
|
3664 | bbox;
|
3665 |
|
3666 | _docElement.appendChild(svg);
|
3667 |
|
3668 | svg.appendChild(this);
|
3669 | this.style.display = "block";
|
3670 |
|
3671 | if (swapIfPossible) {
|
3672 | try {
|
3673 | bbox = this.getBBox();
|
3674 | this._gsapBBox = this.getBBox;
|
3675 | this.getBBox = _getBBoxHack;
|
3676 | } catch (e) {}
|
3677 | } else if (this._gsapBBox) {
|
3678 | bbox = this._gsapBBox();
|
3679 | }
|
3680 |
|
3681 | if (oldParent) {
|
3682 | if (oldSibling) {
|
3683 | oldParent.insertBefore(this, oldSibling);
|
3684 | } else {
|
3685 | oldParent.appendChild(this);
|
3686 | }
|
3687 | }
|
3688 |
|
3689 | _docElement.removeChild(svg);
|
3690 |
|
3691 | this.style.cssText = oldCSS;
|
3692 | return bbox;
|
3693 | },
|
3694 | _getAttributeFallbacks = function _getAttributeFallbacks(target, attributesArray) {
|
3695 | var i = attributesArray.length;
|
3696 |
|
3697 | while (i--) {
|
3698 | if (target.hasAttribute(attributesArray[i])) {
|
3699 | return target.getAttribute(attributesArray[i]);
|
3700 | }
|
3701 | }
|
3702 | },
|
3703 | _getBBox = function _getBBox(target) {
|
3704 | var bounds;
|
3705 |
|
3706 | try {
|
3707 | bounds = target.getBBox();
|
3708 | } catch (error) {
|
3709 | bounds = _getBBoxHack.call(target, true);
|
3710 | }
|
3711 |
|
3712 | bounds && (bounds.width || bounds.height) || target.getBBox === _getBBoxHack || (bounds = _getBBoxHack.call(target, true));
|
3713 | return bounds && !bounds.width && !bounds.x && !bounds.y ? {
|
3714 | x: +_getAttributeFallbacks(target, ["x", "cx", "x1"]) || 0,
|
3715 | y: +_getAttributeFallbacks(target, ["y", "cy", "y1"]) || 0,
|
3716 | width: 0,
|
3717 | height: 0
|
3718 | } : bounds;
|
3719 | },
|
3720 | _isSVG = function _isSVG(e) {
|
3721 | return !!(e.getCTM && (!e.parentNode || e.ownerSVGElement) && _getBBox(e));
|
3722 | },
|
3723 | _removeProperty = function _removeProperty(target, property) {
|
3724 | if (property) {
|
3725 | var style = target.style;
|
3726 |
|
3727 | if (property in _transformProps && property !== _transformOriginProp) {
|
3728 | property = _transformProp;
|
3729 | }
|
3730 |
|
3731 | if (style.removeProperty) {
|
3732 | if (property.substr(0, 2) === "ms" || property.substr(0, 6) === "webkit") {
|
3733 | property = "-" + property;
|
3734 | }
|
3735 |
|
3736 | style.removeProperty(property.replace(_capsExp, "-$1").toLowerCase());
|
3737 | } else {
|
3738 | style.removeAttribute(property);
|
3739 | }
|
3740 | }
|
3741 | },
|
3742 | _addNonTweeningPT = function _addNonTweeningPT(plugin, target, property, beginning, end, onlySetAtEnd) {
|
3743 | var pt = new PropTween(plugin._pt, target, property, 0, 1, onlySetAtEnd ? _renderNonTweeningValueOnlyAtEnd : _renderNonTweeningValue);
|
3744 | plugin._pt = pt;
|
3745 | pt.b = beginning;
|
3746 | pt.e = end;
|
3747 |
|
3748 | plugin._props.push(property);
|
3749 |
|
3750 | return pt;
|
3751 | },
|
3752 | _nonConvertibleUnits = {
|
3753 | deg: 1,
|
3754 | rad: 1,
|
3755 | turn: 1
|
3756 | },
|
3757 | _convertToUnit = function _convertToUnit(target, property, value, unit) {
|
3758 | var curValue = parseFloat(value) || 0,
|
3759 | curUnit = (value + "").trim().substr((curValue + "").length) || "px",
|
3760 | style = _tempDiv.style,
|
3761 | horizontal = _horizontalExp.test(property),
|
3762 | isRootSVG = target.tagName.toLowerCase() === "svg",
|
3763 | measureProperty = (isRootSVG ? "client" : "offset") + (horizontal ? "Width" : "Height"),
|
3764 | amount = 100,
|
3765 | toPixels = unit === "px",
|
3766 | toPercent = unit === "%",
|
3767 | px,
|
3768 | parent,
|
3769 | cache,
|
3770 | isSVG;
|
3771 |
|
3772 | if (unit === curUnit || !curValue || _nonConvertibleUnits[unit] || _nonConvertibleUnits[curUnit]) {
|
3773 | return curValue;
|
3774 | }
|
3775 |
|
3776 | curUnit !== "px" && !toPixels && (curValue = _convertToUnit(target, property, value, "px"));
|
3777 | isSVG = target.getCTM && _isSVG(target);
|
3778 |
|
3779 | if (toPercent && (_transformProps[property] || ~property.indexOf("adius"))) {
|
3780 | return _round(curValue / (isSVG ? target.getBBox()[horizontal ? "width" : "height"] : target[measureProperty]) * amount);
|
3781 | }
|
3782 |
|
3783 | style[horizontal ? "width" : "height"] = amount + (toPixels ? curUnit : unit);
|
3784 | parent = ~property.indexOf("adius") || unit === "em" && target.appendChild && !isRootSVG ? target : target.parentNode;
|
3785 |
|
3786 | if (isSVG) {
|
3787 | parent = (target.ownerSVGElement || {}).parentNode;
|
3788 | }
|
3789 |
|
3790 | if (!parent || parent === _doc$1 || !parent.appendChild) {
|
3791 | parent = _doc$1.body;
|
3792 | }
|
3793 |
|
3794 | cache = parent._gsap;
|
3795 |
|
3796 | if (cache && toPercent && cache.width && horizontal && cache.time === _ticker.time) {
|
3797 | return _round(curValue / cache.width * amount);
|
3798 | } else {
|
3799 | (toPercent || curUnit === "%") && (style.position = _getComputedProperty(target, "position"));
|
3800 | parent === target && (style.position = "static");
|
3801 | parent.appendChild(_tempDiv);
|
3802 | px = _tempDiv[measureProperty];
|
3803 | parent.removeChild(_tempDiv);
|
3804 | style.position = "absolute";
|
3805 |
|
3806 | if (horizontal && toPercent) {
|
3807 | cache = _getCache(parent);
|
3808 | cache.time = _ticker.time;
|
3809 | cache.width = parent[measureProperty];
|
3810 | }
|
3811 | }
|
3812 |
|
3813 | return _round(toPixels ? px * curValue / amount : px && curValue ? amount / px * curValue : 0);
|
3814 | },
|
3815 | _get = function _get(target, property, unit, uncache) {
|
3816 | var value;
|
3817 | _pluginInitted || _initCore();
|
3818 |
|
3819 | if (property in _propertyAliases && property !== "transform") {
|
3820 | property = _propertyAliases[property];
|
3821 |
|
3822 | if (~property.indexOf(",")) {
|
3823 | property = property.split(",")[0];
|
3824 | }
|
3825 | }
|
3826 |
|
3827 | if (_transformProps[property] && property !== "transform") {
|
3828 | value = _parseTransform(target, uncache);
|
3829 | value = property !== "transformOrigin" ? value[property] : _firstTwoOnly(_getComputedProperty(target, _transformOriginProp)) + " " + value.zOrigin + "px";
|
3830 | } else {
|
3831 | value = target.style[property];
|
3832 |
|
3833 | if (!value || value === "auto" || uncache || ~(value + "").indexOf("calc(")) {
|
3834 | value = _specialProps[property] && _specialProps[property](target, property, unit) || _getComputedProperty(target, property) || _getProperty(target, property) || (property === "opacity" ? 1 : 0);
|
3835 | }
|
3836 | }
|
3837 |
|
3838 | return unit && !~(value + "").indexOf(" ") ? _convertToUnit(target, property, value, unit) + unit : value;
|
3839 | },
|
3840 | _tweenComplexCSSString = function _tweenComplexCSSString(target, prop, start, end) {
|
3841 | if (!start || start === "none") {
|
3842 | var p = _checkPropPrefix(prop, target, 1),
|
3843 | s = p && _getComputedProperty(target, p, 1);
|
3844 |
|
3845 | if (s && s !== start) {
|
3846 | prop = p;
|
3847 | start = s;
|
3848 | } else if (prop === "borderColor") {
|
3849 | start = _getComputedProperty(target, "borderTopColor");
|
3850 | }
|
3851 | }
|
3852 |
|
3853 | var pt = new PropTween(this._pt, target.style, prop, 0, 1, _renderComplexString),
|
3854 | index = 0,
|
3855 | matchIndex = 0,
|
3856 | a,
|
3857 | result,
|
3858 | startValues,
|
3859 | startNum,
|
3860 | color,
|
3861 | startValue,
|
3862 | endValue,
|
3863 | endNum,
|
3864 | chunk,
|
3865 | endUnit,
|
3866 | startUnit,
|
3867 | relative,
|
3868 | endValues;
|
3869 | pt.b = start;
|
3870 | pt.e = end;
|
3871 | start += "";
|
3872 | end += "";
|
3873 |
|
3874 | if (end === "auto") {
|
3875 | target.style[prop] = end;
|
3876 | end = _getComputedProperty(target, prop) || end;
|
3877 | target.style[prop] = start;
|
3878 | }
|
3879 |
|
3880 | a = [start, end];
|
3881 |
|
3882 | _colorStringFilter(a);
|
3883 |
|
3884 | start = a[0];
|
3885 | end = a[1];
|
3886 | startValues = start.match(_numWithUnitExp) || [];
|
3887 | endValues = end.match(_numWithUnitExp) || [];
|
3888 |
|
3889 | if (endValues.length) {
|
3890 | while (result = _numWithUnitExp.exec(end)) {
|
3891 | endValue = result[0];
|
3892 | chunk = end.substring(index, result.index);
|
3893 |
|
3894 | if (color) {
|
3895 | color = (color + 1) % 5;
|
3896 | } else if (chunk.substr(-5) === "rgba(" || chunk.substr(-5) === "hsla(") {
|
3897 | color = 1;
|
3898 | }
|
3899 |
|
3900 | if (endValue !== (startValue = startValues[matchIndex++] || "")) {
|
3901 | startNum = parseFloat(startValue) || 0;
|
3902 | startUnit = startValue.substr((startNum + "").length);
|
3903 | relative = endValue.charAt(1) === "=" ? +(endValue.charAt(0) + "1") : 0;
|
3904 |
|
3905 | if (relative) {
|
3906 | endValue = endValue.substr(2);
|
3907 | }
|
3908 |
|
3909 | endNum = parseFloat(endValue);
|
3910 | endUnit = endValue.substr((endNum + "").length);
|
3911 | index = _numWithUnitExp.lastIndex - endUnit.length;
|
3912 |
|
3913 | if (!endUnit) {
|
3914 | endUnit = endUnit || _config.units[prop] || startUnit;
|
3915 |
|
3916 | if (index === end.length) {
|
3917 | end += endUnit;
|
3918 | pt.e += endUnit;
|
3919 | }
|
3920 | }
|
3921 |
|
3922 | if (startUnit !== endUnit) {
|
3923 | startNum = _convertToUnit(target, prop, startValue, endUnit) || 0;
|
3924 | }
|
3925 |
|
3926 | pt._pt = {
|
3927 | _next: pt._pt,
|
3928 | p: chunk || matchIndex === 1 ? chunk : ",",
|
3929 | s: startNum,
|
3930 | c: relative ? relative * endNum : endNum - startNum,
|
3931 | m: color && color < 4 ? Math.round : 0
|
3932 | };
|
3933 | }
|
3934 | }
|
3935 |
|
3936 | pt.c = index < end.length ? end.substring(index, end.length) : "";
|
3937 | } else {
|
3938 | pt.r = prop === "display" && end === "none" ? _renderNonTweeningValueOnlyAtEnd : _renderNonTweeningValue;
|
3939 | }
|
3940 |
|
3941 | if (_relExp.test(end)) {
|
3942 | pt.e = 0;
|
3943 | }
|
3944 |
|
3945 | this._pt = pt;
|
3946 | return pt;
|
3947 | },
|
3948 | _keywordToPercent = {
|
3949 | top: "0%",
|
3950 | bottom: "100%",
|
3951 | left: "0%",
|
3952 | right: "100%",
|
3953 | center: "50%"
|
3954 | },
|
3955 | _convertKeywordsToPercentages = function _convertKeywordsToPercentages(value) {
|
3956 | var split = value.split(" "),
|
3957 | x = split[0],
|
3958 | y = split[1] || "50%";
|
3959 |
|
3960 | if (x === "top" || x === "bottom" || y === "left" || y === "right") {
|
3961 | value = x;
|
3962 | x = y;
|
3963 | y = value;
|
3964 | }
|
3965 |
|
3966 | split[0] = _keywordToPercent[x] || x;
|
3967 | split[1] = _keywordToPercent[y] || y;
|
3968 | return split.join(" ");
|
3969 | },
|
3970 | _renderClearProps = function _renderClearProps(ratio, data) {
|
3971 | if (data.tween && data.tween._time === data.tween._dur) {
|
3972 | var target = data.t,
|
3973 | style = target.style,
|
3974 | props = data.u,
|
3975 | cache = target._gsap,
|
3976 | prop,
|
3977 | clearTransforms,
|
3978 | i;
|
3979 |
|
3980 | if (props === "all" || props === true) {
|
3981 | style.cssText = "";
|
3982 | clearTransforms = 1;
|
3983 | } else {
|
3984 | props = props.split(",");
|
3985 | i = props.length;
|
3986 |
|
3987 | while (--i > -1) {
|
3988 | prop = props[i];
|
3989 |
|
3990 | if (_transformProps[prop]) {
|
3991 | clearTransforms = 1;
|
3992 | prop = prop === "transformOrigin" ? _transformOriginProp : _transformProp;
|
3993 | }
|
3994 |
|
3995 | _removeProperty(target, prop);
|
3996 | }
|
3997 | }
|
3998 |
|
3999 | if (clearTransforms) {
|
4000 | _removeProperty(target, _transformProp);
|
4001 |
|
4002 | if (cache) {
|
4003 | cache.svg && target.removeAttribute("transform");
|
4004 |
|
4005 | _parseTransform(target, 1);
|
4006 |
|
4007 | cache.uncache = 1;
|
4008 | }
|
4009 | }
|
4010 | }
|
4011 | },
|
4012 | _specialProps = {
|
4013 | clearProps: function clearProps(plugin, target, property, endValue, tween) {
|
4014 | if (tween.data !== "isFromStart") {
|
4015 | var pt = plugin._pt = new PropTween(plugin._pt, target, property, 0, 0, _renderClearProps);
|
4016 | pt.u = endValue;
|
4017 | pt.pr = -10;
|
4018 | pt.tween = tween;
|
4019 |
|
4020 | plugin._props.push(property);
|
4021 |
|
4022 | return 1;
|
4023 | }
|
4024 | }
|
4025 | },
|
4026 | _identity2DMatrix = [1, 0, 0, 1, 0, 0],
|
4027 | _rotationalProperties = {},
|
4028 | _isNullTransform = function _isNullTransform(value) {
|
4029 | return value === "matrix(1, 0, 0, 1, 0, 0)" || value === "none" || !value;
|
4030 | },
|
4031 | _getComputedTransformMatrixAsArray = function _getComputedTransformMatrixAsArray(target) {
|
4032 | var matrixString = _getComputedProperty(target, _transformProp);
|
4033 |
|
4034 | return _isNullTransform(matrixString) ? _identity2DMatrix : matrixString.substr(7).match(_numExp).map(_round);
|
4035 | },
|
4036 | _getMatrix = function _getMatrix(target, force2D) {
|
4037 | var cache = target._gsap || _getCache(target),
|
4038 | style = target.style,
|
4039 | matrix = _getComputedTransformMatrixAsArray(target),
|
4040 | parent,
|
4041 | nextSibling,
|
4042 | temp,
|
4043 | addedToDOM;
|
4044 |
|
4045 | if (cache.svg && target.getAttribute("transform")) {
|
4046 | temp = target.transform.baseVal.consolidate().matrix;
|
4047 | matrix = [temp.a, temp.b, temp.c, temp.d, temp.e, temp.f];
|
4048 | return matrix.join(",") === "1,0,0,1,0,0" ? _identity2DMatrix : matrix;
|
4049 | } else if (matrix === _identity2DMatrix && !target.offsetParent && target !== _docElement && !cache.svg) {
|
4050 | temp = style.display;
|
4051 | style.display = "block";
|
4052 | parent = target.parentNode;
|
4053 |
|
4054 | if (!parent || !target.offsetParent) {
|
4055 | addedToDOM = 1;
|
4056 | nextSibling = target.nextSibling;
|
4057 |
|
4058 | _docElement.appendChild(target);
|
4059 | }
|
4060 |
|
4061 | matrix = _getComputedTransformMatrixAsArray(target);
|
4062 | temp ? style.display = temp : _removeProperty(target, "display");
|
4063 |
|
4064 | if (addedToDOM) {
|
4065 | nextSibling ? parent.insertBefore(target, nextSibling) : parent ? parent.appendChild(target) : _docElement.removeChild(target);
|
4066 | }
|
4067 | }
|
4068 |
|
4069 | return force2D && matrix.length > 6 ? [matrix[0], matrix[1], matrix[4], matrix[5], matrix[12], matrix[13]] : matrix;
|
4070 | },
|
4071 | _applySVGOrigin = function _applySVGOrigin(target, origin, originIsAbsolute, smooth, matrixArray, pluginToAddPropTweensTo) {
|
4072 | var cache = target._gsap,
|
4073 | matrix = matrixArray || _getMatrix(target, true),
|
4074 | xOriginOld = cache.xOrigin || 0,
|
4075 | yOriginOld = cache.yOrigin || 0,
|
4076 | xOffsetOld = cache.xOffset || 0,
|
4077 | yOffsetOld = cache.yOffset || 0,
|
4078 | a = matrix[0],
|
4079 | b = matrix[1],
|
4080 | c = matrix[2],
|
4081 | d = matrix[3],
|
4082 | tx = matrix[4],
|
4083 | ty = matrix[5],
|
4084 | originSplit = origin.split(" "),
|
4085 | xOrigin = parseFloat(originSplit[0]) || 0,
|
4086 | yOrigin = parseFloat(originSplit[1]) || 0,
|
4087 | bounds,
|
4088 | determinant,
|
4089 | x,
|
4090 | y;
|
4091 |
|
4092 | if (!originIsAbsolute) {
|
4093 | bounds = _getBBox(target);
|
4094 | xOrigin = bounds.x + (~originSplit[0].indexOf("%") ? xOrigin / 100 * bounds.width : xOrigin);
|
4095 | yOrigin = bounds.y + (~(originSplit[1] || originSplit[0]).indexOf("%") ? yOrigin / 100 * bounds.height : yOrigin);
|
4096 | } else if (matrix !== _identity2DMatrix && (determinant = a * d - b * c)) {
|
4097 | x = xOrigin * (d / determinant) + yOrigin * (-c / determinant) + (c * ty - d * tx) / determinant;
|
4098 | y = xOrigin * (-b / determinant) + yOrigin * (a / determinant) - (a * ty - b * tx) / determinant;
|
4099 | xOrigin = x;
|
4100 | yOrigin = y;
|
4101 | }
|
4102 |
|
4103 | if (smooth || smooth !== false && cache.smooth) {
|
4104 | tx = xOrigin - xOriginOld;
|
4105 | ty = yOrigin - yOriginOld;
|
4106 | cache.xOffset = xOffsetOld + (tx * a + ty * c) - tx;
|
4107 | cache.yOffset = yOffsetOld + (tx * b + ty * d) - ty;
|
4108 | } else {
|
4109 | cache.xOffset = cache.yOffset = 0;
|
4110 | }
|
4111 |
|
4112 | cache.xOrigin = xOrigin;
|
4113 | cache.yOrigin = yOrigin;
|
4114 | cache.smooth = !!smooth;
|
4115 | cache.origin = origin;
|
4116 | cache.originIsAbsolute = !!originIsAbsolute;
|
4117 | target.style[_transformOriginProp] = "0px 0px";
|
4118 |
|
4119 | if (pluginToAddPropTweensTo) {
|
4120 | _addNonTweeningPT(pluginToAddPropTweensTo, cache, "xOrigin", xOriginOld, xOrigin);
|
4121 |
|
4122 | _addNonTweeningPT(pluginToAddPropTweensTo, cache, "yOrigin", yOriginOld, yOrigin);
|
4123 |
|
4124 | _addNonTweeningPT(pluginToAddPropTweensTo, cache, "xOffset", xOffsetOld, cache.xOffset);
|
4125 |
|
4126 | _addNonTweeningPT(pluginToAddPropTweensTo, cache, "yOffset", yOffsetOld, cache.yOffset);
|
4127 | }
|
4128 |
|
4129 | target.setAttribute("data-svg-origin", xOrigin + " " + yOrigin);
|
4130 | },
|
4131 | _parseTransform = function _parseTransform(target, uncache) {
|
4132 | var cache = target._gsap || new GSCache(target);
|
4133 |
|
4134 | if ("x" in cache && !uncache && !cache.uncache) {
|
4135 | return cache;
|
4136 | }
|
4137 |
|
4138 | var style = target.style,
|
4139 | invertedScaleX = cache.scaleX < 0,
|
4140 | px = "px",
|
4141 | deg = "deg",
|
4142 | origin = _getComputedProperty(target, _transformOriginProp) || "0",
|
4143 | x,
|
4144 | y,
|
4145 | z,
|
4146 | scaleX,
|
4147 | scaleY,
|
4148 | rotation,
|
4149 | rotationX,
|
4150 | rotationY,
|
4151 | skewX,
|
4152 | skewY,
|
4153 | perspective,
|
4154 | xOrigin,
|
4155 | yOrigin,
|
4156 | matrix,
|
4157 | angle,
|
4158 | cos,
|
4159 | sin,
|
4160 | a,
|
4161 | b,
|
4162 | c,
|
4163 | d,
|
4164 | a12,
|
4165 | a22,
|
4166 | t1,
|
4167 | t2,
|
4168 | t3,
|
4169 | a13,
|
4170 | a23,
|
4171 | a33,
|
4172 | a42,
|
4173 | a43,
|
4174 | a32;
|
4175 | x = y = z = rotation = rotationX = rotationY = skewX = skewY = perspective = 0;
|
4176 | scaleX = scaleY = 1;
|
4177 | cache.svg = !!(target.getCTM && _isSVG(target));
|
4178 | matrix = _getMatrix(target, cache.svg);
|
4179 |
|
4180 | if (cache.svg) {
|
4181 | t1 = !cache.uncache && target.getAttribute("data-svg-origin");
|
4182 |
|
4183 | _applySVGOrigin(target, t1 || origin, !!t1 || cache.originIsAbsolute, cache.smooth !== false, matrix);
|
4184 | }
|
4185 |
|
4186 | xOrigin = cache.xOrigin || 0;
|
4187 | yOrigin = cache.yOrigin || 0;
|
4188 |
|
4189 | if (matrix !== _identity2DMatrix) {
|
4190 | a = matrix[0];
|
4191 | b = matrix[1];
|
4192 | c = matrix[2];
|
4193 | d = matrix[3];
|
4194 | x = a12 = matrix[4];
|
4195 | y = a22 = matrix[5];
|
4196 |
|
4197 | if (matrix.length === 6) {
|
4198 | scaleX = Math.sqrt(a * a + b * b);
|
4199 | scaleY = Math.sqrt(d * d + c * c);
|
4200 | rotation = a || b ? _atan2(b, a) * _RAD2DEG : 0;
|
4201 | skewX = c || d ? _atan2(c, d) * _RAD2DEG + rotation : 0;
|
4202 | skewX && (scaleY *= Math.cos(skewX * _DEG2RAD));
|
4203 |
|
4204 | if (cache.svg) {
|
4205 | x -= xOrigin - (xOrigin * a + yOrigin * c);
|
4206 | y -= yOrigin - (xOrigin * b + yOrigin * d);
|
4207 | }
|
4208 | } else {
|
4209 | a32 = matrix[6];
|
4210 | a42 = matrix[7];
|
4211 | a13 = matrix[8];
|
4212 | a23 = matrix[9];
|
4213 | a33 = matrix[10];
|
4214 | a43 = matrix[11];
|
4215 | x = matrix[12];
|
4216 | y = matrix[13];
|
4217 | z = matrix[14];
|
4218 | angle = _atan2(a32, a33);
|
4219 | rotationX = angle * _RAD2DEG;
|
4220 |
|
4221 | if (angle) {
|
4222 | cos = Math.cos(-angle);
|
4223 | sin = Math.sin(-angle);
|
4224 | t1 = a12 * cos + a13 * sin;
|
4225 | t2 = a22 * cos + a23 * sin;
|
4226 | t3 = a32 * cos + a33 * sin;
|
4227 | a13 = a12 * -sin + a13 * cos;
|
4228 | a23 = a22 * -sin + a23 * cos;
|
4229 | a33 = a32 * -sin + a33 * cos;
|
4230 | a43 = a42 * -sin + a43 * cos;
|
4231 | a12 = t1;
|
4232 | a22 = t2;
|
4233 | a32 = t3;
|
4234 | }
|
4235 |
|
4236 | angle = _atan2(-c, a33);
|
4237 | rotationY = angle * _RAD2DEG;
|
4238 |
|
4239 | if (angle) {
|
4240 | cos = Math.cos(-angle);
|
4241 | sin = Math.sin(-angle);
|
4242 | t1 = a * cos - a13 * sin;
|
4243 | t2 = b * cos - a23 * sin;
|
4244 | t3 = c * cos - a33 * sin;
|
4245 | a43 = d * sin + a43 * cos;
|
4246 | a = t1;
|
4247 | b = t2;
|
4248 | c = t3;
|
4249 | }
|
4250 |
|
4251 | angle = _atan2(b, a);
|
4252 | rotation = angle * _RAD2DEG;
|
4253 |
|
4254 | if (angle) {
|
4255 | cos = Math.cos(angle);
|
4256 | sin = Math.sin(angle);
|
4257 | t1 = a * cos + b * sin;
|
4258 | t2 = a12 * cos + a22 * sin;
|
4259 | b = b * cos - a * sin;
|
4260 | a22 = a22 * cos - a12 * sin;
|
4261 | a = t1;
|
4262 | a12 = t2;
|
4263 | }
|
4264 |
|
4265 | if (rotationX && Math.abs(rotationX) + Math.abs(rotation) > 359.9) {
|
4266 | rotationX = rotation = 0;
|
4267 | rotationY = 180 - rotationY;
|
4268 | }
|
4269 |
|
4270 | scaleX = _round(Math.sqrt(a * a + b * b + c * c));
|
4271 | scaleY = _round(Math.sqrt(a22 * a22 + a32 * a32));
|
4272 | angle = _atan2(a12, a22);
|
4273 | skewX = Math.abs(angle) > 0.0002 ? angle * _RAD2DEG : 0;
|
4274 | perspective = a43 ? 1 / (a43 < 0 ? -a43 : a43) : 0;
|
4275 | }
|
4276 |
|
4277 | if (cache.svg) {
|
4278 | t1 = target.getAttribute("transform");
|
4279 | cache.forceCSS = target.setAttribute("transform", "") || !_isNullTransform(_getComputedProperty(target, _transformProp));
|
4280 | t1 && target.setAttribute("transform", t1);
|
4281 | }
|
4282 | }
|
4283 |
|
4284 | if (Math.abs(skewX) > 90 && Math.abs(skewX) < 270) {
|
4285 | if (invertedScaleX) {
|
4286 | scaleX *= -1;
|
4287 | skewX += rotation <= 0 ? 180 : -180;
|
4288 | rotation += rotation <= 0 ? 180 : -180;
|
4289 | } else {
|
4290 | scaleY *= -1;
|
4291 | skewX += skewX <= 0 ? 180 : -180;
|
4292 | }
|
4293 | }
|
4294 |
|
4295 | cache.x = ((cache.xPercent = x && Math.round(target.offsetWidth / 2) === Math.round(-x) ? -50 : 0) ? 0 : x) + px;
|
4296 | cache.y = ((cache.yPercent = y && Math.round(target.offsetHeight / 2) === Math.round(-y) ? -50 : 0) ? 0 : y) + px;
|
4297 | cache.z = z + px;
|
4298 | cache.scaleX = _round(scaleX);
|
4299 | cache.scaleY = _round(scaleY);
|
4300 | cache.rotation = _round(rotation) + deg;
|
4301 | cache.rotationX = _round(rotationX) + deg;
|
4302 | cache.rotationY = _round(rotationY) + deg;
|
4303 | cache.skewX = skewX + deg;
|
4304 | cache.skewY = skewY + deg;
|
4305 | cache.transformPerspective = perspective + px;
|
4306 |
|
4307 | if (cache.zOrigin = parseFloat(origin.split(" ")[2]) || 0) {
|
4308 | style[_transformOriginProp] = _firstTwoOnly(origin);
|
4309 | }
|
4310 |
|
4311 | cache.xOffset = cache.yOffset = 0;
|
4312 | cache.force3D = _config.force3D;
|
4313 | cache.renderTransform = cache.svg ? _renderSVGTransforms : _supports3D ? _renderCSSTransforms : _renderNon3DTransforms;
|
4314 | cache.uncache = 0;
|
4315 | return cache;
|
4316 | },
|
4317 | _firstTwoOnly = function _firstTwoOnly(value) {
|
4318 | return (value = value.split(" "))[0] + " " + value[1];
|
4319 | },
|
4320 | _addPxTranslate = function _addPxTranslate(target, start, value) {
|
4321 | var unit = getUnit(start);
|
4322 | return _round(parseFloat(start) + parseFloat(_convertToUnit(target, "x", value + "px", unit))) + unit;
|
4323 | },
|
4324 | _renderNon3DTransforms = function _renderNon3DTransforms(ratio, cache) {
|
4325 | cache.z = "0px";
|
4326 | cache.rotationY = cache.rotationX = "0deg";
|
4327 | cache.force3D = 0;
|
4328 |
|
4329 | _renderCSSTransforms(ratio, cache);
|
4330 | },
|
4331 | _zeroDeg = "0deg",
|
4332 | _zeroPx = "0px",
|
4333 | _endParenthesis = ") ",
|
4334 | _renderCSSTransforms = function _renderCSSTransforms(ratio, cache) {
|
4335 | var _ref = cache || this,
|
4336 | xPercent = _ref.xPercent,
|
4337 | yPercent = _ref.yPercent,
|
4338 | x = _ref.x,
|
4339 | y = _ref.y,
|
4340 | z = _ref.z,
|
4341 | rotation = _ref.rotation,
|
4342 | rotationY = _ref.rotationY,
|
4343 | rotationX = _ref.rotationX,
|
4344 | skewX = _ref.skewX,
|
4345 | skewY = _ref.skewY,
|
4346 | scaleX = _ref.scaleX,
|
4347 | scaleY = _ref.scaleY,
|
4348 | transformPerspective = _ref.transformPerspective,
|
4349 | force3D = _ref.force3D,
|
4350 | target = _ref.target,
|
4351 | zOrigin = _ref.zOrigin,
|
4352 | transforms = "",
|
4353 | use3D = force3D === "auto" && ratio && ratio !== 1 || force3D === true;
|
4354 |
|
4355 | if (zOrigin && (rotationX !== _zeroDeg || rotationY !== _zeroDeg)) {
|
4356 | var angle = parseFloat(rotationY) * _DEG2RAD,
|
4357 | a13 = Math.sin(angle),
|
4358 | a33 = Math.cos(angle),
|
4359 | cos;
|
4360 |
|
4361 | angle = parseFloat(rotationX) * _DEG2RAD;
|
4362 | cos = Math.cos(angle);
|
4363 | x = _addPxTranslate(target, x, a13 * cos * -zOrigin);
|
4364 | y = _addPxTranslate(target, y, -Math.sin(angle) * -zOrigin);
|
4365 | z = _addPxTranslate(target, z, a33 * cos * -zOrigin + zOrigin);
|
4366 | }
|
4367 |
|
4368 | if (transformPerspective !== _zeroPx) {
|
4369 | transforms += "perspective(" + transformPerspective + _endParenthesis;
|
4370 | }
|
4371 |
|
4372 | if (xPercent || yPercent) {
|
4373 | transforms += "translate(" + xPercent + "%, " + yPercent + "%) ";
|
4374 | }
|
4375 |
|
4376 | if (use3D || x !== _zeroPx || y !== _zeroPx || z !== _zeroPx) {
|
4377 | transforms += z !== _zeroPx || use3D ? "translate3d(" + x + ", " + y + ", " + z + ") " : "translate(" + x + ", " + y + _endParenthesis;
|
4378 | }
|
4379 |
|
4380 | if (rotation !== _zeroDeg) {
|
4381 | transforms += "rotate(" + rotation + _endParenthesis;
|
4382 | }
|
4383 |
|
4384 | if (rotationY !== _zeroDeg) {
|
4385 | transforms += "rotateY(" + rotationY + _endParenthesis;
|
4386 | }
|
4387 |
|
4388 | if (rotationX !== _zeroDeg) {
|
4389 | transforms += "rotateX(" + rotationX + _endParenthesis;
|
4390 | }
|
4391 |
|
4392 | if (skewX !== _zeroDeg || skewY !== _zeroDeg) {
|
4393 | transforms += "skew(" + skewX + ", " + skewY + _endParenthesis;
|
4394 | }
|
4395 |
|
4396 | if (scaleX !== 1 || scaleY !== 1) {
|
4397 | transforms += "scale(" + scaleX + ", " + scaleY + _endParenthesis;
|
4398 | }
|
4399 |
|
4400 | target.style[_transformProp] = transforms || "translate(0, 0)";
|
4401 | },
|
4402 | _renderSVGTransforms = function _renderSVGTransforms(ratio, cache) {
|
4403 | var _ref2 = cache || this,
|
4404 | xPercent = _ref2.xPercent,
|
4405 | yPercent = _ref2.yPercent,
|
4406 | x = _ref2.x,
|
4407 | y = _ref2.y,
|
4408 | rotation = _ref2.rotation,
|
4409 | skewX = _ref2.skewX,
|
4410 | skewY = _ref2.skewY,
|
4411 | scaleX = _ref2.scaleX,
|
4412 | scaleY = _ref2.scaleY,
|
4413 | target = _ref2.target,
|
4414 | xOrigin = _ref2.xOrigin,
|
4415 | yOrigin = _ref2.yOrigin,
|
4416 | xOffset = _ref2.xOffset,
|
4417 | yOffset = _ref2.yOffset,
|
4418 | forceCSS = _ref2.forceCSS,
|
4419 | tx = parseFloat(x),
|
4420 | ty = parseFloat(y),
|
4421 | a11,
|
4422 | a21,
|
4423 | a12,
|
4424 | a22,
|
4425 | temp;
|
4426 |
|
4427 | rotation = parseFloat(rotation);
|
4428 | skewX = parseFloat(skewX);
|
4429 | skewY = parseFloat(skewY);
|
4430 |
|
4431 | if (skewY) {
|
4432 | skewY = parseFloat(skewY);
|
4433 | skewX += skewY;
|
4434 | rotation += skewY;
|
4435 | }
|
4436 |
|
4437 | if (rotation || skewX) {
|
4438 | rotation *= _DEG2RAD;
|
4439 | skewX *= _DEG2RAD;
|
4440 | a11 = Math.cos(rotation) * scaleX;
|
4441 | a21 = Math.sin(rotation) * scaleX;
|
4442 | a12 = Math.sin(rotation - skewX) * -scaleY;
|
4443 | a22 = Math.cos(rotation - skewX) * scaleY;
|
4444 |
|
4445 | if (skewX) {
|
4446 | skewY *= _DEG2RAD;
|
4447 | temp = Math.tan(skewX - skewY);
|
4448 | temp = Math.sqrt(1 + temp * temp);
|
4449 | a12 *= temp;
|
4450 | a22 *= temp;
|
4451 |
|
4452 | if (skewY) {
|
4453 | temp = Math.tan(skewY);
|
4454 | temp = Math.sqrt(1 + temp * temp);
|
4455 | a11 *= temp;
|
4456 | a21 *= temp;
|
4457 | }
|
4458 | }
|
4459 |
|
4460 | a11 = _round(a11);
|
4461 | a21 = _round(a21);
|
4462 | a12 = _round(a12);
|
4463 | a22 = _round(a22);
|
4464 | } else {
|
4465 | a11 = scaleX;
|
4466 | a22 = scaleY;
|
4467 | a21 = a12 = 0;
|
4468 | }
|
4469 |
|
4470 | if (tx && !~(x + "").indexOf("px") || ty && !~(y + "").indexOf("px")) {
|
4471 | tx = _convertToUnit(target, "x", x, "px");
|
4472 | ty = _convertToUnit(target, "y", y, "px");
|
4473 | }
|
4474 |
|
4475 | if (xOrigin || yOrigin || xOffset || yOffset) {
|
4476 | tx = _round(tx + xOrigin - (xOrigin * a11 + yOrigin * a12) + xOffset);
|
4477 | ty = _round(ty + yOrigin - (xOrigin * a21 + yOrigin * a22) + yOffset);
|
4478 | }
|
4479 |
|
4480 | if (xPercent || yPercent) {
|
4481 | temp = target.getBBox();
|
4482 | tx = _round(tx + xPercent / 100 * temp.width);
|
4483 | ty = _round(ty + yPercent / 100 * temp.height);
|
4484 | }
|
4485 |
|
4486 | temp = "matrix(" + a11 + "," + a21 + "," + a12 + "," + a22 + "," + tx + "," + ty + ")";
|
4487 | target.setAttribute("transform", temp);
|
4488 |
|
4489 | if (forceCSS) {
|
4490 | target.style[_transformProp] = temp;
|
4491 | }
|
4492 | },
|
4493 | _addRotationalPropTween = function _addRotationalPropTween(plugin, target, property, startNum, endValue, relative) {
|
4494 | var cap = 360,
|
4495 | isString = _isString(endValue),
|
4496 | endNum = parseFloat(endValue) * (isString && ~endValue.indexOf("rad") ? _RAD2DEG : 1),
|
4497 | change = relative ? endNum * relative : endNum - startNum,
|
4498 | finalValue = startNum + change + "deg",
|
4499 | direction,
|
4500 | pt;
|
4501 |
|
4502 | if (isString) {
|
4503 | direction = endValue.split("_")[1];
|
4504 |
|
4505 | if (direction === "short") {
|
4506 | change %= cap;
|
4507 |
|
4508 | if (change !== change % (cap / 2)) {
|
4509 | change += change < 0 ? cap : -cap;
|
4510 | }
|
4511 | }
|
4512 |
|
4513 | if (direction === "cw" && change < 0) {
|
4514 | change = (change + cap * _bigNum$1) % cap - ~~(change / cap) * cap;
|
4515 | } else if (direction === "ccw" && change > 0) {
|
4516 | change = (change - cap * _bigNum$1) % cap - ~~(change / cap) * cap;
|
4517 | }
|
4518 | }
|
4519 |
|
4520 | plugin._pt = pt = new PropTween(plugin._pt, target, property, startNum, change, _renderPropWithEnd);
|
4521 | pt.e = finalValue;
|
4522 | pt.u = "deg";
|
4523 |
|
4524 | plugin._props.push(property);
|
4525 |
|
4526 | return pt;
|
4527 | },
|
4528 | _addRawTransformPTs = function _addRawTransformPTs(plugin, transforms, target) {
|
4529 | var style = _tempDivStyler.style,
|
4530 | startCache = target._gsap,
|
4531 | exclude = "perspective,force3D,transformOrigin,svgOrigin",
|
4532 | endCache,
|
4533 | p,
|
4534 | startValue,
|
4535 | endValue,
|
4536 | startNum,
|
4537 | endNum,
|
4538 | startUnit,
|
4539 | endUnit;
|
4540 | style.cssText = getComputedStyle(target).cssText + ";position:absolute;display:block;";
|
4541 | style[_transformProp] = transforms;
|
4542 |
|
4543 | _doc$1.body.appendChild(_tempDivStyler);
|
4544 |
|
4545 | endCache = _parseTransform(_tempDivStyler, 1);
|
4546 |
|
4547 | for (p in _transformProps) {
|
4548 | startValue = startCache[p];
|
4549 | endValue = endCache[p];
|
4550 |
|
4551 | if (startValue !== endValue && exclude.indexOf(p) < 0) {
|
4552 | startUnit = getUnit(startValue);
|
4553 | endUnit = getUnit(endValue);
|
4554 | startNum = startUnit !== endUnit ? _convertToUnit(target, p, startValue, endUnit) : parseFloat(startValue);
|
4555 | endNum = parseFloat(endValue);
|
4556 | plugin._pt = new PropTween(plugin._pt, startCache, p, startNum, endNum - startNum, _renderCSSProp);
|
4557 | plugin._pt.u = endUnit || 0;
|
4558 |
|
4559 | plugin._props.push(p);
|
4560 | }
|
4561 | }
|
4562 |
|
4563 | _doc$1.body.removeChild(_tempDivStyler);
|
4564 | };
|
4565 |
|
4566 | _forEachName("padding,margin,Width,Radius", function (name, index) {
|
4567 | var t = "Top",
|
4568 | r = "Right",
|
4569 | b = "Bottom",
|
4570 | l = "Left",
|
4571 | props = (index < 3 ? [t, r, b, l] : [t + l, t + r, b + r, b + l]).map(function (side) {
|
4572 | return index < 2 ? name + side : "border" + side + name;
|
4573 | });
|
4574 |
|
4575 | _specialProps[index > 1 ? "border" + name : name] = function (plugin, target, property, endValue, tween) {
|
4576 | var a, vars;
|
4577 |
|
4578 | if (arguments.length < 4) {
|
4579 | a = props.map(function (prop) {
|
4580 | return _get(plugin, prop, property);
|
4581 | });
|
4582 | vars = a.join(" ");
|
4583 | return vars.split(a[0]).length === 5 ? a[0] : vars;
|
4584 | }
|
4585 |
|
4586 | a = (endValue + "").split(" ");
|
4587 | vars = {};
|
4588 | props.forEach(function (prop, i) {
|
4589 | return vars[prop] = a[i] = a[i] || a[(i - 1) / 2 | 0];
|
4590 | });
|
4591 | plugin.init(target, vars, tween);
|
4592 | };
|
4593 | });
|
4594 |
|
4595 | var CSSPlugin = {
|
4596 | name: "css",
|
4597 | register: _initCore,
|
4598 | targetTest: function targetTest(target) {
|
4599 | return target.style && target.nodeType;
|
4600 | },
|
4601 | init: function init(target, vars, tween, index, targets) {
|
4602 | var props = this._props,
|
4603 | style = target.style,
|
4604 | startValue,
|
4605 | endValue,
|
4606 | endNum,
|
4607 | startNum,
|
4608 | type,
|
4609 | specialProp,
|
4610 | p,
|
4611 | startUnit,
|
4612 | endUnit,
|
4613 | relative,
|
4614 | isTransformRelated,
|
4615 | transformPropTween,
|
4616 | cache,
|
4617 | smooth,
|
4618 | hasPriority;
|
4619 | _pluginInitted || _initCore();
|
4620 |
|
4621 | for (p in vars) {
|
4622 | if (p === "autoRound") {
|
4623 | continue;
|
4624 | }
|
4625 |
|
4626 | endValue = vars[p];
|
4627 |
|
4628 | if (_plugins[p] && _checkPlugin(p, vars, tween, index, target, targets)) {
|
4629 | continue;
|
4630 | }
|
4631 |
|
4632 | type = typeof endValue;
|
4633 | specialProp = _specialProps[p];
|
4634 |
|
4635 | if (type === "function") {
|
4636 | endValue = endValue.call(tween, index, target, targets);
|
4637 | type = typeof endValue;
|
4638 | }
|
4639 |
|
4640 | if (type === "string" && ~endValue.indexOf("random(")) {
|
4641 | endValue = _replaceRandom(endValue);
|
4642 | }
|
4643 |
|
4644 | if (specialProp) {
|
4645 | if (specialProp(this, target, p, endValue, tween)) {
|
4646 | hasPriority = 1;
|
4647 | }
|
4648 | } else if (p.substr(0, 2) === "--") {
|
4649 | this.add(style, "setProperty", getComputedStyle(target).getPropertyValue(p) + "", endValue + "", index, targets, 0, 0, p);
|
4650 | } else if (type !== "undefined") {
|
4651 | startValue = _get(target, p);
|
4652 | startNum = parseFloat(startValue);
|
4653 | relative = type === "string" && endValue.charAt(1) === "=" ? +(endValue.charAt(0) + "1") : 0;
|
4654 |
|
4655 | if (relative) {
|
4656 | endValue = endValue.substr(2);
|
4657 | }
|
4658 |
|
4659 | endNum = parseFloat(endValue);
|
4660 |
|
4661 | if (p in _propertyAliases) {
|
4662 | if (p === "autoAlpha") {
|
4663 | if (startNum === 1 && _get(target, "visibility") === "hidden" && endNum) {
|
4664 | startNum = 0;
|
4665 | }
|
4666 |
|
4667 | _addNonTweeningPT(this, style, "visibility", startNum ? "inherit" : "hidden", endNum ? "inherit" : "hidden", !endNum);
|
4668 | }
|
4669 |
|
4670 | if (p !== "scale" && p !== "transform") {
|
4671 | p = _propertyAliases[p];
|
4672 | ~p.indexOf(",") && (p = p.split(",")[0]);
|
4673 | }
|
4674 | }
|
4675 |
|
4676 | isTransformRelated = p in _transformProps;
|
4677 |
|
4678 | if (isTransformRelated) {
|
4679 | if (!transformPropTween) {
|
4680 | cache = target._gsap;
|
4681 | cache.renderTransform || _parseTransform(target);
|
4682 | smooth = vars.smoothOrigin !== false && cache.smooth;
|
4683 | transformPropTween = this._pt = new PropTween(this._pt, style, _transformProp, 0, 1, cache.renderTransform, cache, 0, -1);
|
4684 | transformPropTween.dep = 1;
|
4685 | }
|
4686 |
|
4687 | if (p === "scale") {
|
4688 | this._pt = new PropTween(this._pt, cache, "scaleY", cache.scaleY, relative ? relative * endNum : endNum - cache.scaleY);
|
4689 | props.push("scaleY", p);
|
4690 | p += "X";
|
4691 | } else if (p === "transformOrigin") {
|
4692 | endValue = _convertKeywordsToPercentages(endValue);
|
4693 |
|
4694 | if (cache.svg) {
|
4695 | _applySVGOrigin(target, endValue, 0, smooth, 0, this);
|
4696 | } else {
|
4697 | endUnit = parseFloat(endValue.split(" ")[2]) || 0;
|
4698 | endUnit !== cache.zOrigin && _addNonTweeningPT(this, cache, "zOrigin", cache.zOrigin, endUnit);
|
4699 |
|
4700 | _addNonTweeningPT(this, style, p, _firstTwoOnly(startValue), _firstTwoOnly(endValue));
|
4701 | }
|
4702 |
|
4703 | continue;
|
4704 | } else if (p === "svgOrigin") {
|
4705 | _applySVGOrigin(target, endValue, 1, smooth, 0, this);
|
4706 |
|
4707 | continue;
|
4708 | } else if (p in _rotationalProperties) {
|
4709 | _addRotationalPropTween(this, cache, p, startNum, endValue, relative);
|
4710 |
|
4711 | continue;
|
4712 | } else if (p === "smoothOrigin") {
|
4713 | _addNonTweeningPT(this, cache, "smooth", cache.smooth, endValue);
|
4714 |
|
4715 | continue;
|
4716 | } else if (p === "force3D") {
|
4717 | cache[p] = endValue;
|
4718 | continue;
|
4719 | } else if (p === "transform") {
|
4720 | _addRawTransformPTs(this, endValue, target);
|
4721 |
|
4722 | continue;
|
4723 | }
|
4724 | } else if (!(p in style)) {
|
4725 | p = _checkPropPrefix(p) || p;
|
4726 | }
|
4727 |
|
4728 | if (isTransformRelated || (endNum || endNum === 0) && (startNum || startNum === 0) && !_complexExp.test(endValue) && p in style) {
|
4729 | startUnit = (startValue + "").substr((startNum + "").length);
|
4730 | endNum || (endNum = 0);
|
4731 | endUnit = getUnit(endValue) || (p in _config.units ? _config.units[p] : startUnit);
|
4732 | startUnit !== endUnit && (startNum = _convertToUnit(target, p, startValue, endUnit));
|
4733 | this._pt = new PropTween(this._pt, isTransformRelated ? cache : style, p, startNum, relative ? relative * endNum : endNum - startNum, endUnit === "px" && vars.autoRound !== false && !isTransformRelated ? _renderRoundedCSSProp : _renderCSSProp);
|
4734 | this._pt.u = endUnit || 0;
|
4735 |
|
4736 | if (startUnit !== endUnit) {
|
4737 | this._pt.b = startValue;
|
4738 | this._pt.r = _renderCSSPropWithBeginning;
|
4739 | }
|
4740 | } else if (!(p in style)) {
|
4741 | if (p in target) {
|
4742 | this.add(target, p, target[p], endValue, index, targets);
|
4743 | } else {
|
4744 | _missingPlugin(p, endValue);
|
4745 |
|
4746 | continue;
|
4747 | }
|
4748 | } else {
|
4749 | _tweenComplexCSSString.call(this, target, p, startValue, endValue);
|
4750 | }
|
4751 |
|
4752 | props.push(p);
|
4753 | }
|
4754 | }
|
4755 |
|
4756 | hasPriority && _sortPropTweensByPriority(this);
|
4757 | },
|
4758 | get: _get,
|
4759 | aliases: _propertyAliases,
|
4760 | getSetter: function getSetter(target, property, plugin) {
|
4761 | var p = _propertyAliases[property];
|
4762 | p && p.indexOf(",") < 0 && (property = p);
|
4763 | return property in _transformProps && property !== _transformOriginProp && (target._gsap.x || _get(target, "x")) ? plugin && _recentSetterPlugin === plugin ? property === "scale" ? _setterScale : _setterTransform : (_recentSetterPlugin = plugin || {}) && (property === "scale" ? _setterScaleWithRender : _setterTransformWithRender) : target.style && !_isUndefined(target.style[property]) ? _setterCSSStyle : ~property.indexOf("-") ? _setterCSSProp : _getSetter(target, property);
|
4764 | },
|
4765 | core: {
|
4766 | _removeProperty: _removeProperty,
|
4767 | _getMatrix: _getMatrix
|
4768 | }
|
4769 | };
|
4770 | gsap.utils.checkPrefix = _checkPropPrefix;
|
4771 |
|
4772 | (function (positionAndScale, rotation, others, aliases) {
|
4773 | var all = _forEachName(positionAndScale + "," + rotation + "," + others, function (name) {
|
4774 | _transformProps[name] = 1;
|
4775 | });
|
4776 |
|
4777 | _forEachName(rotation, function (name) {
|
4778 | _config.units[name] = "deg";
|
4779 | _rotationalProperties[name] = 1;
|
4780 | });
|
4781 |
|
4782 | _propertyAliases[all[13]] = positionAndScale + "," + rotation;
|
4783 |
|
4784 | _forEachName(aliases, function (name) {
|
4785 | var split = name.split(":");
|
4786 | _propertyAliases[split[1]] = all[split[0]];
|
4787 | });
|
4788 | })("x,y,z,scale,scaleX,scaleY,xPercent,yPercent", "rotation,rotationX,rotationY,skewX,skewY", "transform,transformOrigin,svgOrigin,force3D,smoothOrigin,transformPerspective", "0:translateX,1:translateY,2:translateZ,8:rotate,8:rotationZ,8:rotateZ,9:rotateX,10:rotateY");
|
4789 |
|
4790 | _forEachName("x,y,z,top,right,bottom,left,width,height,fontSize,padding,margin,perspective", function (name) {
|
4791 | _config.units[name] = "px";
|
4792 | });
|
4793 |
|
4794 | gsap.registerPlugin(CSSPlugin);
|
4795 |
|
4796 | var gsapWithCSS = gsap.registerPlugin(CSSPlugin) || gsap,
|
4797 | TweenMaxWithCSS = gsapWithCSS.core.Tween;
|
4798 |
|
4799 | exports.Back = Back;
|
4800 | exports.Bounce = Bounce;
|
4801 | exports.CSSPlugin = CSSPlugin;
|
4802 | exports.Circ = Circ;
|
4803 | exports.Cubic = Cubic;
|
4804 | exports.Elastic = Elastic;
|
4805 | exports.Expo = Expo;
|
4806 | exports.Linear = Linear;
|
4807 | exports.Power0 = Power0;
|
4808 | exports.Power1 = Power1;
|
4809 | exports.Power2 = Power2;
|
4810 | exports.Power3 = Power3;
|
4811 | exports.Power4 = Power4;
|
4812 | exports.Quad = Quad;
|
4813 | exports.Quart = Quart;
|
4814 | exports.Quint = Quint;
|
4815 | exports.Sine = Sine;
|
4816 | exports.SteppedEase = SteppedEase;
|
4817 | exports.Strong = Strong;
|
4818 | exports.TimelineLite = Timeline;
|
4819 | exports.TimelineMax = Timeline;
|
4820 | exports.TweenLite = Tween;
|
4821 | exports.TweenMax = TweenMaxWithCSS;
|
4822 | exports.default = gsapWithCSS;
|
4823 | exports.gsap = gsapWithCSS;
|
4824 |
|
4825 | if (typeof(window) === 'undefined' || window !== exports) {Object.defineProperty(exports, '__esModule', { value: true });} else {delete window.default;}
|
4826 |
|
4827 | })));
|