Added mousewheel support for PixiJS Lists.

This commit is contained in:
Sebastian Kupke 2019-03-29 11:40:01 +01:00
parent 6c2ae3b433
commit 1292fd23f0
116 changed files with 55687 additions and 6 deletions

50
dist/iwmlib.pixi.js vendored
View File

@ -13690,6 +13690,8 @@
* left, center and right. * left, center and right.
* @param {string} [opts.verticalAlign=middle] - The vertical position of the items. Possible values are * @param {string} [opts.verticalAlign=middle] - The vertical position of the items. Possible values are
* top, middle and bottom. * top, middle and bottom.
* @param {PIXI.Application} [opts.app] - The PixiJS Application. Must be set if you want to use the mousewheel to
* scroll your list.
*/ */
constructor(items = [], opts = {}) { constructor(items = [], opts = {}) {
@ -13702,7 +13704,8 @@
align: 'left', align: 'left',
verticalAlign: 'middle', verticalAlign: 'middle',
width: null, width: null,
height: null height: null,
app: null
}, opts); }, opts);
this.__items = items; this.__items = items;
@ -13748,6 +13751,22 @@
this.on('pointercancel', this.onEnd.bind(this)); this.on('pointercancel', this.onEnd.bind(this));
this.on('pointerout', this.onEnd.bind(this)); this.on('pointerout', this.onEnd.bind(this));
this.on('pointerupoutside', this.onEnd.bind(this)); this.on('pointerupoutside', this.onEnd.bind(this));
this.on('scroll', this.onScroll.bind(this));
// mousewheel
//--------------------
if (this.opts.app) {
const app = this.opts.app;
app.view.addEventListener('mousewheel', event => {
event.preventDefault();
const bounds = this.mask ? this.mask.getBounds() : this.getBounds();
const x = event.clientX - app.view.getBoundingClientRect().left;
const y = event.clientY - app.view.getBoundingClientRect().top;
if (bounds.contains(x, y)) {
this.emit('scroll', event);
}
});
}
this.layout(); this.layout();
@ -13975,13 +13994,40 @@
} }
} }
/**
*
* @private
* @param {*} event
*/
onScroll(event) {
this.capture(event);
if (this.opts.orientation === 'horizontal') {
this.container.position.x -= event.deltaX;
if (this.container.position.x > 0) {
this.container.position.x = 0;
} else if (this.container.position.x + this.innerWidth < this.opts.width) {
this.container.position.x = this.opts.width - this.innerWidth;
}
} else {
this.container.position.y -= event.deltaY;
if (this.container.position.y > 0) {
this.container.position.y = 0;
} else if (this.container.position.y + this.innerHeight < this.opts.height) {
this.container.position.y = this.opts.height - this.innerHeight;
}
}
}
/** /**
* Captures an event to inform InteractionMapper about processed events. * Captures an event to inform InteractionMapper about processed events.
* *
* @param {event|PIXI.InteractionEvent} event - The PIXI event to capture. * @param {event|PIXI.InteractionEvent} event - The PIXI event to capture.
*/ */
capture(event) { capture(event) {
Events$1.capturedBy(event.data.originalEvent, this); const originalEvent = event.data && event.data.originalEvent ? event.data.originalEvent : event;
Events$1.capturedBy(originalEvent, this);
} }
} }

10
lib/3rdparty/gsap/docs.html vendored Executable file
View File

@ -0,0 +1,10 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="refresh" content="0;URL=https://greensock.com/docs/" />
<title>JavaScript Documentation</title>
</head>
<body>
</body>
</html>

11
lib/3rdparty/gsap/getting_started.html vendored Executable file
View File

@ -0,0 +1,11 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="REFRESH" content="0;url=https://greensock.com/get-started-js/">
<title>Getting Started with the JavaScript Version of the GreenSock Animation Platform</title>
</head>
<body bgcolor="#EFEFEF" text="#333333" link="#71b200" leftmargin="20" topmargin="20" marginwidth="20" marginheight="20">
<div>REDIRECTING...</div>
<a href="https://greensock.com/get-started-js/">View the most recent "getting started" guide at greensock.com</a>
</body>
</html>

View File

@ -0,0 +1,152 @@
/*!
* VERSION: 0.2.1
* DATE: 2018-08-27
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
/* eslint-disable */
import { _gsScope, globals } from "gsap/TweenLite.js";
import CustomEase from "./CustomEase.js";
_gsScope._gsDefine("easing.CustomBounce", ["easing.CustomEase"], function() {
var _normalizeX = function (a) { //scales all the x values in an array [x, y, x, y...] AND rounds them to the closest hundredth (decimal)
var l = a.length,
s = 1 / a[l - 2],
rnd = 1000,
i;
for (i = 2; i < l; i += 2) {
a[i] = ((a[i] * s * rnd) | 0) / rnd;
}
a[l - 2] = 1; //in case there are any rounding errors. x should always end at 1.
},
CustomBounce = function(id, vars) {
this.vars = vars = vars || {};
if (vars.squash) {
this.squash = new CustomEase(vars.squashID || (id + "-squash"));
}
CustomEase.call(this, id);
this.bounce = this;
this.update(vars);
},
p;
CustomBounce.prototype = p = new CustomEase();
p.constructor = CustomBounce;
p.update = function(vars) {
vars = vars || this.vars;
var max = 0.999,
decay = Math.min(max, vars.strength || 0.7), // Math.min(0.999, 1 - 0.3 / (vars.strength || 1)),
decayX = decay,
gap = (vars.squash || 0) / 100,
originalGap = gap,
slope = 1 / 0.03,
w = 0.2,
h = 1,
prevX = 0.1,
path = [0, 0, 0.07, 0, 0.1, 1, 0.1, 1],
squashPath = [0, 0, 0, 0, 0.1, 0, 0.1, 0],
cp1, cp2, x, y, i, nextX, squishMagnitude;
for (i = 0; i < 200; i++) {
w *= decayX * ((decayX + 1) / 2);
h *= decay * decay;
nextX = prevX + w;
x = prevX + w * 0.49;
y = 1 - h;
cp1 = prevX + h / slope;
cp2 = x + (x - cp1) * 0.8;
if (gap) {
prevX += gap;
cp1 += gap;
x += gap;
cp2 += gap;
nextX += gap;
squishMagnitude = gap / originalGap;
squashPath.push(
prevX - gap, 0,
prevX - gap, squishMagnitude,
prevX - gap / 2, squishMagnitude, //center peak anchor
prevX, squishMagnitude,
prevX, 0,
prevX, 0, //base anchor
prevX, squishMagnitude * -0.6,
prevX + (nextX - prevX) / 6, 0,
nextX, 0
);
path.push(prevX - gap, 1,
prevX, 1,
prevX, 1);
gap *= decay * decay;
}
path.push(prevX, 1,
cp1, y,
x, y,
cp2, y,
nextX, 1,
nextX, 1);
decay *= 0.95;
slope = h / (nextX - cp2);
prevX = nextX;
if (y > max) {
break;
}
}
if (vars.endAtStart) {
x = -0.1;
path.unshift(x, 1, x, 1, -0.07, 0);
if (originalGap) {
gap = originalGap * 2.5; //make the initial anticipation squash longer (more realistic)
x -= gap;
path.unshift(x, 1, x, 1, x, 1);
squashPath.splice(0, 6);
squashPath.unshift(x, 0, x, 0, x, 1, x + gap / 2, 1, x + gap, 1, x + gap, 0, x + gap, 0, x + gap, -0.6, x + gap + 0.033, 0);
for (i = 0; i < squashPath.length; i+=2) {
squashPath[i] -= x;
}
}
for (i = 0; i < path.length; i+=2) {
path[i] -= x;
path[i+1] = 1 - path[i+1];
}
}
if (gap) {
_normalizeX(squashPath);
squashPath[2] = "C" + squashPath[2];
if (!this.squash) {
this.squash = new CustomEase(vars.squashID || (this.id + "-squash"));
}
this.squash.setData("M" + squashPath.join(","));
}
_normalizeX(path);
path[2] = "C" + path[2];
return this.setData("M" + path.join(","));
};
CustomBounce.create = function(id, vars) {
return new CustomBounce(id, vars);
};
CustomBounce.version = "0.2.1";
return CustomBounce;
}, true);
export var CustomBounce = globals.CustomBounce;
export { CustomBounce as default };

View File

@ -0,0 +1,379 @@
/*!
* VERSION: 0.2.2
* DATE: 2018-08-27
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
/* eslint-disable */
import { _gsScope, globals, Ease } from "gsap/TweenLite.js";
_gsScope._gsDefine("easing.CustomEase", ["easing.Ease"], function() {
var _numbersExp = /(?:(-|-=|\+=)?\d*\.?\d*(?:e[\-+]?\d+)?)[0-9]/ig,
_svgPathExp = /[achlmqstvz]|(-?\d*\.?\d*(?:e[\-+]?\d+)?)[0-9]/ig,
_scientific = /[\+\-]?\d*\.?\d+e[\+\-]?\d+/ig,
_needsParsingExp = /[cLlsS]/g,
_bezierError = "CustomEase only accepts Cubic Bezier data.",
_bezierToPoints = function (x1, y1, x2, y2, x3, y3, x4, y4, threshold, points, index) {
var x12 = (x1 + x2) / 2,
y12 = (y1 + y2) / 2,
x23 = (x2 + x3) / 2,
y23 = (y2 + y3) / 2,
x34 = (x3 + x4) / 2,
y34 = (y3 + y4) / 2,
x123 = (x12 + x23) / 2,
y123 = (y12 + y23) / 2,
x234 = (x23 + x34) / 2,
y234 = (y23 + y34) / 2,
x1234 = (x123 + x234) / 2,
y1234 = (y123 + y234) / 2,
dx = x4 - x1,
dy = y4 - y1,
d2 = Math.abs((x2 - x4) * dy - (y2 - y4) * dx),
d3 = Math.abs((x3 - x4) * dy - (y3 - y4) * dx),
length;
if (!points) {
points = [{x: x1, y: y1}, {x: x4, y: y4}];
index = 1;
}
points.splice(index || points.length - 1, 0, {x: x1234, y: y1234});
if ((d2 + d3) * (d2 + d3) > threshold * (dx * dx + dy * dy)) {
length = points.length;
_bezierToPoints(x1, y1, x12, y12, x123, y123, x1234, y1234, threshold, points, index);
_bezierToPoints(x1234, y1234, x234, y234, x34, y34, x4, y4, threshold, points, index + 1 + (points.length - length));
}
return points;
},
_pathDataToBezier = function (d) {
var a = (d + "").replace(_scientific, function (m) {
var n = +m;
return (n < 0.0001 && n > -0.0001) ? 0 : n;
}).match(_svgPathExp) || [], //some authoring programs spit out very small numbers in scientific notation like "1e-5", so make sure we round that down to 0 first.
path = [],
relativeX = 0,
relativeY = 0,
elements = a.length,
l = 2,
i, x, y, command, isRelative, segment, startX, startY, prevCommand, difX, difY;
for (i = 0; i < elements; i++) {
prevCommand = command;
if (isNaN(a[i])) {
command = a[i].toUpperCase();
isRelative = (command !== a[i]); //lower case means relative
} else { //commands like "C" can be strung together without any new command characters between.
i--;
}
x = +a[i + 1];
y = +a[i + 2];
if (isRelative) {
x += relativeX;
y += relativeY;
}
if (!i) {
startX = x;
startY = y;
}
if (command === "M") {
if (segment && segment.length < 8) { //if the path data was funky and just had a M with no actual drawing anywhere, skip it.
path.length -= 1;
l = 0;
}
relativeX = startX = x;
relativeY = startY = y;
segment = [x, y];
l = 2;
path.push(segment);
i += 2;
command = "L"; //an "M" with more than 2 values gets interpreted as "lineTo" commands ("L").
} else if (command === "C") {
if (!segment) {
segment = [0, 0];
}
segment[l++] = x;
segment[l++] = y;
if (!isRelative) {
relativeX = relativeY = 0;
}
segment[l++] = relativeX + a[i + 3] * 1; //note: "*1" is just a fast/short way to cast the value as a Number. WAAAY faster in Chrome, slightly slower in Firefox.
segment[l++] = relativeY + a[i + 4] * 1;
segment[l++] = relativeX = relativeX + a[i + 5] * 1;
segment[l++] = relativeY = relativeY + a[i + 6] * 1;
i += 6;
} else if (command === "S") {
if (prevCommand === "C" || prevCommand === "S") {
difX = relativeX - segment[l - 4];
difY = relativeY - segment[l - 3];
segment[l++] = relativeX + difX;
segment[l++] = relativeY + difY;
} else {
segment[l++] = relativeX;
segment[l++] = relativeY;
}
segment[l++] = x;
segment[l++] = y;
if (!isRelative) {
relativeX = relativeY = 0;
}
segment[l++] = relativeX = relativeX + a[i + 3] * 1;
segment[l++] = relativeY = relativeY + a[i + 4] * 1;
i += 4;
} else if (command === "L" || command === "Z") {
if (command === "Z") {
x = startX;
y = startY;
segment.closed = true;
}
if (command === "L" || Math.abs(relativeX - x) > 0.5 || Math.abs(relativeY - y) > 0.5) {
segment[l++] = relativeX + (x - relativeX) / 3;
segment[l++] = relativeY + (y - relativeY) / 3;
segment[l++] = relativeX + (x - relativeX) * 2 / 3;
segment[l++] = relativeY + (y - relativeY) * 2 / 3;
segment[l++] = x;
segment[l++] = y;
if (command === "L") {
i += 2;
}
}
relativeX = x;
relativeY = y;
} else {
throw _bezierError;
}
}
return path[0];
},
_findMinimum = function (values) {
var l = values.length,
min = 999999999999,
i;
for (i = 1; i < l; i += 6) {
if (+values[i] < min) {
min = +values[i];
}
}
return min;
},
_normalize = function (values, height, originY) { //takes all the points and translates/scales them so that the x starts at 0 and ends at 1.
if (!originY && originY !== 0) {
originY = Math.max(+values[values.length-1], +values[1]);
}
var tx = +values[0] * -1,
ty = -originY,
l = values.length,
sx = 1 / (+values[l - 2] + tx),
sy = -height || ((Math.abs(+values[l - 1] - +values[1]) < 0.01 * (+values[l - 2] - +values[0])) ? _findMinimum(values) + ty : +values[l - 1] + ty),
i;
if (sy) { //typically y ends at 1 (so that the end values are reached)
sy = 1 / sy;
} else { //in case the ease returns to its beginning value, scale everything proportionally
sy = -sx;
}
for (i = 0; i < l; i += 2) {
values[i] = (+values[i] + tx) * sx;
values[i + 1] = (+values[i + 1] + ty) * sy;
}
},
_getRatio = function (p) {
var point = this.lookup[(p * this.l) | 0] || this.lookup[this.l - 1];
if (point.nx < p) {
point = point.n;
}
return point.y + ((p - point.x) / point.cx) * point.cy;
},
CustomEase = function (id, data, config) {
this._calcEnd = true;
this.id = id;
if (id) {
Ease.map[id] = this;
}
this.getRatio = _getRatio; //speed optimization, faster lookups.
this.setData(data, config);
},
p = CustomEase.prototype = new Ease();
p.constructor = CustomEase;
p.setData = function(data, config) {
data = data || "0,0,1,1";
var values = data.match(_numbersExp),
closest = 1,
points = [],
l, a1, a2, i, inc, j, point, prevPoint, p, precision;
config = config || {};
precision = config.precision || 1;
this.data = data;
this.lookup = [];
this.points = points;
this.fast = (precision <= 1);
if (_needsParsingExp.test(data) || (data.indexOf("M") !== -1 && data.indexOf("C") === -1)) {
values = _pathDataToBezier(data);
}
l = values.length;
if (l === 4) {
values.unshift(0, 0);
values.push(1, 1);
l = 8;
} else if ((l - 2) % 6) {
throw _bezierError;
}
if (+values[0] !== 0 || +values[l - 2] !== 1) {
_normalize(values, config.height, config.originY);
}
this.rawBezier = values;
for (i = 2; i < l; i += 6) {
a1 = {x: +values[i - 2], y: +values[i - 1]};
a2 = {x: +values[i + 4], y: +values[i + 5]};
points.push(a1, a2);
_bezierToPoints(a1.x, a1.y, +values[i], +values[i + 1], +values[i + 2], +values[i + 3], a2.x, a2.y, 1 / (precision * 200000), points, points.length - 1);
}
l = points.length;
for (i = 0; i < l; i++) {
point = points[i];
prevPoint = points[i - 1] || point;
if (point.x > prevPoint.x || (prevPoint.y !== point.y && prevPoint.x === point.x) || point === prevPoint) { //if a point goes BACKWARD in time or is a duplicate, just drop it.
prevPoint.cx = point.x - prevPoint.x; //change in x between this point and the next point (performance optimization)
prevPoint.cy = point.y - prevPoint.y;
prevPoint.n = point;
prevPoint.nx = point.x; //next point's x value (performance optimization, making lookups faster in getRatio()). Remember, the lookup will always land on a spot where it's either this point or the very next one (never beyond that)
if (this.fast && i > 1 && Math.abs(prevPoint.cy / prevPoint.cx - points[i - 2].cy / points[i - 2].cx) > 2) { //if there's a sudden change in direction, prioritize accuracy over speed. Like a bounce ease - you don't want to risk the sampling chunks landing on each side of the bounce anchor and having it clipped off.
this.fast = false;
}
if (prevPoint.cx < closest) {
if (!prevPoint.cx) {
prevPoint.cx = 0.001; //avoids math problems in getRatio() (dividing by zero)
if (i === l - 1) { //in case the final segment goes vertical RIGHT at the end, make sure we end at the end.
prevPoint.x -= 0.001;
closest = Math.min(closest, 0.001);
this.fast = false;
}
} else {
closest = prevPoint.cx;
}
}
} else {
points.splice(i--, 1);
l--;
}
}
l = (1 / closest + 1) | 0;
this.l = l; //record for speed optimization
inc = 1 / l;
j = 0;
point = points[0];
if (this.fast) {
for (i = 0; i < l; i++) { //for fastest lookups, we just sample along the path at equal x (time) distance. Uses more memory and is slightly less accurate for anchors that don't land on the sampling points, but for the vast majority of eases it's excellent (and fast).
p = i * inc;
if (point.nx < p) {
point = points[++j];
}
a1 = point.y + ((p - point.x) / point.cx) * point.cy;
this.lookup[i] = {x: p, cx: inc, y: a1, cy: 0, nx: 9};
if (i) {
this.lookup[i - 1].cy = a1 - this.lookup[i - 1].y;
}
}
this.lookup[l - 1].cy = points[points.length - 1].y - a1;
} else { //this option is more accurate, ensuring that EVERY anchor is hit perfectly. Clipping across a bounce, for example, would never happen.
for (i = 0; i < l; i++) { //build a lookup table based on the smallest distance so that we can instantly find the appropriate point (well, it'll either be that point or the very next one). We'll look up based on the linear progress. So it's it's 0.5 and the lookup table has 100 elements, it'd be like lookup[Math.floor(0.5 * 100)]
if (point.nx < i * inc) {
point = points[++j];
}
this.lookup[i] = point;
}
if (j < points.length - 1) {
this.lookup[i-1] = points[points.length-2];
}
}
this._calcEnd = (points[points.length-1].y !== 1 || points[0].y !== 0); //ensures that we don't run into floating point errors. As long as we're starting at 0 and ending at 1, tell GSAP to skip the final calculation and use 0/1 as the factor.
return this;
};
p.getRatio = _getRatio;
p.getSVGData = function(config) {
return CustomEase.getSVGData(this, config);
};
CustomEase.create = function (id, data, config) {
return new CustomEase(id, data, config);
};
CustomEase.version = "0.2.2";
CustomEase.bezierToPoints = _bezierToPoints;
CustomEase.get = function (id) {
return Ease.map[id];
};
CustomEase.getSVGData = function(ease, config) {
config = config || {};
var rnd = 1000,
width = config.width || 100,
height = config.height || 100,
x = config.x || 0,
y = (config.y || 0) + height,
e = config.path,
a, slope, i, inc, tx, ty, precision, threshold, prevX, prevY;
if (config.invert) {
height = -height;
y = 0;
}
ease = ease.getRatio ? ease : Ease.map[ease] || console.log("No ease found: ", ease);
if (!ease.rawBezier) {
a = ["M" + x + "," + y];
precision = Math.max(5, (config.precision || 1) * 200);
inc = 1 / precision;
precision += 2;
threshold = 5 / precision;
prevX = (((x + inc * width) * rnd) | 0) / rnd;
prevY = (((y + ease.getRatio(inc) * -height) * rnd) | 0) / rnd;
slope = (prevY - y) / (prevX - x);
for (i = 2; i < precision; i++) {
tx = (((x + i * inc * width) * rnd) | 0) / rnd;
ty = (((y + ease.getRatio(i * inc) * -height) * rnd) | 0) / rnd;
if (Math.abs((ty - prevY) / (tx - prevX) - slope) > threshold || i === precision - 1) { //only add points when the slope changes beyond the threshold
a.push(prevX + "," + prevY);
slope = (ty - prevY) / (tx - prevX);
}
prevX = tx;
prevY = ty;
}
} else {
a = [];
precision = ease.rawBezier.length;
for (i = 0; i < precision; i += 2) {
a.push((((x + ease.rawBezier[i] * width) * rnd) | 0) / rnd + "," + (((y + ease.rawBezier[i + 1] * -height) * rnd) | 0) / rnd);
}
a[0] = "M" + a[0];
a[1] = "C" + a[1];
}
if (e) {
(typeof(e) === "string" ? document.querySelector(e) : e).setAttribute("d", a.join(" "));
}
return a.join(" ");
};
return CustomEase;
}, true);
export var CustomEase = globals.CustomEase;
export { CustomEase as default };

View File

@ -0,0 +1,113 @@
/*!
* VERSION: 0.2.1
* DATE: 2018-08-27
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
/* eslint-disable */
import { _gsScope, globals, Ease } from "gsap/TweenLite.js";
import CustomEase from "./CustomEase.js";
_gsScope._gsDefine("easing.CustomWiggle", ["easing.CustomEase", "easing.Ease"], function() {
var eases = {
easeOut: new CustomEase("", "M0,1,C0.7,1,0.6,0,1,0"),
easeInOut: new CustomEase("", "M0,0,C0.104,0,0.242,1,0.444,1,0.644,1,0.608,0,1,0"),
anticipate: new CustomEase("", "M0,0,C0,0.222,0.024,0.386,0.06,0.402,0.181,0.455,0.647,0.646,0.7,0.67,0.9,0.76,1,0.846,1,1"),
uniform: new CustomEase("", "M0,0,C0,0.95,0.01,1,0.01,1,0.01,1,1,1,1,1,1,1,1,0.01,1,0")
},
_linearEase = new CustomEase(), //linear
_parseEase = function(ease, invertNonCustomEases) {
ease = ease.getRatio ? ease : Ease.map[ease] || new CustomEase("", ease);
return (ease.rawBezier || !invertNonCustomEases) ? ease : {getRatio:function(n) { return 1 - ease.getRatio(n); }};
},
CustomWiggle = function(id, vars) {
this.vars = vars || {};
CustomEase.call(this, id);
this.update(this.vars);
},
p;
CustomWiggle.prototype = p = new CustomEase();
p.constructor = CustomWiggle;
p.update = function(vars) {
vars = vars || this.vars;
var wiggles = (vars.wiggles || 10) | 0,
inc = 1 / wiggles,
x = inc / 2,
anticipate = (vars.type === "anticipate"),
yEase = eases[vars.type] || eases.easeOut,
xEase = _linearEase,
rnd = 1000,
nextX, nextY, angle, handleX, handleY, easedX, y, path, i;
if (anticipate) { //the anticipate ease is actually applied on the x-axis (timing) and uses easeOut for amplitude.
xEase = yEase;
yEase = eases.easeOut;
}
if (vars.timingEase) {
xEase = _parseEase(vars.timingEase);
}
if (vars.amplitudeEase) {
yEase = _parseEase(vars.amplitudeEase, true);
}
easedX = xEase.getRatio(x);
y = anticipate ? -yEase.getRatio(x) : yEase.getRatio(x);
path = [0, 0, easedX / 4, 0, easedX / 2, y, easedX, y];
if (vars.type === "random") { //if we just select random values on the y-axis and plug them into the "normal" algorithm, since the control points are always straight horizontal, it creates a bit of a slowdown at each anchor which just didn't seem as desirable, so we switched to an algorithm that bends the control points to be more in line with their context.
path.length = 4;
nextX = xEase.getRatio(inc);
nextY = Math.random() * 2 - 1;
for (i = 2; i < wiggles; i++) {
x = nextX;
y = nextY;
nextX = xEase.getRatio(inc * i);
nextY = Math.random() * 2 - 1;
angle = Math.atan2(nextY - path[path.length - 3], nextX - path[path.length - 4]);
handleX = Math.cos(angle) * inc;
handleY = Math.sin(angle) * inc;
path.push(x - handleX, y - handleY, x, y, x + handleX, y + handleY);
}
path.push(nextX, 0, 1, 0);
} else {
for (i = 1; i < wiggles; i++) {
path.push(xEase.getRatio(x + inc / 2), y);
x += inc;
y = ((y > 0) ? -1 : 1) * (yEase.getRatio(i * inc));
easedX = xEase.getRatio(x);
path.push(xEase.getRatio(x - inc / 2), y, easedX, y);
}
path.push(xEase.getRatio(x + inc / 4), y, xEase.getRatio(x + inc / 4), 0, 1, 0);
}
i = path.length;
while (--i > -1) {
path[i] = ((path[i] * rnd) | 0) / rnd; //round values to avoid odd strings for super tiny values
}
path[2] = "C" + path[2];
this.setData("M" + path.join(","));
};
CustomWiggle.create = function (id, vars) {
return new CustomWiggle(id, vars);
};
CustomWiggle.version = "0.2.1";
CustomWiggle.eases = eases;
return CustomWiggle;
}, true);
export var CustomWiggle = globals.CustomWiggle;
export { CustomWiggle as default };

View File

@ -0,0 +1,230 @@
/*!
* VERSION: 0.2.1
* DATE: 2019-02-07
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* DrawSVGPlugin is a Club GreenSock membership benefit; You must have a valid membership to use
* this code without violating the terms of use. Visit http://greensock.com/club/ to sign up or get more details.
* This work is subject to the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
import { _gsScope } from "gsap/TweenLite.js";
var _doc = _gsScope.document,
_computedStyleScope = (typeof(window) !== "undefined" ? window : _doc.defaultView || {getComputedStyle:function() {}}),
_getComputedStyle = function(e) {
return _computedStyleScope.getComputedStyle(e); //to avoid errors in Microsoft Edge, we need to call getComputedStyle() from a specific scope, typically window.
},
_numbersExp = /(?:(-|-=|\+=)?\d*\.?\d*(?:e[\-+]?\d+)?)[0-9]/ig,
_isEdge = (((_gsScope.navigator || {}).userAgent || "").indexOf("Edge") !== -1), //Microsoft Edge has a bug that causes it not to redraw the path correctly if the stroke-linecap is anything other than "butt" (like "round") and it doesn't match the stroke-linejoin. A way to trigger it is to change the stroke-miterlimit, so we'll only do that if/when we have to (to maximize performance)
_types = {rect:["width","height"], circle:["r","r"], ellipse:["rx","ry"], line:["x2","y2"]},
DrawSVGPlugin;
function getDistance(x1, y1, x2, y2, scaleX, scaleY) {
x2 = (parseFloat(x2 || 0) - parseFloat(x1 || 0)) * scaleX;
y2 = (parseFloat(y2 || 0) - parseFloat(y1 || 0)) * scaleY;
return Math.sqrt(x2 * x2 + y2 * y2);
}
function unwrap(element) {
if (typeof(element) === "string" || !element.nodeType) {
element = _gsScope.TweenLite.selector(element);
if (element.length) {
element = element[0];
}
}
return element;
}
//accepts values like "100%" or "20% 80%" or "20 50" and parses it into an absolute start and end position on the line/stroke based on its length. Returns an an array with the start and end values, like [0, 243]
function parse(value, length, defaultStart) {
var i = value.indexOf(" "),
s, e;
if (i === -1) {
s = defaultStart !== undefined ? defaultStart + "" : value;
e = value;
} else {
s = value.substr(0, i);
e = value.substr(i+1);
}
s = (s.indexOf("%") !== -1) ? (parseFloat(s) / 100) * length : parseFloat(s);
e = (e.indexOf("%") !== -1) ? (parseFloat(e) / 100) * length : parseFloat(e);
return (s > e) ? [e, s] : [s, e];
}
function getLength(element) {
if (!element) {
return 0;
}
element = unwrap(element);
var type = element.tagName.toLowerCase(),
scaleX = 1,
scaleY = 1,
length, bbox, points, prevPoint, i, rx, ry;
if (element.getAttribute("vector-effect") === "non-scaling-stroke") { //non-scaling-stroke basically scales the shape and then strokes it at the screen-level (after transforms), thus we need to adjust the length accordingly.
scaleY = element.getScreenCTM();
scaleX = Math.sqrt(scaleY.a * scaleY.a + scaleY.b * scaleY.b);
scaleY = Math.sqrt(scaleY.d * scaleY.d + scaleY.c * scaleY.c);
}
try { //IE bug: calling <path>.getTotalLength() locks the repaint area of the stroke to whatever its current dimensions are on that frame/tick. To work around that, we must call getBBox() to force IE to recalculate things.
bbox = element.getBBox(); //solely for fixing bug in IE - we don't actually use the bbox.
} catch (e) {
//firefox has a bug that throws an error if the element isn't visible.
console.log("Error: Some browsers like Firefox won't report measurements of invisible elements (like display:none or masks inside defs).");
}
if ((!bbox || (!bbox.width && !bbox.height)) && _types[type]) { //if the element isn't visible, try to discern width/height using its attributes.
bbox = {
width: parseFloat( element.getAttribute(_types[type][0]) ),
height: parseFloat( element.getAttribute(_types[type][1]) )
};
if (type !== "rect" && type !== "line") { //double the radius for circles and ellipses
bbox.width *= 2;
bbox.height *= 2;
}
if (type === "line") {
bbox.x = parseFloat( element.getAttribute("x1") );
bbox.y = parseFloat( element.getAttribute("y1") );
bbox.width = Math.abs(bbox.width - bbox.x);
bbox.height = Math.abs(bbox.height - bbox.y);
}
}
if (type === "path") {
prevPoint = element.style.strokeDasharray;
element.style.strokeDasharray = "none";
length = element.getTotalLength() || 0;
if (scaleX !== scaleY) {
console.log("Warning: <path> length cannot be measured accurately when vector-effect is non-scaling-stroke and the element isn't proportionally scaled.");
}
length *= (scaleX + scaleY) / 2;
element.style.strokeDasharray = prevPoint;
} else if (type === "rect") {
length = bbox.width * 2 * scaleX + bbox.height * 2 * scaleY;
} else if (type === "line") {
length = getDistance(bbox.x, bbox.y, bbox.x + bbox.width, bbox.y + bbox.height, scaleX, scaleY);
} else if (type === "polyline" || type === "polygon") {
points = element.getAttribute("points").match(_numbersExp) || [];
if (type === "polygon") {
points.push(points[0], points[1]);
}
length = 0;
for (i = 2; i < points.length; i+=2) {
length += getDistance(points[i-2], points[i-1], points[i], points[i+1], scaleX, scaleY) || 0;
}
} else if (type === "circle" || type === "ellipse") {
rx = (bbox.width / 2) * scaleX;
ry = (bbox.height / 2) * scaleY;
length = Math.PI * ( 3 * (rx + ry) - Math.sqrt((3 * rx + ry) * (rx + 3 * ry)) );
}
return length || 0;
}
function getPosition(element, length) {
if (!element) {
return [0, 0];
}
element = unwrap(element);
length = length || (getLength(element) + 1);
var cs = _getComputedStyle(element),
dash = cs.strokeDasharray || "",
offset = parseFloat(cs.strokeDashoffset),
i = dash.indexOf(",");
if (i < 0) {
i = dash.indexOf(" ");
}
dash = (i < 0) ? length : parseFloat(dash.substr(0, i)) || 0.00001;
if (dash > length) {
dash = length;
}
return [Math.max(0, -offset), Math.max(0, dash - offset)];
}
DrawSVGPlugin = _gsScope._gsDefine.plugin({
propName: "drawSVG",
API: 2,
version: "0.2.1",
global: true,
overwriteProps: ["drawSVG"],
init: function(target, value, tween, index) {
if (!target.getBBox) {
return false;
}
var length = getLength(target) + 1,
start, end, overage, cs;
this._style = target.style;
this._target = target;
if (typeof(value) === "function") {
value = value(index, target);
}
if (value === true || value === "true") {
value = "0 100%";
} else if (!value) {
value = "0 0";
} else if ((value + "").indexOf(" ") === -1) {
value = "0 " + value;
}
start = getPosition(target, length);
end = parse(value, length, start[0]);
this._length = length + 10;
if (start[0] === 0 && end[0] === 0) {
overage = Math.max(0.00001, end[1] - length); //allow people to go past the end, like values of 105% because for some paths, Firefox doesn't return an accurate getTotalLength(), so it could end up coming up short.
this._dash = length + overage;
this._offset = length - start[1] + overage;
this._offsetPT = this._addTween(this, "_offset", this._offset, length - end[1] + overage, "drawSVG");
} else {
this._dash = (start[1] - start[0]) || 0.000001; //some browsers render artifacts if dash is 0, so we use a very small number in that case.
this._offset = -start[0];
this._dashPT = this._addTween(this, "_dash", this._dash, (end[1] - end[0]) || 0.00001, "drawSVG");
this._offsetPT = this._addTween(this, "_offset", this._offset, -end[0], "drawSVG");
}
if (_isEdge) { //to work around a bug in Microsoft Edge, animate the stroke-miterlimit by 0.0001 just to trigger the repaint (unnecessary if it's "round" and stroke-linejoin is also "round"). Imperceptible, relatively high-performance, and effective. Another option was to set the "d" <path> attribute to its current value on every tick, but that seems like it'd be much less performant.
cs = _getComputedStyle(target);
if (cs.strokeLinecap !== cs.strokeLinejoin) {
end = parseFloat(cs.strokeMiterlimit);
this._addTween(target.style, "strokeMiterlimit", end, end + 0.0001, "strokeMiterlimit");
}
}
this._live = (target.getAttribute("vector-effect") === "non-scaling-stroke" || (value + "").indexOf("live") !== -1);
return true;
},
//called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.)
set: function(ratio) {
if (this._firstPT) {
//when the element has vector-effect="non-scaling-stroke" and the SVG is resized (like on a window resize), it actually changes the length of the stroke! So we must sense that and make the proper adjustments.
if (this._live) {
var length = getLength(this._target) + 11,
lengthRatio;
if (length !== this._length) {
lengthRatio = length / this._length;
this._length = length;
this._offsetPT.s *= lengthRatio;
this._offsetPT.c *= lengthRatio;
if (this._dashPT) {
this._dashPT.s *= lengthRatio;
this._dashPT.c *= lengthRatio;
} else {
this._dash *= lengthRatio;
}
}
}
this._super.setRatio.call(this, ratio);
this._style.strokeDashoffset = this._offset;
if (ratio === 1 || ratio === 0) {
this._style.strokeDasharray = (this._offset < 0.001 && this._length - this._dash <= 10) ? "none" : (this._offset === this._dash) ? "0px, 999999px" : this._dash + "px," + this._length + "px";
} else {
this._style.strokeDasharray = this._dash + "px," + this._length + "px";
}
}
}
});
DrawSVGPlugin.getLength = getLength;
DrawSVGPlugin.getPosition = getPosition;
export { DrawSVGPlugin, DrawSVGPlugin as default };

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,192 @@
/*!
* VERSION: 0.2.1
* DATE: 2018-05-30
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* Physics2DPlugin is a Club GreenSock membership benefit; You must have a valid membership to use
* this code without violating the terms of use. Visit http://greensock.com/club/ to sign up or get more details.
* This work is subject to the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
import { _gsScope } from "gsap/TweenLite.js";
var _DEG2RAD = Math.PI / 180,
Physics2DProp = function(target, p, velocity, acceleration, stepsPerTimeUnit) {
this.p = p;
this.f = (typeof(target[p]) === "function");
this.start = this.value = (!this.f) ? parseFloat(target[p]) : target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]();
this.velocity = velocity || 0;
this.v = this.velocity / stepsPerTimeUnit;
if (acceleration || acceleration === 0) {
this.acceleration = acceleration;
this.a = this.acceleration / (stepsPerTimeUnit * stepsPerTimeUnit);
} else {
this.acceleration = this.a = 0;
}
},
_random = Math.random(),
_globals = _gsScope._gsDefine.globals,
_rootFramesTimeline = _globals.com.greensock.core.Animation._rootFramesTimeline,
Physics2DPlugin = _gsScope._gsDefine.plugin({
propName: "physics2D",
version: "0.2.1",
API: 2,
//called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
init: function(target, value, tween, index) {
if (typeof(value) === "function") {
value = value(index, target);
}
this._target = target;
this._tween = tween;
this._runBackwards = (tween.vars.runBackwards === true);
this._step = 0;
var tl = tween._timeline,
angle = Number(value.angle) || 0,
velocity = Number(value.velocity) || 0,
acceleration = Number(value.acceleration) || 0,
xProp = value.xProp || "x",
yProp = value.yProp || "y",
aAngle = (value.accelerationAngle || value.accelerationAngle === 0) ? Number(value.accelerationAngle) : angle,
stepsPerTimeUnit;
while (tl._timeline) {
tl = tl._timeline;
}
this._stepsPerTimeUnit = stepsPerTimeUnit = (tl === _rootFramesTimeline) ? 1 : 30;
if (value.gravity) {
acceleration = Number(value.gravity);
aAngle = 90;
}
angle *= _DEG2RAD;
aAngle *= _DEG2RAD;
this._friction = 1 - Number(value.friction || 0);
this._overwriteProps.push(xProp);
this._overwriteProps.push(yProp);
this._x = new Physics2DProp(target, xProp, Math.cos(angle) * velocity, Math.cos(aAngle) * acceleration, stepsPerTimeUnit);
this._y = new Physics2DProp(target, yProp, Math.sin(angle) * velocity, Math.sin(aAngle) * acceleration, stepsPerTimeUnit);
this._skipX = this._skipY = false;
return true;
},
//called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.)
set: function(ratio) {
var time = this._tween._time,
xp = this._x,
yp = this._y,
x, y, tt, steps, remainder, i;
if (this._runBackwards === true) {
time = this._tween._duration - time;
}
if (this._friction === 1) {
tt = time * time * 0.5;
x = xp.start + ((xp.velocity * time) + (xp.acceleration * tt));
y = yp.start + ((yp.velocity * time) + (yp.acceleration * tt));
} else {
time *= this._stepsPerTimeUnit;
steps = i = (time | 0) - this._step;
remainder = (time % 1);
if (i >= 0) { //going forward
while (--i > -1) {
xp.v += xp.a;
yp.v += yp.a;
xp.v *= this._friction;
yp.v *= this._friction;
xp.value += xp.v;
yp.value += yp.v;
}
} else { //going backwards
i = -i;
while (--i > -1) {
xp.value -= xp.v;
yp.value -= yp.v;
xp.v /= this._friction;
yp.v /= this._friction;
xp.v -= xp.a;
yp.v -= yp.a;
}
}
x = xp.value + (xp.v * remainder);
y = yp.value + (yp.v * remainder);
this._step += steps;
}
if (!this._skipX) {
if (xp.m) {
x = xp.m(x, this._target);
}
if (xp.f) {
this._target[xp.p](x);
} else {
this._target[xp.p] = x;
}
}
if (!this._skipY) {
if (yp.m) {
y = yp.m(y, this._target);
}
if (yp.f) {
this._target[yp.p](y);
} else {
this._target[yp.p] = y;
}
}
}
}),
p = Physics2DPlugin.prototype;
p._kill = function(lookup) {
if (lookup[this._x.p] != null) {
this._skipX = true;
}
if (lookup[this._y.p] != null) {
this._skipY = true;
}
return this._super._kill.call(this, lookup);
};
p._mod = function(lookup) {
var val = lookup[this._x.p] || lookup.physics2D;
if (val && typeof(val) === "function") {
this._x.m = val;
}
val = lookup[this._y.p] || lookup.physics2D;
if (val && typeof(val) === "function") {
this._y.m = val;
}
};
Physics2DPlugin._autoCSS = true; //indicates that this plugin can be inserted into the "css" object using the autoCSS feature of TweenLite
Physics2DPlugin._cssRegister = function() {
var CSSPlugin = _globals.CSSPlugin;
if (!CSSPlugin) {
return;
}
var _internals = CSSPlugin._internals,
_parseToProxy = _internals._parseToProxy,
_setPluginRatio = _internals._setPluginRatio,
CSSPropTween = _internals.CSSPropTween;
_internals._registerComplexSpecialProp("physics2D", {parser:function(t, e, prop, cssp, pt, plugin) {
plugin = new Physics2DPlugin();
var xProp = e.xProp || "x",
yProp = e.yProp || "y",
vars = {},
data;
vars[xProp] = vars[yProp] = _random++; //doesn't really matter what values we put here because the plugin will determine end values, but it'd be best of the values don't match the current ones so that CSSPlugin doesn't skip creating a CSSPropTween.
data = _parseToProxy(t, vars, cssp, pt, plugin);
pt = new CSSPropTween(t, "physics2D", 0, 0, data.pt, 2);
pt.data = data;
pt.plugin = plugin;
pt.setRatio = _setPluginRatio;
plugin._onInitTween(data.proxy, e, cssp._tween);
return pt;
}});
};
export { Physics2DPlugin, Physics2DPlugin as default };

View File

@ -0,0 +1,200 @@
/*!
* VERSION: 0.2.1
* DATE: 2018-05-30
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* PhysicsPropsPlugin is a Club GreenSock membership benefit; You must have a valid membership to use
* this code without violating the terms of use. Visit http://greensock.com/club/ to sign up or get more details.
* This work is subject to the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
import { _gsScope } from "gsap/TweenLite.js";
var PhysicsProp = function(target, p, velocity, acceleration, friction, stepsPerTimeUnit) {
this.p = p;
this.f = (typeof(target[p]) === "function");
this.start = this.value = (!this.f) ? parseFloat(target[p]) : target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]();
this.velocity = velocity || 0;
this.v = this.velocity / stepsPerTimeUnit;
if (acceleration || acceleration == 0) {
this.acceleration = acceleration;
this.a = this.acceleration / (stepsPerTimeUnit * stepsPerTimeUnit);
} else {
this.acceleration = this.a = 0;
}
this.friction = 1 - (friction || 0) ;
},
_random = Math.random(),
_globals = _gsScope._gsDefine.globals,
_rootFramesTimeline = _globals.com.greensock.core.Animation._rootFramesTimeline,
PhysicsPropsPlugin = _gsScope._gsDefine.plugin({
propName: "physicsProps",
version: "0.2.1",
API: 2,
//called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
init: function(target, value, tween, index) {
if (typeof(value) === "function") {
value = value(target);
}
this._target = target;
this._tween = tween;
this._runBackwards = (tween.vars.runBackwards === true);
this._step = 0;
var tl = tween._timeline,
cnt = 0,
p, curProp;
while (tl._timeline) {
tl = tl._timeline;
}
this._stepsPerTimeUnit = (tl === _rootFramesTimeline) ? 1 : 30;
this._props = [];
for (p in value) {
curProp = value[p];
if (typeof(curProp) === "function") {
curProp = curProp(index, target);
}
if (curProp.velocity || curProp.acceleration) {
this._props[cnt++] = new PhysicsProp(target, p, curProp.velocity, curProp.acceleration, curProp.friction, this._stepsPerTimeUnit);
this._overwriteProps[cnt] = p;
if (curProp.friction) {
this._hasFriction = true;
}
}
}
return true;
},
//called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.)
set: function(ratio) {
var i = this._props.length,
time = this._tween._time,
target = this._target,
curProp, val, steps, remainder, j, tt;
if (this._runBackwards) {
time = this._tween._duration - time;
}
if (this._hasFriction) {
time *= this._stepsPerTimeUnit;
steps = (time | 0) - this._step;
remainder = time % 1;
if (steps >= 0) { //going forward
while (--i > -1) {
curProp = this._props[i];
j = steps;
while (--j > -1) {
curProp.v += curProp.a;
curProp.v *= curProp.friction;
curProp.value += curProp.v;
}
val = curProp.value + (curProp.v * remainder);
if (curProp.m) {
val = curProp.m(val, target);
}
if (curProp.f) {
target[curProp.p](val);
} else {
target[curProp.p] = val;
}
}
} else { //going backwards
while (--i > -1) {
curProp = this._props[i];
j = -steps;
while (--j > -1) {
curProp.value -= curProp.v;
curProp.v /= curProp.friction;
curProp.v -= curProp.a;
}
val = curProp.value + (curProp.v * remainder);
if (curProp.m) {
val = curProp.m(val, target);
}
if (curProp.f) {
target[curProp.p](val);
} else {
target[curProp.p] = val;
}
}
}
this._step += steps;
} else {
tt = time * time * 0.5;
while (--i > -1) {
curProp = this._props[i];
val = curProp.start + ((curProp.velocity * time) + (curProp.acceleration * tt));
if (curProp.m) {
val = curProp.m(val, target);
}
if (curProp.f) {
target[curProp.p](val);
} else {
target[curProp.p] = val;
}
}
}
}
}),
p = PhysicsPropsPlugin.prototype;
p._kill = function(lookup) {
var i = this._props.length;
while (--i > -1) {
if (this._props[i].p in lookup) {
this._props.splice(i, 1);
}
}
return this._super._kill.call(this, lookup);
};
p._mod = function(lookup) {
var i = this._props.length,
val;
while (--i > -1) {
val = lookup[this._props[i].p] || lookup.physicsProps;
if (typeof(val) === "function") {
this._props[i].m = val;
}
}
};
PhysicsPropsPlugin._autoCSS = true; //indicates that this plugin can be inserted into the "css" object using the autoCSS feature of TweenLite
PhysicsPropsPlugin._cssRegister = function() {
var CSSPlugin = _globals.CSSPlugin;
if (!CSSPlugin) {
return;
}
var _internals = CSSPlugin._internals,
_parseToProxy = _internals._parseToProxy,
_setPluginRatio = _internals._setPluginRatio,
CSSPropTween = _internals.CSSPropTween;
_internals._registerComplexSpecialProp("physicsProps", {parser:function(t, e, prop, cssp, pt, plugin) {
plugin = new PhysicsPropsPlugin();
var vars = {},
p, data;
if (e.scale) {
e.scaleX = e.scaleY = e.scale;
delete e.scale;
}
for (p in e) {
vars[p] = _random++; //doesn't really matter what values we put here because the plugin will determine end values, but it'd be best of the values don't match the current ones so that CSSPlugin doesn't skip creating a CSSPropTween.
}
data = _parseToProxy(t, vars, cssp, pt, plugin);
pt = new CSSPropTween(t, "physicsProps", 0, 0, data.pt, 2);
pt.data = data;
pt.plugin = plugin;
pt.setRatio = _setPluginRatio;
plugin._onInitTween(data.proxy, e, cssp._tween);
return pt;
}});
};
export { PhysicsPropsPlugin, PhysicsPropsPlugin as default };

View File

@ -0,0 +1,215 @@
/*!
* VERSION: 0.5.2
* DATE: 2018-09-11
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* ScrambleTextPlugin is a Club GreenSock membership benefit; You must have a valid membership to use
* this code without violating the terms of use. Visit http://greensock.com/club/ to sign up or get more details.
* This work is subject to the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
import { _gsScope } from "gsap/TweenLite.js";
var _trimExp = /(^\s+|\s+$)/g,
_spacesExp = /\s+/g,
_getText = function(e) {
var type = e.nodeType,
result = "";
if (type === 1 || type === 9 || type === 11) {
if (typeof(e.textContent) === "string") {
return e.textContent;
} else {
for (e = e.firstChild; e; e = e.nextSibling ) {
result += _getText(e);
}
}
} else if (type === 3 || type === 4) {
return e.nodeValue;
}
return result;
},
_scrambleText = function(length, chars) {
var l = chars.length,
s = "";
while (--length > -1) {
s += chars[ ((Math.random() * l) | 0) ];
}
return s;
},
CharSet = function(chars) {
this.chars = _emojiSafeSplit(chars);
this.sets = [];
this.length = 50;
var i;
for (i = 0; i < 20; i++) {
this.sets[i] = _scrambleText(80, this.chars); //we create 20 strings that are 80 characters long, randomly chosen and pack them into an array. We then randomly choose the scrambled text from this array in order to greatly improve efficiency compared to creating new randomized text from scratch each and every time it's needed. This is a simple lookup whereas the other technique requires looping through as many times as there are characters needed, and calling Math.random() each time through the loop, building the string, etc.
}
this.grow = function(newLength) { //if we encounter a tween that has more than 80 characters, we'll need to add to the character sets accordingly. Once it's cached, it'll only need to grow again if we exceed that new length. Again, this is an efficiency tactic.
for (i = 0; i < 20; i++) {
this.sets[i] += _scrambleText(newLength - this.length, this.chars);
}
this.length = newLength;
};
},
_emoji = "[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2694-\u2697]|\uD83E[\uDD10-\uDD5D]|[\uD800-\uDBFF][\uDC00-\uDFFF]",
_emojiExp = new RegExp(_emoji),
_emojiAndCharsExp = new RegExp(_emoji + "|.", "g"),
_emojiSafeSplit = function(text, delimiter, trim) {
if (trim) {
text = text.replace(_trimExp, "");
}
return ((delimiter === "" || !delimiter) && _emojiExp.test(text)) ? text.match(_emojiAndCharsExp) : text.split(delimiter || "");
},
_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
_lower = _upper.toLowerCase(),
_charsLookup = {
upperCase: new CharSet(_upper),
lowerCase: new CharSet(_lower),
upperAndLowerCase: new CharSet(_upper + _lower)
},
ScrambleTextPlugin = _gsScope._gsDefine.plugin({
propName: "scrambleText",
version: "0.5.2",
API: 2,
overwriteProps:["scrambleText","text"],
//called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
init: function(target, value, tween, index) {
this._prop = ("innerHTML" in target) ? "innerHTML" : ("textContent" in target) ? "textContent" : 0; // SVG text in IE doesn't have innerHTML, but it does have textContent.
if (!this._prop) {
return false;
}
if (typeof(value) === "function") {
value = value(index, target);
}
this._target = target;
if (typeof(value) !== "object") {
value = {text:value};
}
var text = value.text || value.value,
trim = (value.trim !== false),
delim, maxLength, charset, splitByChars;
this._delimiter = delim = value.delimiter || "";
this._original = _emojiSafeSplit(_getText(target).replace(_spacesExp, " ").split("&nbsp;").join(""), delim, trim);
if (text === "{original}" || text === true || text == null) {
text = this._original.join(delim);
}
this._text = _emojiSafeSplit((text || "").replace(_spacesExp, " "), delim, trim);
this._hasClass = false;
if (typeof(value.newClass) === "string") {
this._newClass = value.newClass;
this._hasClass = true;
}
if (typeof(value.oldClass) === "string") {
this._oldClass = value.oldClass;
this._hasClass = true;
}
splitByChars = (delim === "");
this._textHasEmoji = (_emojiExp.test(this._text.join(delim)) && splitByChars);
this._charsHaveEmoji = !!value.chars && _emojiExp.test(value.chars);
this._length = splitByChars ? this._original.length : this._original.join(delim).length;
this._lengthDif = (splitByChars ? this._text.length : this._text.join(delim).length) - this._length;
this._fillChar = value.fillChar || (value.chars && value.chars.indexOf(" ") !== -1) ? "&nbsp;" : "";
this._charSet = charset = _charsLookup[(value.chars || "upperCase")] || new CharSet(value.chars);
this._speed = 0.016 / (value.speed || 1);
this._prevScrambleTime = 0;
this._setIndex = (Math.random() * 20) | 0;
maxLength = this._length + Math.max(this._lengthDif, 0);
if (maxLength > charset.length) {
charset.grow(maxLength);
}
this._chars = charset.sets[this._setIndex];
this._revealDelay = value.revealDelay || 0;
this._tweenLength = (value.tweenLength !== false);
this._tween = tween;
this._rightToLeft = !!value.rightToLeft;
return true;
},
//called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.)
set: function(ratio) {
var l = this._text.length,
delim = this._delimiter,
time = this._tween._time,
timeDif = time - this._prevScrambleTime,
i, i2, startText, endText, applyNew, applyOld, str, startClass, endClass;
if (this._revealDelay) {
if (this._tween.vars.runBackwards) {
time = this._tween._duration - time; //invert the time for from() tweens
}
ratio = (time === 0) ? 0 : (time < this._revealDelay) ? 0.000001 : (time === this._tween._duration) ? 1 : this._tween._ease.getRatio((time - this._revealDelay) / (this._tween._duration - this._revealDelay));
}
if (ratio < 0) {
ratio = 0;
} else if (ratio > 1) {
ratio = 1;
}
if (this._rightToLeft) {
ratio = 1 - ratio;
}
i = (ratio * l + 0.5) | 0;
if (ratio) {
if (timeDif > this._speed || timeDif < -this._speed) {
this._setIndex = (this._setIndex + ((Math.random() * 19) | 0)) % 20;
this._chars = this._charSet.sets[this._setIndex];
this._prevScrambleTime += timeDif;
}
endText = this._chars;
} else {
endText = this._original.join(delim);
}
if (this._rightToLeft) {
if (ratio === 1 && (this._tween.vars.runBackwards || this._tween.data === "isFromStart")) { //special case for from() tweens
startText = "";
endText = this._original.join(delim);
} else {
str = this._text.slice(i).join(delim);
if (this._charsHaveEmoji) {
startText = _emojiSafeSplit(endText).slice(0, ((this._length + (this._tweenLength ? 1 - (ratio * ratio * ratio) : 1) * this._lengthDif) - ((this._textHasEmoji ? _emojiSafeSplit(str) : str).length) + 0.5) | 0).join("");
} else {
startText = endText.substr(0, ((this._length + (this._tweenLength ? 1 - (ratio * ratio * ratio) : 1) * this._lengthDif) - ((this._textHasEmoji ? _emojiSafeSplit(str) : str).length) + 0.5) | 0);
}
endText = str;
}
} else {
startText = this._text.slice(0, i).join(delim);
i2 = (this._textHasEmoji ? _emojiSafeSplit(startText) : startText).length;
if (this._charsHaveEmoji) {
endText = _emojiSafeSplit(endText).slice(i2, ((this._length + (this._tweenLength ? 1 - ((ratio = 1 - ratio) * ratio * ratio * ratio) : 1) * this._lengthDif) + 0.5) | 0).join("");
} else {
endText = endText.substr(i2, ((this._length + (this._tweenLength ? 1 - ((ratio = 1 - ratio) * ratio * ratio * ratio) : 1) * this._lengthDif) - i2 + 0.5) | 0);
}
}
if (this._hasClass) {
startClass = this._rightToLeft ? this._oldClass : this._newClass;
endClass = this._rightToLeft ? this._newClass : this._oldClass;
applyNew = (startClass && i !== 0);
applyOld = (endClass && i !== l);
str = (applyNew ? "<span class='" + startClass + "'>" : "") + startText + (applyNew ? "</span>" : "") + (applyOld ? "<span class='" + endClass + "'>" : "") + delim + endText + (applyOld ? "</span>" : "");
} else {
str = startText + delim + endText;
}
this._target[this._prop] = (this._fillChar === "&nbsp;" && str.indexOf(" ") !== -1) ? str.split(" ").join("&nbsp;&nbsp;") : str;
}
}),
p = ScrambleTextPlugin.prototype;
p._newClass = p._oldClass = "";
for (p in _charsLookup) {
_charsLookup[p.toLowerCase()] = _charsLookup[p];
_charsLookup[p.toUpperCase()] = _charsLookup[p];
}
export { ScrambleTextPlugin, ScrambleTextPlugin as default };

View File

@ -0,0 +1,565 @@
/*!
* VERSION: 0.7.0
* DATE: 2019-02-07
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* SplitText is a Club GreenSock membership benefit; You must have a valid membership to use
* this code without violating the terms of use. Visit http://greensock.com/club/ to sign up or get more details.
* This work is subject to the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
import { _gsScope, globals } from "gsap/TweenLite.js";
(function(window) {
"use strict";
var _globals = window.GreenSockGlobals || window,
_namespace = function(ns) {
var a = ns.split("."),
p = _globals, i;
for (i = 0; i < a.length; i++) {
p[a[i]] = p = p[a[i]] || {};
}
return p;
},
pkg = _namespace("com.greensock.utils"),
_getText = function(e) {
var type = e.nodeType,
result = "";
if (type === 1 || type === 9 || type === 11) {
if (typeof(e.textContent) === "string") {
return e.textContent;
} else {
for ( e = e.firstChild; e; e = e.nextSibling ) {
result += _getText(e);
}
}
} else if (type === 3 || type === 4) {
return e.nodeValue;
}
return result;
},
_doc = _gsScope.document || {},
_computedStyleScope = (typeof(window) !== "undefined" ? window : _doc.defaultView || {getComputedStyle:function() {}}),
_getComputedStyle = function(e) {
return _computedStyleScope.getComputedStyle(e); //to avoid errors in Microsoft Edge, we need to call getComputedStyle() from a specific scope, typically window.
},
_capsExp = /([A-Z])/g,
_getStyle = function(t, p, cs, str) {
var result;
if ((cs = cs || _getComputedStyle(t, null))) {
t = cs.getPropertyValue(p.replace(_capsExp, "-$1").toLowerCase());
result = (t || cs.length) ? t : cs[p]; //Opera behaves VERY strangely - length is usually 0 and cs[p] is the only way to get accurate results EXCEPT when checking for -o-transform which only works with cs.getPropertyValue()!
} else if (t.currentStyle) {
cs = t.currentStyle;
result = cs[p];
}
return str ? result : parseInt(result, 10) || 0;
},
_isArrayLike = function(e) {
return (e.length && e[0] && ((e[0].nodeType && e[0].style && !e.nodeType) || (e[0].length && e[0][0]))) ? true : false; //could be an array of jQuery objects too, so accommodate that.
},
_flattenArray = function(a) {
var result = [],
l = a.length,
i, e, j;
for (i = 0; i < l; i++) {
e = a[i];
if (_isArrayLike(e)) {
j = e.length;
for (j = 0; j < e.length; j++) {
result.push(e[j]);
}
} else {
result.push(e);
}
}
return result;
},
//some characters are combining marks (think diacritics/accents in European languages) which involve 2 or 4 characters that combine in the browser to form a single character. Pass in the remaining text and an array of the special characters to search for and if the text starts with one of those special characters, it'll spit back the number of characters to retain (often 2 or 4). Used in the specialChars features that was introduced in 0.6.0.
_findSpecialChars = function(text, chars) {
var i = chars.length,
s;
while (--i > -1) {
s = chars[i];
if (text.substr(0, s.length) === s) {
return s.length;
}
}
},
_stripExp = /(?:\r|\n|\t\t)/g, //find carriage returns, new line feeds and double-tabs.
_multipleSpacesExp = /(?:\s\s+)/g,
_emojiStart = 0xD800,
_emojiEnd = 0xDBFF,
_emojiLowStart = 0xDC00,
_emojiRegionStart = 0x1F1E6,
_emojiRegionEnd = 0x1F1FF,
_emojiModStart = 0x1f3fb,
_emojiModEnd = 0x1f3ff,
_emojiPairCode = function(s) {
return ((s.charCodeAt(0) - _emojiStart) << 10) + (s.charCodeAt(1) - _emojiLowStart) + 0x10000;
},
_isOldIE = (_doc.all && !_doc.addEventListener),
_divStart = " style='position:relative;display:inline-block;" + (_isOldIE ? "*display:inline;*zoom:1;'" : "'"), //note: we must use both display:inline-block and *display:inline for IE8 and earlier, otherwise it won't flow correctly (and if we only use display:inline, IE won't render most of the property tweens - very odd).
_cssClassFunc = function(cssClass, tag) {
cssClass = cssClass || "";
var iterate = (cssClass.indexOf("++") !== -1),
num = 1;
if (iterate) {
cssClass = cssClass.split("++").join("");
}
return function() {
return "<" + tag + _divStart + (cssClass ? " class='" + cssClass + (iterate ? num++ : "") + "'>" : ">");
};
},
SplitText = pkg.SplitText = _globals.SplitText = function(element, vars) {
if (typeof(element) === "string") {
element = SplitText.selector(element);
}
if (!element) {
throw("cannot split a null element.");
}
this.elements = _isArrayLike(element) ? _flattenArray(element) : [element];
this.chars = [];
this.words = [];
this.lines = [];
this._originals = [];
this.vars = vars || {};
this.split(vars);
},
_swapText = function(element, oldText, newText) {
var type = element.nodeType;
if (type === 1 || type === 9 || type === 11) {
for (element = element.firstChild; element; element = element.nextSibling) {
_swapText(element, oldText, newText);
}
} else if (type === 3 || type === 4) {
element.nodeValue = element.nodeValue.split(oldText).join(newText);
}
},
_pushReversed = function(a, merge) {
var i = merge.length;
while (--i > -1) {
a.push(merge[i]);
}
},
_slice = function(a) { //don't use Array.prototype.slice.call(target, 0) because that doesn't work in IE8 with a NodeList that's returned by querySelectorAll()
var b = [],
l = a.length,
i;
for (i = 0; i !== l; b.push(a[i++])) {}
return b;
},
_isBeforeWordDelimiter = function(e, root, wordDelimiter) {
var next;
while (e && e !== root) {
next = e._next || e.nextSibling;
if (next) {
return next.textContent.charAt(0) === wordDelimiter;
}
e = e.parentNode || e._parent;
}
return false;
},
_deWordify = function(e) {
var children = _slice(e.childNodes),
l = children.length,
i, child;
for (i = 0; i < l; i++) {
child = children[i];
if (child._isSplit) {
_deWordify(child);
} else {
if (i && child.previousSibling.nodeType === 3) {
child.previousSibling.nodeValue += (child.nodeType === 3) ? child.nodeValue : child.firstChild.nodeValue;
} else if (child.nodeType !== 3) {
e.insertBefore(child.firstChild, child);
}
e.removeChild(child);
}
}
},
_setPositionsAfterSplit = function(element, vars, allChars, allWords, allLines, origWidth, origHeight) {
var cs = _getComputedStyle(element),
paddingLeft = _getStyle(element, "paddingLeft", cs),
lineOffsetY = -999,
borderTopAndBottom = _getStyle(element, "borderBottomWidth", cs) + _getStyle(element, "borderTopWidth", cs),
borderLeftAndRight = _getStyle(element, "borderLeftWidth", cs) + _getStyle(element, "borderRightWidth", cs),
padTopAndBottom = _getStyle(element, "paddingTop", cs) + _getStyle(element, "paddingBottom", cs),
padLeftAndRight = _getStyle(element, "paddingLeft", cs) + _getStyle(element, "paddingRight", cs),
lineThreshold = _getStyle(element, "fontSize") * 0.2,
textAlign = _getStyle(element, "textAlign", cs, true),
charArray = [],
wordArray = [],
lineArray = [],
wordDelimiter = vars.wordDelimiter || " ",
tag = vars.tag ? vars.tag : (vars.span ? "span" : "div"),
types = vars.type || vars.split || "chars,words,lines",
lines = (allLines && types.indexOf("lines") !== -1) ? [] : null,
words = (types.indexOf("words") !== -1),
chars = (types.indexOf("chars") !== -1),
absolute = (vars.position === "absolute" || vars.absolute === true),
linesClass = vars.linesClass,
iterateLine = ((linesClass || "").indexOf("++") !== -1),
spaceNodesToRemove = [],
i, j, l, node, nodes, isChild, curLine, addWordSpaces, style, lineNode, lineWidth, offset;
if (iterateLine) {
linesClass = linesClass.split("++").join("");
}
//copy all the descendant nodes into an array (we can't use a regular nodeList because it's live and we may need to renest things)
j = element.getElementsByTagName("*");
l = j.length;
nodes = [];
for (i = 0; i < l; i++) {
nodes[i] = j[i];
}
//for absolute positioning, we need to record the x/y offsets and width/height for every <div>. And even if we're not positioning things absolutely, in order to accommodate lines, we must figure out where the y offset changes so that we can sense where the lines break, and we populate the lines array.
if (lines || absolute) {
for (i = 0; i < l; i++) {
node = nodes[i];
isChild = (node.parentNode === element);
if (isChild || absolute || (chars && !words)) {
offset = node.offsetTop;
if (lines && isChild && Math.abs(offset - lineOffsetY) > lineThreshold && (node.nodeName !== "BR" || i === 0)) { //we found some rare occasions where a certain character like &#8209; could cause the offsetTop to be off by 1 pixel, so we build in a threshold.
curLine = [];
lines.push(curLine);
lineOffsetY = offset;
}
if (absolute) { //record offset x and y, as well as width and height so that we can access them later for positioning. Grabbing them at once ensures we don't trigger a browser paint & we maximize performance.
node._x = node.offsetLeft;
node._y = offset;
node._w = node.offsetWidth;
node._h = node.offsetHeight;
}
if (lines) {
if ((node._isSplit && isChild) || (!chars && isChild) || (words && isChild) || (!words && node.parentNode.parentNode === element && !node.parentNode._isSplit)) {
curLine.push(node);
node._x -= paddingLeft;
if (_isBeforeWordDelimiter(node, element, wordDelimiter)) {
node._wordEnd = true;
}
}
if (node.nodeName === "BR" && ((node.nextSibling && node.nextSibling.nodeName === "BR") || i === 0)) { //two consecutive <br> tags signify a new [empty] line. Also, if the entire block of content STARTS with a <br>, add a line.
lines.push([]);
}
}
}
}
}
for (i = 0; i < l; i++) {
node = nodes[i];
isChild = (node.parentNode === element);
if (node.nodeName === "BR") {
if (lines || absolute) {
if (node.parentNode) {
node.parentNode.removeChild(node);
}
nodes.splice(i--, 1);
l--;
} else if (!words) {
element.appendChild(node);
}
continue;
}
if (absolute) {
style = node.style;
if (!words && !isChild) {
node._x += node.parentNode._x;
node._y += node.parentNode._y;
}
style.left = node._x + "px";
style.top = node._y + "px";
style.position = "absolute";
style.display = "block";
//if we don't set the width/height, things collapse in older versions of IE and the origin for transforms is thrown off in all browsers.
style.width = (node._w + 1) + "px"; //IE is 1px short sometimes. Avoid wrapping
style.height = node._h + "px";
}
if (!words && chars) {
//we always start out wrapping words in their own <div> so that line breaks happen correctly, but here we'll remove those <div> tags if necessary and renest the characters directly into the element rather than inside the word <div>
if (node._isSplit) {
node._next = node.nextSibling;
node.parentNode.appendChild(node); //put it at the end to keep the order correct.
} else if (node.parentNode._isSplit) {
node._parent = node.parentNode;
if (!node.previousSibling && node.firstChild) {
node.firstChild._isFirst = true;
}
if (node.nextSibling && node.nextSibling.textContent === " " && !node.nextSibling.nextSibling) { //if the last node inside a nested element is just a space (like T<span>nested </span>), remove it otherwise it'll get placed in the wrong order. Don't remove it right away, though, because we need to sense when words/characters are before a space like _isBeforeWordDelimiter(). Removing it now would make that a false negative.
spaceNodesToRemove.push(node.nextSibling);
}
node._next = (node.nextSibling && node.nextSibling._isFirst) ? null : node.nextSibling;
node.parentNode.removeChild(node);
nodes.splice(i--, 1);
l--;
} else if (!isChild) {
offset = (!node.nextSibling && _isBeforeWordDelimiter(node.parentNode, element, wordDelimiter)); //if this is the last letter in the word (and we're not breaking by lines and not positioning things absolutely), we need to add a space afterwards so that the characters don't just mash together
if (node.parentNode._parent) {
node.parentNode._parent.appendChild(node);
}
if (offset) {
node.parentNode.appendChild(_doc.createTextNode(" "));
}
if (tag === "span") {
node.style.display = "inline"; //so that word breaks are honored properly.
}
charArray.push(node);
}
} else if (node.parentNode._isSplit && !node._isSplit && node.innerHTML !== "") {
wordArray.push(node);
} else if (chars && !node._isSplit) {
if (tag === "span") {
node.style.display = "inline";
}
charArray.push(node);
}
}
i = spaceNodesToRemove.length;
while (--i > -1) {
spaceNodesToRemove[i].parentNode.removeChild(spaceNodesToRemove[i]);
}
if (lines) {
//the next 7 lines just give us the line width in the most reliable way and figure out the left offset (if position isn't relative or absolute). We must set the width along with text-align to ensure everything works properly for various alignments.
if (absolute) {
lineNode = _doc.createElement(tag);
element.appendChild(lineNode);
lineWidth = lineNode.offsetWidth + "px";
offset = (lineNode.offsetParent === element) ? 0 : element.offsetLeft;
element.removeChild(lineNode);
}
style = element.style.cssText;
element.style.cssText = "display:none;"; //to improve performance, set display:none on the element so that the browser doesn't have to worry about reflowing or rendering while we're renesting things. We'll revert the cssText later.
//we can't use element.innerHTML = "" because that causes IE to literally delete all the nodes and their content even though we've stored them in an array! So we must loop through the children and remove them.
while (element.firstChild) {
element.removeChild(element.firstChild);
}
addWordSpaces = (wordDelimiter === " " && (!absolute || (!words && !chars)));
for (i = 0; i < lines.length; i++) {
curLine = lines[i];
lineNode = _doc.createElement(tag);
lineNode.style.cssText = "display:block;text-align:" + textAlign + ";position:" + (absolute ? "absolute;" : "relative;");
if (linesClass) {
lineNode.className = linesClass + (iterateLine ? i+1 : "");
}
lineArray.push(lineNode);
l = curLine.length;
for (j = 0; j < l; j++) {
if (curLine[j].nodeName !== "BR") {
node = curLine[j];
lineNode.appendChild(node);
if (addWordSpaces && node._wordEnd) {
lineNode.appendChild(_doc.createTextNode(" "));
}
if (absolute) {
if (j === 0) {
lineNode.style.top = (node._y) + "px";
lineNode.style.left = (paddingLeft + offset) + "px";
}
node.style.top = "0px";
if (offset) {
node.style.left = (node._x - offset) + "px";
}
}
}
}
if (l === 0) { //if there are no nodes in the line (typically meaning there were two consecutive <br> tags, just add a non-breaking space so that things display properly.
lineNode.innerHTML = "&nbsp;";
} else if (!words && !chars) {
_deWordify(lineNode);
_swapText(lineNode, String.fromCharCode(160), " ");
}
if (absolute) {
lineNode.style.width = lineWidth;
lineNode.style.height = node._h + "px";
}
element.appendChild(lineNode);
}
element.style.cssText = style;
}
//if everything shifts to being position:absolute, the container can collapse in terms of height or width, so fix that here.
if (absolute) {
if (origHeight > element.clientHeight) {
element.style.height = (origHeight - padTopAndBottom) + "px";
if (element.clientHeight < origHeight) { //IE8 and earlier use a different box model - we must include padding and borders
element.style.height = (origHeight + borderTopAndBottom)+ "px";
}
}
if (origWidth > element.clientWidth) {
element.style.width = (origWidth - padLeftAndRight) + "px";
if (element.clientWidth < origWidth) { //IE8 and earlier use a different box model - we must include padding and borders
element.style.width = (origWidth + borderLeftAndRight)+ "px";
}
}
}
_pushReversed(allChars, charArray);
if (words) {
_pushReversed(allWords, wordArray);
}
_pushReversed(allLines, lineArray);
},
_splitRawText = function(element, vars, wordStart, charStart) {
var tag = vars.tag ? vars.tag : (vars.span ? "span" : "div"),
types = vars.type || vars.split || "chars,words,lines",
//words = (types.indexOf("words") !== -1),
chars = (types.indexOf("chars") !== -1),
absolute = (vars.position === "absolute" || vars.absolute === true),
wordDelimiter = vars.wordDelimiter || " ",
space = wordDelimiter !== " " ? "" : (absolute ? "&#173; " : " "),
wordEnd = "</" + tag + ">",
wordIsOpen = true,
specialChars = vars.specialChars ? (typeof(vars.specialChars) === "function" ? vars.specialChars : _findSpecialChars) : null, //specialChars can be an array or a function. For performance reasons, we always set this local "specialChars" to a function to which we pass the remaining text and whatever the original vars.specialChars was so that if it's an array, it works with the _findSpecialChars() function.
text, splitText, i, j, l, character, hasTagStart, emojiPair1, emojiPair2, testResult,
container = _doc.createElement("div"),
parent = element.parentNode;
parent.insertBefore(container, element);
container.textContent = element.nodeValue;
parent.removeChild(element);
element = container;
text = _getText(element);
hasTagStart = text.indexOf("<") !== -1;
if (vars.reduceWhiteSpace !== false) {
text = text.replace(_multipleSpacesExp, " ").replace(_stripExp, "");
}
if (hasTagStart) {
text = text.split("<").join("{{LT}}"); //we can't leave "<" in the string, or when we set the innerHTML, it can be interpreted as a node
}
l = text.length;
splitText = ((text.charAt(0) === " ") ? space : "") + wordStart();
for (i = 0; i < l; i++) {
character = text.charAt(i);
if (specialChars && (testResult = specialChars(text.substr(i), vars.specialChars))) { // look for any specialChars that were declared. Remember, they can be passed in like {specialChars:["मी", "पा", "है"]} or a function could be defined instead. Either way, the function should return the number of characters that should be grouped together for this "character".
character = text.substr(i, testResult || 1);
splitText += (chars && character !== " ") ? charStart() + character + "</" + tag + ">" : character;
i += testResult - 1;
} else if (character === wordDelimiter && text.charAt(i-1) !== wordDelimiter && i) {
splitText += wordIsOpen ? wordEnd : "";
wordIsOpen = false;
while (text.charAt(i + 1) === wordDelimiter) { //skip over empty spaces (to avoid making them words)
splitText += space;
i++;
}
if (i === l-1) {
splitText += space;
} else if (text.charAt(i + 1) !== ")") {
splitText += space + wordStart();
wordIsOpen = true;
}
} else if (character === "{" && text.substr(i, 6) === "{{LT}}") {
splitText += chars ? charStart() + "{{LT}}" + "</" + tag + ">" : "{{LT}}";
i += 5;
} else if ((character.charCodeAt(0) >= _emojiStart && character.charCodeAt(0) <= _emojiEnd) || (text.charCodeAt(i+1) >= 0xFE00 && text.charCodeAt(i+1) <= 0xFE0F)) { //special emoji characters use 2 or 4 unicode characters that we must keep together.
emojiPair1 = _emojiPairCode(text.substr(i, 2));
emojiPair2 = _emojiPairCode(text.substr(i + 2, 2));
j = ((emojiPair1 >= _emojiRegionStart && emojiPair1 <= _emojiRegionEnd && emojiPair2 >= _emojiRegionStart && emojiPair2 <= _emojiRegionEnd) || (emojiPair2 >= _emojiModStart && emojiPair2 <= _emojiModEnd)) ? 4 : 2;
splitText += (chars && character !== " ") ? charStart() + text.substr(i, j) + "</" + tag + ">" : text.substr(i, j);
i += j - 1;
} else {
splitText += (chars && character !== " ") ? charStart() + character + "</" + tag + ">" : character;
}
}
element.outerHTML = splitText + (wordIsOpen ? wordEnd : "");
if (hasTagStart) {
_swapText(parent, "{{LT}}", "<"); //note: don't perform this on "element" because that gets replaced with all new elements when we set element.outerHTML.
}
},
_split = function(element, vars, wordStart, charStart) {
var children = _slice(element.childNodes),
l = children.length,
absolute = (vars.position === "absolute" || vars.absolute === true),
i, child;
if (element.nodeType !== 3 || l > 1) {
vars.absolute = false;
for (i = 0; i < l; i++) {
child = children[i];
if (child.nodeType !== 3 || /\S+/.test(child.nodeValue)) {
if (absolute && child.nodeType !== 3 && _getStyle(child, "display", null, true) === "inline") { //if there's a child node that's display:inline, switch it to inline-block so that absolute positioning works properly (most browsers don't report offsetTop/offsetLeft properly inside a <span> for example)
child.style.display = "inline-block";
child.style.position = "relative";
}
child._isSplit = true;
_split(child, vars, wordStart, charStart); //don't split lines on child elements
}
}
vars.absolute = absolute;
element._isSplit = true;
return;
}
_splitRawText(element, vars, wordStart, charStart);
},
p = SplitText.prototype;
p.split = function(vars) {
if (this.isSplit) {
this.revert();
}
this.vars = vars = vars || this.vars;
this._originals.length = this.chars.length = this.words.length = this.lines.length = 0;
var i = this.elements.length,
tag = vars.tag ? vars.tag : (vars.span ? "span" : "div"),
wordStart = _cssClassFunc(vars.wordsClass, tag),
charStart = _cssClassFunc(vars.charsClass, tag),
origHeight, origWidth, e;
//we split in reversed order so that if/when we position:absolute elements, they don't affect the position of the ones after them in the document flow (shifting them up as they're taken out of the document flow).
while (--i > -1) {
e = this.elements[i];
this._originals[i] = e.innerHTML;
origHeight = e.clientHeight;
origWidth = e.clientWidth;
_split(e, vars, wordStart, charStart);
_setPositionsAfterSplit(e, vars, this.chars, this.words, this.lines, origWidth, origHeight);
}
this.chars.reverse();
this.words.reverse();
this.lines.reverse();
this.isSplit = true;
return this;
};
p.revert = function() {
if (!this._originals) {
throw("revert() call wasn't scoped properly.");
}
var i = this._originals.length;
while (--i > -1) {
this.elements[i].innerHTML = this._originals[i];
}
this.chars = [];
this.words = [];
this.lines = [];
this.isSplit = false;
return this;
};
SplitText.selector = window.$ || window.jQuery || function(e) {
var selector = window.$ || window.jQuery;
if (selector) {
SplitText.selector = selector;
return selector(e);
}
return (typeof(document) === "undefined") ? e : (document.querySelectorAll ? document.querySelectorAll(e) : document.getElementById((e.charAt(0) === "#") ? e.substr(1) : e));
};
SplitText.version = "0.7.0";
})(_gsScope);
export var SplitText = globals.SplitText;
export { SplitText as default };

View File

@ -0,0 +1,726 @@
/*!
* VERSION: 0.11.2
* DATE: 2019-02-07
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* ThrowPropsPlugin is a Club GreenSock membership benefit; You must have a valid membership to use
* this code without violating the terms of use. Visit http://greensock.com/club/ to sign up or get more details.
* This work is subject to the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
import { TweenLite, _gsScope, globals, TweenPlugin, Ease } from "gsap/TweenLite.js";
_gsScope._gsDefine("plugins.ThrowPropsPlugin", ["utils.VelocityTracker", "plugins.TweenPlugin", "TweenLite", "easing.Ease"], function(VelocityTracker) {
var ThrowPropsPlugin = function(props, priority) {
TweenPlugin.call(this, "throwProps");
this._overwriteProps.length = 0;
},
_max = 999999999999999,
_min = 0.0000000001,
_globals = _gsScope._gsDefine.globals,
_recordEndMode = false,//in a typical throwProps css tween that has an "end" defined as a function, it grabs that value initially when the tween is rendered, then again when we calculate the necessary duration, and then a 3rd time after we invalidate() the tween, so we toggle _recordEndMode to true when we're about to begin such a tween which tells the engine to grab the end value(s) once and record them as "max" and "min" on the throwProps object, thus we can skip those extra calls. Then we set it back to false when we're done with our fancy initialization routine.
_transforms = {x:1,y:1,z:2,scale:1,scaleX:1,scaleY:1,rotation:1,rotationZ:1,rotationX:2,rotationY:2,skewX:1,skewY:1,xPercent:1,yPercent:1},
_getClosest = function(n, values, max, min, radius) {
var i = values.length,
closest = 0,
absDif = _max,
val, dif, p, dist;
if (typeof(n) === "object") {
while (--i > -1) {
val = values[i];
dif = 0;
for (p in n) {
dist = val[p] - n[p];
dif += dist * dist;
}
if (dif < absDif) {
closest = i;
absDif = dif;
}
}
if ((radius || _max) < _max && radius < Math.sqrt(absDif)) {
return n;
}
} else {
while (--i > -1) {
val = values[i];
dif = val - n;
if (dif < 0) {
dif = -dif;
}
if (dif < absDif && val >= min && val <= max) {
closest = i;
absDif = dif;
}
}
}
return values[closest];
},
_parseEnd = function(curProp, end, max, min, name, radius) {
if (curProp.end === "auto") {
return curProp;
}
var endVar = curProp.end,
adjustedEnd, p;
max = isNaN(max) ? _max : max;
min = isNaN(min) ? -_max : min;
if (typeof(end) === "object") { //for objects, like {x, y} where they're linked and we must pass an object to the function or find the closest value in an array.
adjustedEnd = end.calculated ? end : ((typeof(endVar) === "function") ? endVar(end) : _getClosest(end, endVar, max, min, radius)) || end;
if (!end.calculated) {
for (p in adjustedEnd) {
end[p] = adjustedEnd[p];
}
end.calculated = true;
}
adjustedEnd = adjustedEnd[name];
} else {
adjustedEnd = (typeof(endVar) === "function") ? endVar(end) : (endVar instanceof Array) ? _getClosest(end, endVar, max, min, radius) : Number(endVar);
}
if (adjustedEnd > max) {
adjustedEnd = max;
} else if (adjustedEnd < min) {
adjustedEnd = min;
}
return {max:adjustedEnd, min:adjustedEnd, unitFactor:curProp.unitFactor};
},
_extend = function(decoratee, extras, exclude) {
for (var p in extras) {
if (decoratee[p] === undefined && p !== exclude) {
decoratee[p] = extras[p];
}
}
return decoratee;
},
_calculateChange = ThrowPropsPlugin.calculateChange = function(velocity, ease, duration, checkpoint) {
if (checkpoint == null) {
checkpoint = 0.05;
}
var e = (ease instanceof Ease) ? ease : (!ease) ? TweenLite.defaultEase : new Ease(ease);
return (duration * checkpoint * velocity) / e.getRatio(checkpoint);
},
_calculateDuration = ThrowPropsPlugin.calculateDuration = function(start, end, velocity, ease, checkpoint) {
checkpoint = checkpoint || 0.05;
var e = (ease instanceof Ease) ? ease : (!ease) ? TweenLite.defaultEase : new Ease(ease);
return Math.abs( (end - start) * e.getRatio(checkpoint) / velocity / checkpoint );
},
_calculateTweenDuration = ThrowPropsPlugin.calculateTweenDuration = function(target, vars, maxDuration, minDuration, overshootTolerance, recordEnd) {
if (typeof(target) === "string") {
target = TweenLite.selector(target);
}
if (!target) {
return 0;
}
if (maxDuration == null) {
maxDuration = 10;
}
if (minDuration == null) {
minDuration = 0.2;
}
if (overshootTolerance == null) {
overshootTolerance = 1;
}
if (target.length) {
target = target[0] || target;
}
var duration = 0,
clippedDuration = 9999999999,
throwPropsVars = vars.throwProps || vars,
ease = (vars.ease instanceof Ease) ? vars.ease : (!vars.ease) ? TweenLite.defaultEase : new Ease(vars.ease),
checkpoint = isNaN(throwPropsVars.checkpoint) ? 0.05 : Number(throwPropsVars.checkpoint),
resistance = isNaN(throwPropsVars.resistance) ? ThrowPropsPlugin.defaultResistance : Number(throwPropsVars.resistance),
p, curProp, curDuration, curVelocity, curResistance, curVal, end, curClippedDuration, tracker, unitFactor,
linkedProps, linkedPropNames, i;
if (throwPropsVars.linkedProps) { //when there are linkedProps (typically "x,y" where snapping has to factor in multiple properties, we must first populate an object with all of those end values, then feed it to the function that make any necessary alterations. So the point of this first loop is to simply build an object (like {x:100, y:204.5}) for feeding into that function which we'll do later in the "real" loop.
linkedPropNames = throwPropsVars.linkedProps.split(",");
linkedProps = {};
for (i = 0; i < linkedPropNames.length; i++) {
p = linkedPropNames[i];
curProp = throwPropsVars[p];
if (curProp) {
if (curProp.velocity !== undefined && typeof(curProp.velocity) === "number") {
curVelocity = Number(curProp.velocity) || 0;
} else {
tracker = tracker || VelocityTracker.getByTarget(target);
curVelocity = (tracker && tracker.isTrackingProp(p)) ? tracker.getVelocity(p) : 0;
}
curResistance = isNaN(curProp.resistance) ? resistance : Number(curProp.resistance);
curDuration = (curVelocity * curResistance > 0) ? curVelocity / curResistance : curVelocity / -curResistance;
curVal = (typeof(target[p]) === "function") ? target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]() : target[p] || 0;
linkedProps[p] = curVal + _calculateChange(curVelocity, ease, curDuration, checkpoint);
}
}
}
for (p in throwPropsVars) {
if (p !== "resistance" && p !== "checkpoint" && p !== "preventOvershoot" && p !== "linkedProps" && p !== "radius") {
curProp = throwPropsVars[p];
if (typeof(curProp) !== "object") {
tracker = tracker || VelocityTracker.getByTarget(target);
if (tracker && tracker.isTrackingProp(p)) {
curProp = (typeof(curProp) === "number") ? {velocity:curProp} : {velocity:tracker.getVelocity(p)}; //if we're tracking this property, we should use the tracking velocity and then use the numeric value that was passed in as the min and max so that it tweens exactly there.
} else {
curVelocity = Number(curProp) || 0;
curDuration = (curVelocity * resistance > 0) ? curVelocity / resistance : curVelocity / -resistance;
}
}
if (typeof(curProp) === "object") {
if (curProp.velocity !== undefined && typeof(curProp.velocity) === "number") {
curVelocity = Number(curProp.velocity) || 0;
} else {
tracker = tracker || VelocityTracker.getByTarget(target);
curVelocity = (tracker && tracker.isTrackingProp(p)) ? tracker.getVelocity(p) : 0;
}
curResistance = isNaN(curProp.resistance) ? resistance : Number(curProp.resistance);
curDuration = (curVelocity * curResistance > 0) ? curVelocity / curResistance : curVelocity / -curResistance;
curVal = (typeof(target[p]) === "function") ? target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]() : target[p] || 0;
end = curVal + _calculateChange(curVelocity, ease, curDuration, checkpoint);
if (curProp.end !== undefined) {
curProp = _parseEnd(curProp, (linkedProps && p in linkedProps) ? linkedProps : end, curProp.max, curProp.min, p, throwPropsVars.radius);
if (recordEnd || _recordEndMode) {
throwPropsVars[p] = _extend(curProp, throwPropsVars[p], "end");
}
}
if (curProp.max !== undefined && end > Number(curProp.max) + _min) {
unitFactor = curProp.unitFactor || ThrowPropsPlugin.defaultUnitFactors[p] || 1; //some values are measured in special units like radians in which case our thresholds need to be adjusted accordingly.
//if the value is already exceeding the max or the velocity is too low, the duration can end up being uncomfortably long but in most situations, users want the snapping to occur relatively quickly (0.75 seconds), so we implement a cap here to make things more intuitive. If the max and min match, it means we're animating to a particular value and we don't want to shorten the time unless the velocity is really slow. Example: a rotation where the start and natural end value are less than the snapping spot, but the natural end is pretty close to the snap.
curClippedDuration = ((curVal > curProp.max && curProp.min !== curProp.max) || (curVelocity * unitFactor > -15 && curVelocity * unitFactor < 45)) ? (minDuration + (maxDuration - minDuration) * 0.1) : _calculateDuration(curVal, curProp.max, curVelocity, ease, checkpoint);
if (curClippedDuration + overshootTolerance < clippedDuration) {
clippedDuration = curClippedDuration + overshootTolerance;
}
} else if (curProp.min !== undefined && end < Number(curProp.min) - _min) {
unitFactor = curProp.unitFactor || ThrowPropsPlugin.defaultUnitFactors[p] || 1; //some values are measured in special units like radians in which case our thresholds need to be adjusted accordingly.
//if the value is already exceeding the min or if the velocity is too low, the duration can end up being uncomfortably long but in most situations, users want the snapping to occur relatively quickly (0.75 seconds), so we implement a cap here to make things more intuitive.
curClippedDuration = ((curVal < curProp.min && curProp.min !== curProp.max) || (curVelocity * unitFactor > -45 && curVelocity * unitFactor < 15)) ? (minDuration + (maxDuration - minDuration) * 0.1) : _calculateDuration(curVal, curProp.min, curVelocity, ease, checkpoint);
if (curClippedDuration + overshootTolerance < clippedDuration) {
clippedDuration = curClippedDuration + overshootTolerance;
}
}
if (curClippedDuration > duration) {
duration = curClippedDuration;
}
}
if (curDuration > duration) {
duration = curDuration;
}
}
}
if (duration > clippedDuration) {
duration = clippedDuration;
}
if (duration > maxDuration) {
return maxDuration;
} else if (duration < minDuration) {
return minDuration;
}
return duration;
},
p = ThrowPropsPlugin.prototype = new TweenPlugin("throwProps"),
_cssProxy, _cssVars, _last, _lastValue; //these serve as a cache of sorts, recording the last css-related proxy and the throwProps vars that get calculated in the _cssRegister() method. This allows us to grab them in the ThrowPropsPlugin.to() function and calculate the duration. Of course we could have structured things in a more "clean" fashion, but performance is of paramount importance.
p.constructor = ThrowPropsPlugin;
ThrowPropsPlugin.version = "0.11.2";
ThrowPropsPlugin.API = 2;
ThrowPropsPlugin._autoCSS = true; //indicates that this plugin can be inserted into the "css" object using the autoCSS feature of TweenLite
ThrowPropsPlugin.defaultResistance = 100;
ThrowPropsPlugin.defaultUnitFactors = {time:1000, totalTime:1000}; //setting the unitFactor to a higher value (default is 1) reduces the chance of the auto-accelerating behavior kicking in when determining durations when the initial velocity is adequately low - imagine dragging something past a boundary and then letting go - snapping back relatively quickly should be prioritized over matching the initial velocity (at least that's the behavior most people consider intuitive). But in some situations when the units are very low (like "time" of a timeline or rotation when using radians), it can kick in too frequently so this allows tweaking.
ThrowPropsPlugin.track = function(target, props, types) {
return VelocityTracker.track(target, props, types);
};
ThrowPropsPlugin.untrack = function(target, props) {
VelocityTracker.untrack(target, props);
};
ThrowPropsPlugin.isTracking = function(target, prop) {
return VelocityTracker.isTracking(target, prop);
};
ThrowPropsPlugin.getVelocity = function(target, prop) {
var vt = VelocityTracker.getByTarget(target);
return vt ? vt.getVelocity(prop) : NaN;
};
ThrowPropsPlugin._cssRegister = function() {
var CSSPlugin = _globals.com.greensock.plugins.CSSPlugin;
if (!CSSPlugin) {
return;
}
var _internals = CSSPlugin._internals,
_parseToProxy = _internals._parseToProxy,
_setPluginRatio = _internals._setPluginRatio,
CSSPropTween = _internals.CSSPropTween;
_internals._registerComplexSpecialProp("throwProps", {parser:function(t, e, prop, cssp, pt, plugin) {
plugin = new ThrowPropsPlugin();
var velocities = {},
min = {},
max = {},
end = {},
res = {},
preventOvershoot = {},
hasResistance, val, p, data, tracker;
_cssVars = {};
for (p in e) {
if (p !== "resistance" && p !== "preventOvershoot" && p !== "linkedProps" && p !== "radius") {
val = e[p];
if (typeof(val) === "object") {
if (val.velocity !== undefined && typeof(val.velocity) === "number") {
velocities[p] = Number(val.velocity) || 0;
} else {
tracker = tracker || VelocityTracker.getByTarget(t);
velocities[p] = (tracker && tracker.isTrackingProp(p)) ? tracker.getVelocity(p) : 0; //rotational values are actually converted to radians in CSSPlugin, but our tracking velocity is in radians already, so make it into degrees to avoid a funky conversion
}
if (val.end !== undefined) {
end[p] = val.end;
}
if (val.min !== undefined) {
min[p] = val.min;
}
if (val.max !== undefined) {
max[p] = val.max;
}
if (val.preventOvershoot) {
preventOvershoot[p] = true;
}
if (val.resistance !== undefined) {
hasResistance = true;
res[p] = val.resistance;
}
} else if (typeof(val) === "number") {
velocities[p] = val;
} else {
tracker = tracker || VelocityTracker.getByTarget(t);
if (tracker && tracker.isTrackingProp(p)) {
velocities[p] = tracker.getVelocity(p);
} else {
velocities[p] = val || 0;
}
}
if (_transforms[p]) {
cssp._enableTransforms((_transforms[p] === 2));
}
}
}
data = _parseToProxy(t, velocities, cssp, pt, plugin);
_cssProxy = data.proxy;
velocities = data.end;
for (p in _cssProxy) {
_cssVars[p] = {velocity:velocities[p], min:min[p], max:max[p], end:end[p], resistance:res[p], preventOvershoot:preventOvershoot[p]};
}
if (e.resistance != null) {
_cssVars.resistance = e.resistance;
}
if (e.linkedProps != null) {
_cssVars.linkedProps = e.linkedProps;
}
if (e.radius != null) {
_cssVars.radius = e.radius;
}
if (e.preventOvershoot) {
_cssVars.preventOvershoot = true;
}
pt = new CSSPropTween(t, "throwProps", 0, 0, data.pt, 2);
cssp._overwriteProps.pop(); //don't overwrite all other throwProps tweens. In the CSSPropTween constructor, we add the property to the _overwriteProps, so remove it here.
pt.plugin = plugin;
pt.setRatio = _setPluginRatio;
pt.data = data;
plugin._onInitTween(_cssProxy, _cssVars, cssp._tween);
return pt;
}});
};
ThrowPropsPlugin.to = function(target, vars, maxDuration, minDuration, overshootTolerance) {
if (!vars.throwProps) {
vars = {throwProps:vars};
}
if (overshootTolerance === 0) {
vars.throwProps.preventOvershoot = true;
}
_recordEndMode = true; //if we encounter a function-based "end" value, ThrowPropsPlugin will record it as "max" and "min" properties, replacing "end" (this is an optimization so that the function only gets called once)
var tween = new TweenLite(target, minDuration || 1, vars);
tween.render(0, true, true); //we force a render so that the CSSPlugin instantiates and populates the _cssProxy and _cssVars which we need in order to calculate the tween duration. Remember, we can't use the regular target for calculating the duration because the current values wouldn't be able to be grabbed like target["propertyName"], as css properties can be complex like boxShadow:"10px 10px 20px 30px red" or backgroundPosition:"25px 50px". The proxy is the result of breaking all that complex data down and finding just the numeric values and assigning them to a generic proxy object with unique names. THAT is what the _calculateTweenDuration() can look at. We also needed to do the same break down of any min or max or velocity data
if (tween.vars.css) {
tween.duration(_calculateTweenDuration(_cssProxy, {throwProps:_cssVars, ease:vars.ease}, maxDuration, minDuration, overshootTolerance));
if (tween._delay && !tween.vars.immediateRender) {
tween.invalidate(); //if there's a delay, the starting values could be off, so invalidate() to force reinstantiation when the tween actually starts.
} else {
_last._onInitTween(_cssProxy, _lastValue, tween);
}
_recordEndMode = false;
return tween;
} else {
tween.kill();
tween = new TweenLite(target, _calculateTweenDuration(target, vars, maxDuration, minDuration, overshootTolerance), vars);
_recordEndMode = false;
return tween;
}
};
p._onInitTween = function(target, value, tween, index) {
this.target = target;
this._props = [];
_last = this;
_lastValue = value;
var ease = tween._ease,
checkpoint = isNaN(value.checkpoint) ? 0.05 : Number(value.checkpoint),
duration = tween._duration,
preventOvershoot = value.preventOvershoot,
cnt = 0,
p, curProp, curVal, isFunc, velocity, change1, end, change2, tracker,
linkedProps, linkedPropNames, i;
if (value.linkedProps) { //when there are linkedProps (typically "x,y" where snapping has to factor in multiple properties, we must first populate an object with all of those end values, then feed it to the function that make any necessary alterations. So the point of this first loop is to simply build an object (like {x:100, y:204.5}) for feeding into that function which we'll do later in the "real" loop.
linkedPropNames = value.linkedProps.split(",");
linkedProps = {};
for (i = 0; i < linkedPropNames.length; i++) {
p = linkedPropNames[i];
curProp = value[p];
if (curProp) {
if (curProp.velocity !== undefined && typeof(curProp.velocity) === "number") {
velocity = Number(curProp.velocity) || 0;
} else {
tracker = tracker || VelocityTracker.getByTarget(target);
velocity = (tracker && tracker.isTrackingProp(p)) ? tracker.getVelocity(p) : 0;
}
curVal = (typeof(target[p]) === "function") ? target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]() : target[p] || 0;
linkedProps[p] = curVal + _calculateChange(velocity, ease, duration, checkpoint);
}
}
}
for (p in value) {
if (p !== "resistance" && p !== "checkpoint" && p !== "preventOvershoot" && p !== "linkedProps" && p !== "radius") {
curProp = value[p];
if (typeof(curProp) === "function") {
curProp = curProp(index, target);
}
if (typeof(curProp) === "number") {
velocity = Number(curProp) || 0;
} else if (typeof(curProp) === "object" && !isNaN(curProp.velocity)) {
velocity = Number(curProp.velocity);
} else {
tracker = tracker || VelocityTracker.getByTarget(target);
if (tracker && tracker.isTrackingProp(p)) {
velocity = tracker.getVelocity(p);
} else {
throw("ERROR: No velocity was defined in the throwProps tween of " + target + " property: " + p);
}
}
change1 = _calculateChange(velocity, ease, duration, checkpoint);
change2 = 0;
isFunc = (typeof(target[p]) === "function");
curVal = (isFunc) ? target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]() : target[p];
if (typeof(curProp) === "object") {
end = curVal + change1;
if (curProp.end !== undefined) {
curProp = _parseEnd(curProp, (linkedProps && p in linkedProps) ? linkedProps : end, curProp.max, curProp.min, p, value.radius);
if (_recordEndMode) {
value[p] = _extend(curProp, value[p], "end");
}
}
if (curProp.max !== undefined && Number(curProp.max) < end) {
if (preventOvershoot || curProp.preventOvershoot) {
change1 = curProp.max - curVal;
} else {
change2 = (curProp.max - curVal) - change1;
}
} else if (curProp.min !== undefined && Number(curProp.min) > end) {
if (preventOvershoot || curProp.preventOvershoot) {
change1 = curProp.min - curVal;
} else {
change2 = (curProp.min - curVal) - change1;
}
}
}
this._overwriteProps[cnt] = p;
this._props[cnt++] = {p:p, s:curVal, c1:change1, c2:change2, f:isFunc, r:false};
}
}
return true;
};
p._kill = function(lookup) {
var i = this._props.length;
while (--i > -1) {
if (lookup[this._props[i].p] != null) {
this._props.splice(i, 1);
}
}
return TweenPlugin.prototype._kill.call(this, lookup);
};
p._mod = function(lookup) {
var p = this._props,
i = p.length,
val;
while (--i > -1) {
val = lookup[p[i].p] || lookup.throwProps;
if (typeof(val) === "function") {
p[i].m = val;
}
}
};
p.setRatio = function(v) {
var i = this._props.length,
cp, val;
while (--i > -1) {
cp = this._props[i];
val = cp.s + cp.c1 * v + cp.c2 * v * v;
if (cp.m) {
val = cp.m(val, this.target);
} else if (v === 1) {
val = ((val * 10000 + (val < 0 ? -0.5 : 0.5)) | 0) / 10000; //if we don't round things at the very end, binary math issues can creep in and cause snapping not to be exact (like landing on 20.000000000001 instead of 20).
}
if (cp.f) {
this.target[cp.p](val);
} else {
this.target[cp.p] = val;
}
}
};
TweenPlugin.activate([ThrowPropsPlugin]);
return ThrowPropsPlugin;
}, true);
/*
* ----------------------------------------------------------------
* VelocityTracker
* ----------------------------------------------------------------
*/
_gsScope._gsDefine("utils.VelocityTracker", ["TweenLite"], function() {
var _first, _initted, _time1, _time2,
_capsExp = /([A-Z])/g,
_empty = {},
_doc = _gsScope.document,
_transforms = {x:1,y:1,z:2,scale:1,scaleX:1,scaleY:1,rotation:1,rotationZ:1,rotationX:2,rotationY:2,skewX:1,skewY:1,xPercent:1,yPercent:1},
_computedStyleScope = (typeof(window) !== "undefined" ? window : _doc.defaultView || {getComputedStyle:function() {}}),
_getComputedStyle = function(e) {
return _computedStyleScope.getComputedStyle(e); //to avoid errors in Microsoft Edge, we need to call getComputedStyle() from a specific scope, typically window.
},
_getStyle = function(t, p, cs) {
var rv = (t._gsTransform || _empty)[p];
if (rv || rv === 0) {
return rv;
} else if (t.style[p]) {
rv = t.style[p];
} else if ((cs = cs || _getComputedStyle(t, null))) {
rv = cs[p] || cs.getPropertyValue(p) || cs.getPropertyValue(p.replace(_capsExp, "-$1").toLowerCase());
} else if (t.currentStyle) {
rv = t.currentStyle[p];
}
return parseFloat(rv) || 0;
},
_ticker = TweenLite.ticker,
VelocityProp = function(p, isFunc, next) {
this.p = p;
this.f = isFunc;
this.v1 = this.v2 = 0;
this.t1 = this.t2 = _ticker.time;
this.css = false;
this.type = "";
this._prev = null;
if (next) {
this._next = next;
next._prev = this;
}
},
_update = function() {
var vt = _first,
t = _ticker.time,
val, vp;
//if the frame rate is too high, we won't be able to track the velocity as well, so only update the values about 33 times per second
if (t - _time1 >= 0.03) {
_time2 = _time1;
_time1 = t;
while (vt) {
vp = vt._firstVP;
while (vp) {
val = vp.css ? _getStyle(vt.target, vp.p) : vp.f ? vt.target[vp.p]() : vt.target[vp.p];
if (val !== vp.v1 || t - vp.t1 > 0.15) { //use a threshold of 0.15 seconds for zeroing-out velocity. If we only use 0.03 and things update slightly slower, like some Android devices dispatch "touchmove" events sluggishly so 2 or 3 ticks of the TweenLite.ticker may elapse inbetween, thus it may appear like the object is not moving but it actually is but it's not updating as frequently. A threshold of 0.15 seconds seems to be a good balance. We want to update things frequently (0.03 seconds) when they're moving so that we can respond to fast motions accurately, but we want to be more resistant to go back to a zero velocity.
vp.v2 = vp.v1;
vp.v1 = val;
vp.t2 = vp.t1;
vp.t1 = t;
}
vp = vp._next;
}
vt = vt._next;
}
}
},
VelocityTracker = function(target) {
this._lookup = {};
this.target = target;
this.elem = (target.style && target.nodeType) ? true : false;
if (!_initted) {
_ticker.addEventListener("tick", _update, null, false, -100);
_time1 = _time2 = _ticker.time;
_initted = true;
}
if (_first) {
this._next = _first;
_first._prev = this;
}
_first = this;
},
getByTarget = VelocityTracker.getByTarget = function(target) {
var vt = _first;
while (vt) {
if (vt.target === target) {
return vt;
}
vt = vt._next;
}
},
p = VelocityTracker.prototype;
p.addProp = function(prop, type) {
if (!this._lookup[prop]) {
var t = this.target,
isFunc = (typeof(t[prop]) === "function"),
alt = isFunc ? this._altProp(prop) : prop,
vp = this._firstVP;
this._firstVP = this._lookup[prop] = this._lookup[alt] = vp = new VelocityProp((alt !== prop && prop.indexOf("set") === 0) ? alt : prop, isFunc, vp);
vp.css = (this.elem && (this.target.style[vp.p] !== undefined || _transforms[vp.p]));
if (vp.css && _transforms[vp.p] && !t._gsTransform) {
TweenLite.set(t, {x:"+=0", overwrite:false}); //just forces CSSPlugin to create a _gsTransform for the element if it doesn't exist
}
vp.type = type || (vp.css && prop.indexOf("rotation") === 0) ? "deg" : "";
vp.v1 = vp.v2 = vp.css ? _getStyle(t, vp.p) : isFunc ? t[vp.p]() : t[vp.p];
}
};
p.removeProp = function(prop) {
var vp = this._lookup[prop];
if (vp) {
if (vp._prev) {
vp._prev._next = vp._next;
} else if (vp === this._firstVP) {
this._firstVP = vp._next;
}
if (vp._next) {
vp._next._prev = vp._prev;
}
this._lookup[prop] = 0;
if (vp.f) {
this._lookup[this._altProp(prop)] = 0; //if it's a getter/setter, we should remove the matching counterpart (if one exists)
}
}
};
p.isTrackingProp = function(prop) {
return (this._lookup[prop] instanceof VelocityProp);
};
p.getVelocity = function(prop) {
var vp = this._lookup[prop],
target = this.target,
val, dif, rotationCap;
if (!vp) {
throw "The velocity of " + prop + " is not being tracked.";
}
val = vp.css ? _getStyle(target, vp.p) : vp.f ? target[vp.p]() : target[vp.p];
dif = (val - vp.v2);
if (vp.type === "rad" || vp.type === "deg") { //rotational values need special interpretation so that if, for example, they go from 179 to -178 degrees it is interpreted as a change of 3 instead of -357.
rotationCap = (vp.type === "rad") ? Math.PI * 2 : 360;
dif = dif % rotationCap;
if (dif !== dif % (rotationCap / 2)) {
dif = (dif < 0) ? dif + rotationCap : dif - rotationCap;
}
}
return dif / (_ticker.time - vp.t2);
};
p._altProp = function(p) { //for getters/setters like getCustomProp() and setCustomProp() - we should accommodate both
var pre = p.substr(0, 3),
alt = ((pre === "get") ? "set" : (pre === "set") ? "get" : pre) + p.substr(3);
return (typeof(this.target[alt]) === "function") ? alt : p;
};
VelocityTracker.getByTarget = function(target) {
var vt = _first;
if (typeof(target) === "string") {
target = TweenLite.selector(target);
}
if (target.length && target !== window && target[0] && target[0].style && !target.nodeType) {
target = target[0];
}
while (vt) {
if (vt.target === target) {
return vt;
}
vt = vt._next;
}
};
VelocityTracker.track = function(target, props, types) {
var vt = getByTarget(target),
a = props.split(","),
i = a.length;
types = (types || "").split(",");
if (!vt) {
vt = new VelocityTracker(target);
}
while (--i > -1) {
vt.addProp(a[i], types[i] || types[0]);
}
return vt;
};
VelocityTracker.untrack = function(target, props) {
var vt = getByTarget(target),
a = (props || "").split(","),
i = a.length;
if (!vt) {
return;
}
while (--i > -1) {
vt.removeProp(a[i]);
}
if (!vt._firstVP || !props) {
if (vt._prev) {
vt._prev._next = vt._next;
} else if (vt === _first) {
_first = vt._next;
}
if (vt._next) {
vt._next._prev = vt._prev;
}
}
};
VelocityTracker.isTracking = function(target, prop) {
var vt = getByTarget(target);
return (!vt) ? false : (!prop && vt._firstVP) ? true : vt.isTrackingProp(prop);
};
return VelocityTracker;
}, true);
export var ThrowPropsPlugin = globals.ThrowPropsPlugin;
export { ThrowPropsPlugin as default };
export var VelocityTracker = globals.com.greensock.utils.VelocityTracker;

View File

@ -0,0 +1,167 @@
/*!
* VERSION: 0.2.1
* DATE: 2018-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
/* eslint-disable */
var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || window; //helps ensure compatibility with AMD/RequireJS and CommonJS/Node
(_gsScope._gsQueue || (_gsScope._gsQueue = [])).push( function() {
"use strict";
_gsScope._gsDefine("easing.CustomBounce", ["easing.CustomEase"], function(CustomEase) {
var _normalizeX = function (a) { //scales all the x values in an array [x, y, x, y...] AND rounds them to the closest hundredth (decimal)
var l = a.length,
s = 1 / a[l - 2],
rnd = 1000,
i;
for (i = 2; i < l; i += 2) {
a[i] = ((a[i] * s * rnd) | 0) / rnd;
}
a[l - 2] = 1; //in case there are any rounding errors. x should always end at 1.
},
CustomBounce = function(id, vars) {
this.vars = vars = vars || {};
if (vars.squash) {
this.squash = new CustomEase(vars.squashID || (id + "-squash"));
}
CustomEase.call(this, id);
this.bounce = this;
this.update(vars);
},
p;
CustomBounce.prototype = p = new CustomEase();
p.constructor = CustomBounce;
p.update = function(vars) {
vars = vars || this.vars;
var max = 0.999,
decay = Math.min(max, vars.strength || 0.7), // Math.min(0.999, 1 - 0.3 / (vars.strength || 1)),
decayX = decay,
gap = (vars.squash || 0) / 100,
originalGap = gap,
slope = 1 / 0.03,
w = 0.2,
h = 1,
prevX = 0.1,
path = [0, 0, 0.07, 0, 0.1, 1, 0.1, 1],
squashPath = [0, 0, 0, 0, 0.1, 0, 0.1, 0],
cp1, cp2, x, y, i, nextX, squishMagnitude;
for (i = 0; i < 200; i++) {
w *= decayX * ((decayX + 1) / 2);
h *= decay * decay;
nextX = prevX + w;
x = prevX + w * 0.49;
y = 1 - h;
cp1 = prevX + h / slope;
cp2 = x + (x - cp1) * 0.8;
if (gap) {
prevX += gap;
cp1 += gap;
x += gap;
cp2 += gap;
nextX += gap;
squishMagnitude = gap / originalGap;
squashPath.push(
prevX - gap, 0,
prevX - gap, squishMagnitude,
prevX - gap / 2, squishMagnitude, //center peak anchor
prevX, squishMagnitude,
prevX, 0,
prevX, 0, //base anchor
prevX, squishMagnitude * -0.6,
prevX + (nextX - prevX) / 6, 0,
nextX, 0
);
path.push(prevX - gap, 1,
prevX, 1,
prevX, 1);
gap *= decay * decay;
}
path.push(prevX, 1,
cp1, y,
x, y,
cp2, y,
nextX, 1,
nextX, 1);
decay *= 0.95;
slope = h / (nextX - cp2);
prevX = nextX;
if (y > max) {
break;
}
}
if (vars.endAtStart) {
x = -0.1;
path.unshift(x, 1, x, 1, -0.07, 0);
if (originalGap) {
gap = originalGap * 2.5; //make the initial anticipation squash longer (more realistic)
x -= gap;
path.unshift(x, 1, x, 1, x, 1);
squashPath.splice(0, 6);
squashPath.unshift(x, 0, x, 0, x, 1, x + gap / 2, 1, x + gap, 1, x + gap, 0, x + gap, 0, x + gap, -0.6, x + gap + 0.033, 0);
for (i = 0; i < squashPath.length; i+=2) {
squashPath[i] -= x;
}
}
for (i = 0; i < path.length; i+=2) {
path[i] -= x;
path[i+1] = 1 - path[i+1];
}
}
if (gap) {
_normalizeX(squashPath);
squashPath[2] = "C" + squashPath[2];
if (!this.squash) {
this.squash = new CustomEase(vars.squashID || (this.id + "-squash"));
}
this.squash.setData("M" + squashPath.join(","));
}
_normalizeX(path);
path[2] = "C" + path[2];
return this.setData("M" + path.join(","));
};
CustomBounce.create = function(id, vars) {
return new CustomBounce(id, vars);
};
CustomBounce.version = "0.2.1";
return CustomBounce;
}, true);
}); if (_gsScope._gsDefine) { _gsScope._gsQueue.pop()(); }
//export to AMD/RequireJS and CommonJS/Node (precursor to full modular build system coming at a later date)
(function(name) {
"use strict";
var getGlobal = function() {
return (_gsScope.GreenSockGlobals || _gsScope)[name];
};
if (typeof(module) !== "undefined" && module.exports) { //node
require("./CustomEase");
require("gsap/umd/TweenLite");
module.exports = getGlobal();
} else if (typeof(define) === "function" && define.amd) { //AMD
define(["gsap/umd/TweenLite", "./CustomEase"], getGlobal);
}
}("CustomBounce"));

View File

@ -0,0 +1,394 @@
/*!
* VERSION: 0.2.2
* DATE: 2018-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
/* eslint-disable */
var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || window; //helps ensure compatibility with AMD/RequireJS and CommonJS/Node
(_gsScope._gsQueue || (_gsScope._gsQueue = [])).push( function() {
"use strict";
_gsScope._gsDefine("easing.CustomEase", ["easing.Ease"], function(Ease) {
var _numbersExp = /(?:(-|-=|\+=)?\d*\.?\d*(?:e[\-+]?\d+)?)[0-9]/ig,
_svgPathExp = /[achlmqstvz]|(-?\d*\.?\d*(?:e[\-+]?\d+)?)[0-9]/ig,
_scientific = /[\+\-]?\d*\.?\d+e[\+\-]?\d+/ig,
_needsParsingExp = /[cLlsS]/g,
_bezierError = "CustomEase only accepts Cubic Bezier data.",
_bezierToPoints = function (x1, y1, x2, y2, x3, y3, x4, y4, threshold, points, index) {
var x12 = (x1 + x2) / 2,
y12 = (y1 + y2) / 2,
x23 = (x2 + x3) / 2,
y23 = (y2 + y3) / 2,
x34 = (x3 + x4) / 2,
y34 = (y3 + y4) / 2,
x123 = (x12 + x23) / 2,
y123 = (y12 + y23) / 2,
x234 = (x23 + x34) / 2,
y234 = (y23 + y34) / 2,
x1234 = (x123 + x234) / 2,
y1234 = (y123 + y234) / 2,
dx = x4 - x1,
dy = y4 - y1,
d2 = Math.abs((x2 - x4) * dy - (y2 - y4) * dx),
d3 = Math.abs((x3 - x4) * dy - (y3 - y4) * dx),
length;
if (!points) {
points = [{x: x1, y: y1}, {x: x4, y: y4}];
index = 1;
}
points.splice(index || points.length - 1, 0, {x: x1234, y: y1234});
if ((d2 + d3) * (d2 + d3) > threshold * (dx * dx + dy * dy)) {
length = points.length;
_bezierToPoints(x1, y1, x12, y12, x123, y123, x1234, y1234, threshold, points, index);
_bezierToPoints(x1234, y1234, x234, y234, x34, y34, x4, y4, threshold, points, index + 1 + (points.length - length));
}
return points;
},
_pathDataToBezier = function (d) {
var a = (d + "").replace(_scientific, function (m) {
var n = +m;
return (n < 0.0001 && n > -0.0001) ? 0 : n;
}).match(_svgPathExp) || [], //some authoring programs spit out very small numbers in scientific notation like "1e-5", so make sure we round that down to 0 first.
path = [],
relativeX = 0,
relativeY = 0,
elements = a.length,
l = 2,
i, x, y, command, isRelative, segment, startX, startY, prevCommand, difX, difY;
for (i = 0; i < elements; i++) {
prevCommand = command;
if (isNaN(a[i])) {
command = a[i].toUpperCase();
isRelative = (command !== a[i]); //lower case means relative
} else { //commands like "C" can be strung together without any new command characters between.
i--;
}
x = +a[i + 1];
y = +a[i + 2];
if (isRelative) {
x += relativeX;
y += relativeY;
}
if (!i) {
startX = x;
startY = y;
}
if (command === "M") {
if (segment && segment.length < 8) { //if the path data was funky and just had a M with no actual drawing anywhere, skip it.
path.length -= 1;
l = 0;
}
relativeX = startX = x;
relativeY = startY = y;
segment = [x, y];
l = 2;
path.push(segment);
i += 2;
command = "L"; //an "M" with more than 2 values gets interpreted as "lineTo" commands ("L").
} else if (command === "C") {
if (!segment) {
segment = [0, 0];
}
segment[l++] = x;
segment[l++] = y;
if (!isRelative) {
relativeX = relativeY = 0;
}
segment[l++] = relativeX + a[i + 3] * 1; //note: "*1" is just a fast/short way to cast the value as a Number. WAAAY faster in Chrome, slightly slower in Firefox.
segment[l++] = relativeY + a[i + 4] * 1;
segment[l++] = relativeX = relativeX + a[i + 5] * 1;
segment[l++] = relativeY = relativeY + a[i + 6] * 1;
i += 6;
} else if (command === "S") {
if (prevCommand === "C" || prevCommand === "S") {
difX = relativeX - segment[l - 4];
difY = relativeY - segment[l - 3];
segment[l++] = relativeX + difX;
segment[l++] = relativeY + difY;
} else {
segment[l++] = relativeX;
segment[l++] = relativeY;
}
segment[l++] = x;
segment[l++] = y;
if (!isRelative) {
relativeX = relativeY = 0;
}
segment[l++] = relativeX = relativeX + a[i + 3] * 1;
segment[l++] = relativeY = relativeY + a[i + 4] * 1;
i += 4;
} else if (command === "L" || command === "Z") {
if (command === "Z") {
x = startX;
y = startY;
segment.closed = true;
}
if (command === "L" || Math.abs(relativeX - x) > 0.5 || Math.abs(relativeY - y) > 0.5) {
segment[l++] = relativeX + (x - relativeX) / 3;
segment[l++] = relativeY + (y - relativeY) / 3;
segment[l++] = relativeX + (x - relativeX) * 2 / 3;
segment[l++] = relativeY + (y - relativeY) * 2 / 3;
segment[l++] = x;
segment[l++] = y;
if (command === "L") {
i += 2;
}
}
relativeX = x;
relativeY = y;
} else {
throw _bezierError;
}
}
return path[0];
},
_findMinimum = function (values) {
var l = values.length,
min = 999999999999,
i;
for (i = 1; i < l; i += 6) {
if (+values[i] < min) {
min = +values[i];
}
}
return min;
},
_normalize = function (values, height, originY) { //takes all the points and translates/scales them so that the x starts at 0 and ends at 1.
if (!originY && originY !== 0) {
originY = Math.max(+values[values.length-1], +values[1]);
}
var tx = +values[0] * -1,
ty = -originY,
l = values.length,
sx = 1 / (+values[l - 2] + tx),
sy = -height || ((Math.abs(+values[l - 1] - +values[1]) < 0.01 * (+values[l - 2] - +values[0])) ? _findMinimum(values) + ty : +values[l - 1] + ty),
i;
if (sy) { //typically y ends at 1 (so that the end values are reached)
sy = 1 / sy;
} else { //in case the ease returns to its beginning value, scale everything proportionally
sy = -sx;
}
for (i = 0; i < l; i += 2) {
values[i] = (+values[i] + tx) * sx;
values[i + 1] = (+values[i + 1] + ty) * sy;
}
},
_getRatio = function (p) {
var point = this.lookup[(p * this.l) | 0] || this.lookup[this.l - 1];
if (point.nx < p) {
point = point.n;
}
return point.y + ((p - point.x) / point.cx) * point.cy;
},
CustomEase = function (id, data, config) {
this._calcEnd = true;
this.id = id;
if (id) {
Ease.map[id] = this;
}
this.getRatio = _getRatio; //speed optimization, faster lookups.
this.setData(data, config);
},
p = CustomEase.prototype = new Ease();
p.constructor = CustomEase;
p.setData = function(data, config) {
data = data || "0,0,1,1";
var values = data.match(_numbersExp),
closest = 1,
points = [],
l, a1, a2, i, inc, j, point, prevPoint, p, precision;
config = config || {};
precision = config.precision || 1;
this.data = data;
this.lookup = [];
this.points = points;
this.fast = (precision <= 1);
if (_needsParsingExp.test(data) || (data.indexOf("M") !== -1 && data.indexOf("C") === -1)) {
values = _pathDataToBezier(data);
}
l = values.length;
if (l === 4) {
values.unshift(0, 0);
values.push(1, 1);
l = 8;
} else if ((l - 2) % 6) {
throw _bezierError;
}
if (+values[0] !== 0 || +values[l - 2] !== 1) {
_normalize(values, config.height, config.originY);
}
this.rawBezier = values;
for (i = 2; i < l; i += 6) {
a1 = {x: +values[i - 2], y: +values[i - 1]};
a2 = {x: +values[i + 4], y: +values[i + 5]};
points.push(a1, a2);
_bezierToPoints(a1.x, a1.y, +values[i], +values[i + 1], +values[i + 2], +values[i + 3], a2.x, a2.y, 1 / (precision * 200000), points, points.length - 1);
}
l = points.length;
for (i = 0; i < l; i++) {
point = points[i];
prevPoint = points[i - 1] || point;
if (point.x > prevPoint.x || (prevPoint.y !== point.y && prevPoint.x === point.x) || point === prevPoint) { //if a point goes BACKWARD in time or is a duplicate, just drop it.
prevPoint.cx = point.x - prevPoint.x; //change in x between this point and the next point (performance optimization)
prevPoint.cy = point.y - prevPoint.y;
prevPoint.n = point;
prevPoint.nx = point.x; //next point's x value (performance optimization, making lookups faster in getRatio()). Remember, the lookup will always land on a spot where it's either this point or the very next one (never beyond that)
if (this.fast && i > 1 && Math.abs(prevPoint.cy / prevPoint.cx - points[i - 2].cy / points[i - 2].cx) > 2) { //if there's a sudden change in direction, prioritize accuracy over speed. Like a bounce ease - you don't want to risk the sampling chunks landing on each side of the bounce anchor and having it clipped off.
this.fast = false;
}
if (prevPoint.cx < closest) {
if (!prevPoint.cx) {
prevPoint.cx = 0.001; //avoids math problems in getRatio() (dividing by zero)
if (i === l - 1) { //in case the final segment goes vertical RIGHT at the end, make sure we end at the end.
prevPoint.x -= 0.001;
closest = Math.min(closest, 0.001);
this.fast = false;
}
} else {
closest = prevPoint.cx;
}
}
} else {
points.splice(i--, 1);
l--;
}
}
l = (1 / closest + 1) | 0;
this.l = l; //record for speed optimization
inc = 1 / l;
j = 0;
point = points[0];
if (this.fast) {
for (i = 0; i < l; i++) { //for fastest lookups, we just sample along the path at equal x (time) distance. Uses more memory and is slightly less accurate for anchors that don't land on the sampling points, but for the vast majority of eases it's excellent (and fast).
p = i * inc;
if (point.nx < p) {
point = points[++j];
}
a1 = point.y + ((p - point.x) / point.cx) * point.cy;
this.lookup[i] = {x: p, cx: inc, y: a1, cy: 0, nx: 9};
if (i) {
this.lookup[i - 1].cy = a1 - this.lookup[i - 1].y;
}
}
this.lookup[l - 1].cy = points[points.length - 1].y - a1;
} else { //this option is more accurate, ensuring that EVERY anchor is hit perfectly. Clipping across a bounce, for example, would never happen.
for (i = 0; i < l; i++) { //build a lookup table based on the smallest distance so that we can instantly find the appropriate point (well, it'll either be that point or the very next one). We'll look up based on the linear progress. So it's it's 0.5 and the lookup table has 100 elements, it'd be like lookup[Math.floor(0.5 * 100)]
if (point.nx < i * inc) {
point = points[++j];
}
this.lookup[i] = point;
}
if (j < points.length - 1) {
this.lookup[i-1] = points[points.length-2];
}
}
this._calcEnd = (points[points.length-1].y !== 1 || points[0].y !== 0); //ensures that we don't run into floating point errors. As long as we're starting at 0 and ending at 1, tell GSAP to skip the final calculation and use 0/1 as the factor.
return this;
};
p.getRatio = _getRatio;
p.getSVGData = function(config) {
return CustomEase.getSVGData(this, config);
};
CustomEase.create = function (id, data, config) {
return new CustomEase(id, data, config);
};
CustomEase.version = "0.2.2";
CustomEase.bezierToPoints = _bezierToPoints;
CustomEase.get = function (id) {
return Ease.map[id];
};
CustomEase.getSVGData = function(ease, config) {
config = config || {};
var rnd = 1000,
width = config.width || 100,
height = config.height || 100,
x = config.x || 0,
y = (config.y || 0) + height,
e = config.path,
a, slope, i, inc, tx, ty, precision, threshold, prevX, prevY;
if (config.invert) {
height = -height;
y = 0;
}
ease = ease.getRatio ? ease : Ease.map[ease] || console.log("No ease found: ", ease);
if (!ease.rawBezier) {
a = ["M" + x + "," + y];
precision = Math.max(5, (config.precision || 1) * 200);
inc = 1 / precision;
precision += 2;
threshold = 5 / precision;
prevX = (((x + inc * width) * rnd) | 0) / rnd;
prevY = (((y + ease.getRatio(inc) * -height) * rnd) | 0) / rnd;
slope = (prevY - y) / (prevX - x);
for (i = 2; i < precision; i++) {
tx = (((x + i * inc * width) * rnd) | 0) / rnd;
ty = (((y + ease.getRatio(i * inc) * -height) * rnd) | 0) / rnd;
if (Math.abs((ty - prevY) / (tx - prevX) - slope) > threshold || i === precision - 1) { //only add points when the slope changes beyond the threshold
a.push(prevX + "," + prevY);
slope = (ty - prevY) / (tx - prevX);
}
prevX = tx;
prevY = ty;
}
} else {
a = [];
precision = ease.rawBezier.length;
for (i = 0; i < precision; i += 2) {
a.push((((x + ease.rawBezier[i] * width) * rnd) | 0) / rnd + "," + (((y + ease.rawBezier[i + 1] * -height) * rnd) | 0) / rnd);
}
a[0] = "M" + a[0];
a[1] = "C" + a[1];
}
if (e) {
(typeof(e) === "string" ? document.querySelector(e) : e).setAttribute("d", a.join(" "));
}
return a.join(" ");
};
return CustomEase;
}, true);
}); if (_gsScope._gsDefine) { _gsScope._gsQueue.pop()(); }
//export to AMD/RequireJS and CommonJS/Node (precursor to full modular build system coming at a later date)
(function(name) {
"use strict";
var getGlobal = function() {
return (_gsScope.GreenSockGlobals || _gsScope)[name];
};
if (typeof(module) !== "undefined" && module.exports) { //node
require("gsap/umd/TweenLite");
module.exports = getGlobal();
} else if (typeof(define) === "function" && define.amd) { //AMD
define(["gsap/umd/TweenLite"], getGlobal);
}
}("CustomEase"));

View File

@ -0,0 +1,128 @@
/*!
* VERSION: 0.2.1
* DATE: 2018-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
/* eslint-disable */
var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || window; //helps ensure compatibility with AMD/RequireJS and CommonJS/Node
(_gsScope._gsQueue || (_gsScope._gsQueue = [])).push( function() {
"use strict";
_gsScope._gsDefine("easing.CustomWiggle", ["easing.CustomEase", "easing.Ease"], function(CustomEase, Ease) {
var eases = {
easeOut: new CustomEase("", "M0,1,C0.7,1,0.6,0,1,0"),
easeInOut: new CustomEase("", "M0,0,C0.104,0,0.242,1,0.444,1,0.644,1,0.608,0,1,0"),
anticipate: new CustomEase("", "M0,0,C0,0.222,0.024,0.386,0.06,0.402,0.181,0.455,0.647,0.646,0.7,0.67,0.9,0.76,1,0.846,1,1"),
uniform: new CustomEase("", "M0,0,C0,0.95,0.01,1,0.01,1,0.01,1,1,1,1,1,1,1,1,0.01,1,0")
},
_linearEase = new CustomEase(), //linear
_parseEase = function(ease, invertNonCustomEases) {
ease = ease.getRatio ? ease : Ease.map[ease] || new CustomEase("", ease);
return (ease.rawBezier || !invertNonCustomEases) ? ease : {getRatio:function(n) { return 1 - ease.getRatio(n); }};
},
CustomWiggle = function(id, vars) {
this.vars = vars || {};
CustomEase.call(this, id);
this.update(this.vars);
},
p;
CustomWiggle.prototype = p = new CustomEase();
p.constructor = CustomWiggle;
p.update = function(vars) {
vars = vars || this.vars;
var wiggles = (vars.wiggles || 10) | 0,
inc = 1 / wiggles,
x = inc / 2,
anticipate = (vars.type === "anticipate"),
yEase = eases[vars.type] || eases.easeOut,
xEase = _linearEase,
rnd = 1000,
nextX, nextY, angle, handleX, handleY, easedX, y, path, i;
if (anticipate) { //the anticipate ease is actually applied on the x-axis (timing) and uses easeOut for amplitude.
xEase = yEase;
yEase = eases.easeOut;
}
if (vars.timingEase) {
xEase = _parseEase(vars.timingEase);
}
if (vars.amplitudeEase) {
yEase = _parseEase(vars.amplitudeEase, true);
}
easedX = xEase.getRatio(x);
y = anticipate ? -yEase.getRatio(x) : yEase.getRatio(x);
path = [0, 0, easedX / 4, 0, easedX / 2, y, easedX, y];
if (vars.type === "random") { //if we just select random values on the y-axis and plug them into the "normal" algorithm, since the control points are always straight horizontal, it creates a bit of a slowdown at each anchor which just didn't seem as desirable, so we switched to an algorithm that bends the control points to be more in line with their context.
path.length = 4;
nextX = xEase.getRatio(inc);
nextY = Math.random() * 2 - 1;
for (i = 2; i < wiggles; i++) {
x = nextX;
y = nextY;
nextX = xEase.getRatio(inc * i);
nextY = Math.random() * 2 - 1;
angle = Math.atan2(nextY - path[path.length - 3], nextX - path[path.length - 4]);
handleX = Math.cos(angle) * inc;
handleY = Math.sin(angle) * inc;
path.push(x - handleX, y - handleY, x, y, x + handleX, y + handleY);
}
path.push(nextX, 0, 1, 0);
} else {
for (i = 1; i < wiggles; i++) {
path.push(xEase.getRatio(x + inc / 2), y);
x += inc;
y = ((y > 0) ? -1 : 1) * (yEase.getRatio(i * inc));
easedX = xEase.getRatio(x);
path.push(xEase.getRatio(x - inc / 2), y, easedX, y);
}
path.push(xEase.getRatio(x + inc / 4), y, xEase.getRatio(x + inc / 4), 0, 1, 0);
}
i = path.length;
while (--i > -1) {
path[i] = ((path[i] * rnd) | 0) / rnd; //round values to avoid odd strings for super tiny values
}
path[2] = "C" + path[2];
this.setData("M" + path.join(","));
};
CustomWiggle.create = function (id, vars) {
return new CustomWiggle(id, vars);
};
CustomWiggle.version = "0.2.1";
CustomWiggle.eases = eases;
return CustomWiggle;
}, true);
}); if (_gsScope._gsDefine) { _gsScope._gsQueue.pop()(); }
//export to AMD/RequireJS and CommonJS/Node (precursor to full modular build system coming at a later date)
(function(name) {
"use strict";
var getGlobal = function() {
return (_gsScope.GreenSockGlobals || _gsScope)[name];
};
if (typeof(module) !== "undefined" && module.exports) { //node
require("./CustomEase");
require("gsap/umd/TweenLite");
module.exports = getGlobal();
} else if (typeof(define) === "function" && define.amd) { //AMD
define(["gsap/umd/TweenLite", "./CustomEase"], getGlobal);
}
}("CustomWiggle"));

View File

@ -0,0 +1,245 @@
/*!
* VERSION: 0.2.1
* DATE: 2019-02-07
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* DrawSVGPlugin is a Club GreenSock membership benefit; You must have a valid membership to use
* this code without violating the terms of use. Visit http://greensock.com/club/ to sign up or get more details.
* This work is subject to the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || window; //helps ensure compatibility with AMD/RequireJS and CommonJS/Node
(_gsScope._gsQueue || (_gsScope._gsQueue = [])).push( function() {
"use strict";
var _doc = _gsScope.document,
_computedStyleScope = (typeof(window) !== "undefined" ? window : _doc.defaultView || {getComputedStyle:function() {}}),
_getComputedStyle = function(e) {
return _computedStyleScope.getComputedStyle(e); //to avoid errors in Microsoft Edge, we need to call getComputedStyle() from a specific scope, typically window.
},
_numbersExp = /(?:(-|-=|\+=)?\d*\.?\d*(?:e[\-+]?\d+)?)[0-9]/ig,
_isEdge = (((_gsScope.navigator || {}).userAgent || "").indexOf("Edge") !== -1), //Microsoft Edge has a bug that causes it not to redraw the path correctly if the stroke-linecap is anything other than "butt" (like "round") and it doesn't match the stroke-linejoin. A way to trigger it is to change the stroke-miterlimit, so we'll only do that if/when we have to (to maximize performance)
_types = {rect:["width","height"], circle:["r","r"], ellipse:["rx","ry"], line:["x2","y2"]},
DrawSVGPlugin;
function getDistance(x1, y1, x2, y2, scaleX, scaleY) {
x2 = (parseFloat(x2 || 0) - parseFloat(x1 || 0)) * scaleX;
y2 = (parseFloat(y2 || 0) - parseFloat(y1 || 0)) * scaleY;
return Math.sqrt(x2 * x2 + y2 * y2);
}
function unwrap(element) {
if (typeof(element) === "string" || !element.nodeType) {
element = _gsScope.TweenLite.selector(element);
if (element.length) {
element = element[0];
}
}
return element;
}
//accepts values like "100%" or "20% 80%" or "20 50" and parses it into an absolute start and end position on the line/stroke based on its length. Returns an an array with the start and end values, like [0, 243]
function parse(value, length, defaultStart) {
var i = value.indexOf(" "),
s, e;
if (i === -1) {
s = defaultStart !== undefined ? defaultStart + "" : value;
e = value;
} else {
s = value.substr(0, i);
e = value.substr(i+1);
}
s = (s.indexOf("%") !== -1) ? (parseFloat(s) / 100) * length : parseFloat(s);
e = (e.indexOf("%") !== -1) ? (parseFloat(e) / 100) * length : parseFloat(e);
return (s > e) ? [e, s] : [s, e];
}
function getLength(element) {
if (!element) {
return 0;
}
element = unwrap(element);
var type = element.tagName.toLowerCase(),
scaleX = 1,
scaleY = 1,
length, bbox, points, prevPoint, i, rx, ry;
if (element.getAttribute("vector-effect") === "non-scaling-stroke") { //non-scaling-stroke basically scales the shape and then strokes it at the screen-level (after transforms), thus we need to adjust the length accordingly.
scaleY = element.getScreenCTM();
scaleX = Math.sqrt(scaleY.a * scaleY.a + scaleY.b * scaleY.b);
scaleY = Math.sqrt(scaleY.d * scaleY.d + scaleY.c * scaleY.c);
}
try { //IE bug: calling <path>.getTotalLength() locks the repaint area of the stroke to whatever its current dimensions are on that frame/tick. To work around that, we must call getBBox() to force IE to recalculate things.
bbox = element.getBBox(); //solely for fixing bug in IE - we don't actually use the bbox.
} catch (e) {
//firefox has a bug that throws an error if the element isn't visible.
console.log("Error: Some browsers like Firefox won't report measurements of invisible elements (like display:none or masks inside defs).");
}
if ((!bbox || (!bbox.width && !bbox.height)) && _types[type]) { //if the element isn't visible, try to discern width/height using its attributes.
bbox = {
width: parseFloat( element.getAttribute(_types[type][0]) ),
height: parseFloat( element.getAttribute(_types[type][1]) )
};
if (type !== "rect" && type !== "line") { //double the radius for circles and ellipses
bbox.width *= 2;
bbox.height *= 2;
}
if (type === "line") {
bbox.x = parseFloat( element.getAttribute("x1") );
bbox.y = parseFloat( element.getAttribute("y1") );
bbox.width = Math.abs(bbox.width - bbox.x);
bbox.height = Math.abs(bbox.height - bbox.y);
}
}
if (type === "path") {
prevPoint = element.style.strokeDasharray;
element.style.strokeDasharray = "none";
length = element.getTotalLength() || 0;
if (scaleX !== scaleY) {
console.log("Warning: <path> length cannot be measured accurately when vector-effect is non-scaling-stroke and the element isn't proportionally scaled.");
}
length *= (scaleX + scaleY) / 2;
element.style.strokeDasharray = prevPoint;
} else if (type === "rect") {
length = bbox.width * 2 * scaleX + bbox.height * 2 * scaleY;
} else if (type === "line") {
length = getDistance(bbox.x, bbox.y, bbox.x + bbox.width, bbox.y + bbox.height, scaleX, scaleY);
} else if (type === "polyline" || type === "polygon") {
points = element.getAttribute("points").match(_numbersExp) || [];
if (type === "polygon") {
points.push(points[0], points[1]);
}
length = 0;
for (i = 2; i < points.length; i+=2) {
length += getDistance(points[i-2], points[i-1], points[i], points[i+1], scaleX, scaleY) || 0;
}
} else if (type === "circle" || type === "ellipse") {
rx = (bbox.width / 2) * scaleX;
ry = (bbox.height / 2) * scaleY;
length = Math.PI * ( 3 * (rx + ry) - Math.sqrt((3 * rx + ry) * (rx + 3 * ry)) );
}
return length || 0;
}
function getPosition(element, length) {
if (!element) {
return [0, 0];
}
element = unwrap(element);
length = length || (getLength(element) + 1);
var cs = _getComputedStyle(element),
dash = cs.strokeDasharray || "",
offset = parseFloat(cs.strokeDashoffset),
i = dash.indexOf(",");
if (i < 0) {
i = dash.indexOf(" ");
}
dash = (i < 0) ? length : parseFloat(dash.substr(0, i)) || 0.00001;
if (dash > length) {
dash = length;
}
return [Math.max(0, -offset), Math.max(0, dash - offset)];
}
DrawSVGPlugin = _gsScope._gsDefine.plugin({
propName: "drawSVG",
API: 2,
version: "0.2.1",
global: true,
overwriteProps: ["drawSVG"],
init: function(target, value, tween, index) {
if (!target.getBBox) {
return false;
}
var length = getLength(target) + 1,
start, end, overage, cs;
this._style = target.style;
this._target = target;
if (typeof(value) === "function") {
value = value(index, target);
}
if (value === true || value === "true") {
value = "0 100%";
} else if (!value) {
value = "0 0";
} else if ((value + "").indexOf(" ") === -1) {
value = "0 " + value;
}
start = getPosition(target, length);
end = parse(value, length, start[0]);
this._length = length + 10;
if (start[0] === 0 && end[0] === 0) {
overage = Math.max(0.00001, end[1] - length); //allow people to go past the end, like values of 105% because for some paths, Firefox doesn't return an accurate getTotalLength(), so it could end up coming up short.
this._dash = length + overage;
this._offset = length - start[1] + overage;
this._offsetPT = this._addTween(this, "_offset", this._offset, length - end[1] + overage, "drawSVG");
} else {
this._dash = (start[1] - start[0]) || 0.000001; //some browsers render artifacts if dash is 0, so we use a very small number in that case.
this._offset = -start[0];
this._dashPT = this._addTween(this, "_dash", this._dash, (end[1] - end[0]) || 0.00001, "drawSVG");
this._offsetPT = this._addTween(this, "_offset", this._offset, -end[0], "drawSVG");
}
if (_isEdge) { //to work around a bug in Microsoft Edge, animate the stroke-miterlimit by 0.0001 just to trigger the repaint (unnecessary if it's "round" and stroke-linejoin is also "round"). Imperceptible, relatively high-performance, and effective. Another option was to set the "d" <path> attribute to its current value on every tick, but that seems like it'd be much less performant.
cs = _getComputedStyle(target);
if (cs.strokeLinecap !== cs.strokeLinejoin) {
end = parseFloat(cs.strokeMiterlimit);
this._addTween(target.style, "strokeMiterlimit", end, end + 0.0001, "strokeMiterlimit");
}
}
this._live = (target.getAttribute("vector-effect") === "non-scaling-stroke" || (value + "").indexOf("live") !== -1);
return true;
},
//called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.)
set: function(ratio) {
if (this._firstPT) {
//when the element has vector-effect="non-scaling-stroke" and the SVG is resized (like on a window resize), it actually changes the length of the stroke! So we must sense that and make the proper adjustments.
if (this._live) {
var length = getLength(this._target) + 11,
lengthRatio;
if (length !== this._length) {
lengthRatio = length / this._length;
this._length = length;
this._offsetPT.s *= lengthRatio;
this._offsetPT.c *= lengthRatio;
if (this._dashPT) {
this._dashPT.s *= lengthRatio;
this._dashPT.c *= lengthRatio;
} else {
this._dash *= lengthRatio;
}
}
}
this._super.setRatio.call(this, ratio);
this._style.strokeDashoffset = this._offset;
if (ratio === 1 || ratio === 0) {
this._style.strokeDasharray = (this._offset < 0.001 && this._length - this._dash <= 10) ? "none" : (this._offset === this._dash) ? "0px, 999999px" : this._dash + "px," + this._length + "px";
} else {
this._style.strokeDasharray = this._dash + "px," + this._length + "px";
}
}
}
});
DrawSVGPlugin.getLength = getLength;
DrawSVGPlugin.getPosition = getPosition;
}); if (_gsScope._gsDefine) { _gsScope._gsQueue.pop()(); }
//export to AMD/RequireJS and CommonJS/Node (precursor to full modular build system coming at a later date)
(function(name) {
"use strict";
var getGlobal = function() {
return (_gsScope.GreenSockGlobals || _gsScope)[name];
};
if (typeof(module) !== "undefined" && module.exports) { //node
require("gsap/umd/TweenLite");
module.exports = getGlobal();
} else if (typeof(define) === "function" && define.amd) { //AMD
define(["gsap/umd/TweenLite"], getGlobal);
}
}("DrawSVGPlugin"));

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,207 @@
/*!
* VERSION: 0.2.1
* DATE: 2018-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* Physics2DPlugin is a Club GreenSock membership benefit; You must have a valid membership to use
* this code without violating the terms of use. Visit http://greensock.com/club/ to sign up or get more details.
* This work is subject to the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || window; //helps ensure compatibility with AMD/RequireJS and CommonJS/Node
(_gsScope._gsQueue || (_gsScope._gsQueue = [])).push( function() {
"use strict";
var _DEG2RAD = Math.PI / 180,
Physics2DProp = function(target, p, velocity, acceleration, stepsPerTimeUnit) {
this.p = p;
this.f = (typeof(target[p]) === "function");
this.start = this.value = (!this.f) ? parseFloat(target[p]) : target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]();
this.velocity = velocity || 0;
this.v = this.velocity / stepsPerTimeUnit;
if (acceleration || acceleration === 0) {
this.acceleration = acceleration;
this.a = this.acceleration / (stepsPerTimeUnit * stepsPerTimeUnit);
} else {
this.acceleration = this.a = 0;
}
},
_random = Math.random(),
_globals = _gsScope._gsDefine.globals,
_rootFramesTimeline = _globals.com.greensock.core.Animation._rootFramesTimeline,
Physics2DPlugin = _gsScope._gsDefine.plugin({
propName: "physics2D",
version: "0.2.1",
API: 2,
//called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
init: function(target, value, tween, index) {
if (typeof(value) === "function") {
value = value(index, target);
}
this._target = target;
this._tween = tween;
this._runBackwards = (tween.vars.runBackwards === true);
this._step = 0;
var tl = tween._timeline,
angle = Number(value.angle) || 0,
velocity = Number(value.velocity) || 0,
acceleration = Number(value.acceleration) || 0,
xProp = value.xProp || "x",
yProp = value.yProp || "y",
aAngle = (value.accelerationAngle || value.accelerationAngle === 0) ? Number(value.accelerationAngle) : angle,
stepsPerTimeUnit;
while (tl._timeline) {
tl = tl._timeline;
}
this._stepsPerTimeUnit = stepsPerTimeUnit = (tl === _rootFramesTimeline) ? 1 : 30;
if (value.gravity) {
acceleration = Number(value.gravity);
aAngle = 90;
}
angle *= _DEG2RAD;
aAngle *= _DEG2RAD;
this._friction = 1 - Number(value.friction || 0);
this._overwriteProps.push(xProp);
this._overwriteProps.push(yProp);
this._x = new Physics2DProp(target, xProp, Math.cos(angle) * velocity, Math.cos(aAngle) * acceleration, stepsPerTimeUnit);
this._y = new Physics2DProp(target, yProp, Math.sin(angle) * velocity, Math.sin(aAngle) * acceleration, stepsPerTimeUnit);
this._skipX = this._skipY = false;
return true;
},
//called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.)
set: function(ratio) {
var time = this._tween._time,
xp = this._x,
yp = this._y,
x, y, tt, steps, remainder, i;
if (this._runBackwards === true) {
time = this._tween._duration - time;
}
if (this._friction === 1) {
tt = time * time * 0.5;
x = xp.start + ((xp.velocity * time) + (xp.acceleration * tt));
y = yp.start + ((yp.velocity * time) + (yp.acceleration * tt));
} else {
time *= this._stepsPerTimeUnit;
steps = i = (time | 0) - this._step;
remainder = (time % 1);
if (i >= 0) { //going forward
while (--i > -1) {
xp.v += xp.a;
yp.v += yp.a;
xp.v *= this._friction;
yp.v *= this._friction;
xp.value += xp.v;
yp.value += yp.v;
}
} else { //going backwards
i = -i;
while (--i > -1) {
xp.value -= xp.v;
yp.value -= yp.v;
xp.v /= this._friction;
yp.v /= this._friction;
xp.v -= xp.a;
yp.v -= yp.a;
}
}
x = xp.value + (xp.v * remainder);
y = yp.value + (yp.v * remainder);
this._step += steps;
}
if (!this._skipX) {
if (xp.m) {
x = xp.m(x, this._target);
}
if (xp.f) {
this._target[xp.p](x);
} else {
this._target[xp.p] = x;
}
}
if (!this._skipY) {
if (yp.m) {
y = yp.m(y, this._target);
}
if (yp.f) {
this._target[yp.p](y);
} else {
this._target[yp.p] = y;
}
}
}
}),
p = Physics2DPlugin.prototype;
p._kill = function(lookup) {
if (lookup[this._x.p] != null) {
this._skipX = true;
}
if (lookup[this._y.p] != null) {
this._skipY = true;
}
return this._super._kill.call(this, lookup);
};
p._mod = function(lookup) {
var val = lookup[this._x.p] || lookup.physics2D;
if (val && typeof(val) === "function") {
this._x.m = val;
}
val = lookup[this._y.p] || lookup.physics2D;
if (val && typeof(val) === "function") {
this._y.m = val;
}
};
Physics2DPlugin._autoCSS = true; //indicates that this plugin can be inserted into the "css" object using the autoCSS feature of TweenLite
Physics2DPlugin._cssRegister = function() {
var CSSPlugin = _globals.CSSPlugin;
if (!CSSPlugin) {
return;
}
var _internals = CSSPlugin._internals,
_parseToProxy = _internals._parseToProxy,
_setPluginRatio = _internals._setPluginRatio,
CSSPropTween = _internals.CSSPropTween;
_internals._registerComplexSpecialProp("physics2D", {parser:function(t, e, prop, cssp, pt, plugin) {
plugin = new Physics2DPlugin();
var xProp = e.xProp || "x",
yProp = e.yProp || "y",
vars = {},
data;
vars[xProp] = vars[yProp] = _random++; //doesn't really matter what values we put here because the plugin will determine end values, but it'd be best of the values don't match the current ones so that CSSPlugin doesn't skip creating a CSSPropTween.
data = _parseToProxy(t, vars, cssp, pt, plugin);
pt = new CSSPropTween(t, "physics2D", 0, 0, data.pt, 2);
pt.data = data;
pt.plugin = plugin;
pt.setRatio = _setPluginRatio;
plugin._onInitTween(data.proxy, e, cssp._tween);
return pt;
}});
};
}); if (_gsScope._gsDefine) { _gsScope._gsQueue.pop()(); }
//export to AMD/RequireJS and CommonJS/Node (precursor to full modular build system coming at a later date)
(function(name) {
"use strict";
var getGlobal = function() {
return (_gsScope.GreenSockGlobals || _gsScope)[name];
};
if (typeof(module) !== "undefined" && module.exports) { //node
require("gsap/umd/TweenLite");
module.exports = getGlobal();
} else if (typeof(define) === "function" && define.amd) { //AMD
define(["gsap/umd/TweenLite"], getGlobal);
}
}("Physics2DPlugin"));

View File

@ -0,0 +1,215 @@
/*!
* VERSION: 0.2.1
* DATE: 2018-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* PhysicsPropsPlugin is a Club GreenSock membership benefit; You must have a valid membership to use
* this code without violating the terms of use. Visit http://greensock.com/club/ to sign up or get more details.
* This work is subject to the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || window; //helps ensure compatibility with AMD/RequireJS and CommonJS/Node
(_gsScope._gsQueue || (_gsScope._gsQueue = [])).push( function() {
"use strict";
var PhysicsProp = function(target, p, velocity, acceleration, friction, stepsPerTimeUnit) {
this.p = p;
this.f = (typeof(target[p]) === "function");
this.start = this.value = (!this.f) ? parseFloat(target[p]) : target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]();
this.velocity = velocity || 0;
this.v = this.velocity / stepsPerTimeUnit;
if (acceleration || acceleration == 0) {
this.acceleration = acceleration;
this.a = this.acceleration / (stepsPerTimeUnit * stepsPerTimeUnit);
} else {
this.acceleration = this.a = 0;
}
this.friction = 1 - (friction || 0) ;
},
_random = Math.random(),
_globals = _gsScope._gsDefine.globals,
_rootFramesTimeline = _globals.com.greensock.core.Animation._rootFramesTimeline,
PhysicsPropsPlugin = _gsScope._gsDefine.plugin({
propName: "physicsProps",
version: "0.2.1",
API: 2,
//called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
init: function(target, value, tween, index) {
if (typeof(value) === "function") {
value = value(target);
}
this._target = target;
this._tween = tween;
this._runBackwards = (tween.vars.runBackwards === true);
this._step = 0;
var tl = tween._timeline,
cnt = 0,
p, curProp;
while (tl._timeline) {
tl = tl._timeline;
}
this._stepsPerTimeUnit = (tl === _rootFramesTimeline) ? 1 : 30;
this._props = [];
for (p in value) {
curProp = value[p];
if (typeof(curProp) === "function") {
curProp = curProp(index, target);
}
if (curProp.velocity || curProp.acceleration) {
this._props[cnt++] = new PhysicsProp(target, p, curProp.velocity, curProp.acceleration, curProp.friction, this._stepsPerTimeUnit);
this._overwriteProps[cnt] = p;
if (curProp.friction) {
this._hasFriction = true;
}
}
}
return true;
},
//called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.)
set: function(ratio) {
var i = this._props.length,
time = this._tween._time,
target = this._target,
curProp, val, steps, remainder, j, tt;
if (this._runBackwards) {
time = this._tween._duration - time;
}
if (this._hasFriction) {
time *= this._stepsPerTimeUnit;
steps = (time | 0) - this._step;
remainder = time % 1;
if (steps >= 0) { //going forward
while (--i > -1) {
curProp = this._props[i];
j = steps;
while (--j > -1) {
curProp.v += curProp.a;
curProp.v *= curProp.friction;
curProp.value += curProp.v;
}
val = curProp.value + (curProp.v * remainder);
if (curProp.m) {
val = curProp.m(val, target);
}
if (curProp.f) {
target[curProp.p](val);
} else {
target[curProp.p] = val;
}
}
} else { //going backwards
while (--i > -1) {
curProp = this._props[i];
j = -steps;
while (--j > -1) {
curProp.value -= curProp.v;
curProp.v /= curProp.friction;
curProp.v -= curProp.a;
}
val = curProp.value + (curProp.v * remainder);
if (curProp.m) {
val = curProp.m(val, target);
}
if (curProp.f) {
target[curProp.p](val);
} else {
target[curProp.p] = val;
}
}
}
this._step += steps;
} else {
tt = time * time * 0.5;
while (--i > -1) {
curProp = this._props[i];
val = curProp.start + ((curProp.velocity * time) + (curProp.acceleration * tt));
if (curProp.m) {
val = curProp.m(val, target);
}
if (curProp.f) {
target[curProp.p](val);
} else {
target[curProp.p] = val;
}
}
}
}
}),
p = PhysicsPropsPlugin.prototype;
p._kill = function(lookup) {
var i = this._props.length;
while (--i > -1) {
if (this._props[i].p in lookup) {
this._props.splice(i, 1);
}
}
return this._super._kill.call(this, lookup);
};
p._mod = function(lookup) {
var i = this._props.length,
val;
while (--i > -1) {
val = lookup[this._props[i].p] || lookup.physicsProps;
if (typeof(val) === "function") {
this._props[i].m = val;
}
}
};
PhysicsPropsPlugin._autoCSS = true; //indicates that this plugin can be inserted into the "css" object using the autoCSS feature of TweenLite
PhysicsPropsPlugin._cssRegister = function() {
var CSSPlugin = _globals.CSSPlugin;
if (!CSSPlugin) {
return;
}
var _internals = CSSPlugin._internals,
_parseToProxy = _internals._parseToProxy,
_setPluginRatio = _internals._setPluginRatio,
CSSPropTween = _internals.CSSPropTween;
_internals._registerComplexSpecialProp("physicsProps", {parser:function(t, e, prop, cssp, pt, plugin) {
plugin = new PhysicsPropsPlugin();
var vars = {},
p, data;
if (e.scale) {
e.scaleX = e.scaleY = e.scale;
delete e.scale;
}
for (p in e) {
vars[p] = _random++; //doesn't really matter what values we put here because the plugin will determine end values, but it'd be best of the values don't match the current ones so that CSSPlugin doesn't skip creating a CSSPropTween.
}
data = _parseToProxy(t, vars, cssp, pt, plugin);
pt = new CSSPropTween(t, "physicsProps", 0, 0, data.pt, 2);
pt.data = data;
pt.plugin = plugin;
pt.setRatio = _setPluginRatio;
plugin._onInitTween(data.proxy, e, cssp._tween);
return pt;
}});
};
}); if (_gsScope._gsDefine) { _gsScope._gsQueue.pop()(); }
//export to AMD/RequireJS and CommonJS/Node (precursor to full modular build system coming at a later date)
(function(name) {
"use strict";
var getGlobal = function() {
return (_gsScope.GreenSockGlobals || _gsScope)[name];
};
if (typeof(module) !== "undefined" && module.exports) { //node
require("gsap/umd/TweenLite");
module.exports = getGlobal();
} else if (typeof(define) === "function" && define.amd) { //AMD
define(["gsap/umd/TweenLite"], getGlobal);
}
}("PhysicsPropsPlugin"));

View File

@ -0,0 +1,231 @@
/*!
* VERSION: 0.5.2
* DATE: 2019-02-07
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* ScrambleTextPlugin is a Club GreenSock membership benefit; You must have a valid membership to use
* this code without violating the terms of use. Visit http://greensock.com/club/ to sign up or get more details.
* This work is subject to the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || window; //helps ensure compatibility with AMD/RequireJS and CommonJS/Node
(_gsScope._gsQueue || (_gsScope._gsQueue = [])).push( function() {
"use strict";
var _trimExp = /(^\s+|\s+$)/g,
_spacesExp = /\s+/g,
_getText = function(e) {
var type = e.nodeType,
result = "";
if (type === 1 || type === 9 || type === 11) {
if (typeof(e.textContent) === "string") {
return e.textContent;
} else {
for (e = e.firstChild; e; e = e.nextSibling ) {
result += _getText(e);
}
}
} else if (type === 3 || type === 4) {
return e.nodeValue;
}
return result;
},
_scrambleText = function(length, chars) {
var l = chars.length,
s = "";
while (--length > -1) {
s += chars[ ((Math.random() * l) | 0) ];
}
return s;
},
CharSet = function(chars) {
this.chars = _emojiSafeSplit(chars);
this.sets = [];
this.length = 50;
var i;
for (i = 0; i < 20; i++) {
this.sets[i] = _scrambleText(80, this.chars); //we create 20 strings that are 80 characters long, randomly chosen and pack them into an array. We then randomly choose the scrambled text from this array in order to greatly improve efficiency compared to creating new randomized text from scratch each and every time it's needed. This is a simple lookup whereas the other technique requires looping through as many times as there are characters needed, and calling Math.random() each time through the loop, building the string, etc.
}
this.grow = function(newLength) { //if we encounter a tween that has more than 80 characters, we'll need to add to the character sets accordingly. Once it's cached, it'll only need to grow again if we exceed that new length. Again, this is an efficiency tactic.
for (i = 0; i < 20; i++) {
this.sets[i] += _scrambleText(newLength - this.length, this.chars);
}
this.length = newLength;
};
},
_emoji = "[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2694-\u2697]|\uD83E[\uDD10-\uDD5D]|[\uD800-\uDBFF][\uDC00-\uDFFF]",
_emojiExp = new RegExp(_emoji),
_emojiAndCharsExp = new RegExp(_emoji + "|.", "g"),
_emojiSafeSplit = function(text, delimiter, trim) {
if (trim) {
text = text.replace(_trimExp, "");
}
return ((delimiter === "" || !delimiter) && _emojiExp.test(text)) ? text.match(_emojiAndCharsExp) : text.split(delimiter || "");
},
_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
_lower = _upper.toLowerCase(),
_charsLookup = {
upperCase: new CharSet(_upper),
lowerCase: new CharSet(_lower),
upperAndLowerCase: new CharSet(_upper + _lower)
},
ScrambleTextPlugin = _gsScope._gsDefine.plugin({
propName: "scrambleText",
version: "0.5.2",
API: 2,
overwriteProps:["scrambleText","text"],
//called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
init: function(target, value, tween, index) {
this._prop = ("innerHTML" in target) ? "innerHTML" : ("textContent" in target) ? "textContent" : 0; // SVG text in IE doesn't have innerHTML, but it does have textContent.
if (!this._prop) {
return false;
}
if (typeof(value) === "function") {
value = value(index, target);
}
this._target = target;
if (typeof(value) !== "object") {
value = {text:value};
}
var text = value.text || value.value,
trim = (value.trim !== false),
delim, maxLength, charset, splitByChars;
this._delimiter = delim = value.delimiter || "";
this._original = _emojiSafeSplit(_getText(target).replace(_spacesExp, " ").split("&nbsp;").join(""), delim, trim);
if (text === "{original}" || text === true || text == null) {
text = this._original.join(delim);
}
this._text = _emojiSafeSplit((text || "").replace(_spacesExp, " "), delim, trim);
this._hasClass = false;
if (typeof(value.newClass) === "string") {
this._newClass = value.newClass;
this._hasClass = true;
}
if (typeof(value.oldClass) === "string") {
this._oldClass = value.oldClass;
this._hasClass = true;
}
splitByChars = (delim === "");
this._textHasEmoji = (_emojiExp.test(this._text.join(delim)) && splitByChars);
this._charsHaveEmoji = !!value.chars && _emojiExp.test(value.chars);
this._length = splitByChars ? this._original.length : this._original.join(delim).length;
this._lengthDif = (splitByChars ? this._text.length : this._text.join(delim).length) - this._length;
this._fillChar = value.fillChar || (value.chars && value.chars.indexOf(" ") !== -1) ? "&nbsp;" : "";
this._charSet = charset = _charsLookup[(value.chars || "upperCase")] || new CharSet(value.chars);
this._speed = 0.016 / (value.speed || 1);
this._prevScrambleTime = 0;
this._setIndex = (Math.random() * 20) | 0;
maxLength = this._length + Math.max(this._lengthDif, 0);
if (maxLength > charset.length) {
charset.grow(maxLength);
}
this._chars = charset.sets[this._setIndex];
this._revealDelay = value.revealDelay || 0;
this._tweenLength = (value.tweenLength !== false);
this._tween = tween;
this._rightToLeft = !!value.rightToLeft;
return true;
},
//called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.)
set: function(ratio) {
var l = this._text.length,
delim = this._delimiter,
time = this._tween._time,
timeDif = time - this._prevScrambleTime,
i, i2, startText, endText, applyNew, applyOld, str, startClass, endClass;
if (this._revealDelay) {
if (this._tween.vars.runBackwards) {
time = this._tween._duration - time; //invert the time for from() tweens
}
ratio = (time === 0) ? 0 : (time < this._revealDelay) ? 0.000001 : (time === this._tween._duration) ? 1 : this._tween._ease.getRatio((time - this._revealDelay) / (this._tween._duration - this._revealDelay));
}
if (ratio < 0) {
ratio = 0;
} else if (ratio > 1) {
ratio = 1;
}
if (this._rightToLeft) {
ratio = 1 - ratio;
}
i = (ratio * l + 0.5) | 0;
if (ratio) {
if (timeDif > this._speed || timeDif < -this._speed) {
this._setIndex = (this._setIndex + ((Math.random() * 19) | 0)) % 20;
this._chars = this._charSet.sets[this._setIndex];
this._prevScrambleTime += timeDif;
}
endText = this._chars;
} else {
endText = this._original.join(delim);
}
if (this._rightToLeft) {
if (ratio === 1 && (this._tween.vars.runBackwards || this._tween.data === "isFromStart")) { //special case for from() tweens
startText = "";
endText = this._original.join(delim);
} else {
str = this._text.slice(i).join(delim);
if (this._charsHaveEmoji) {
startText = _emojiSafeSplit(endText).slice(0, ((this._length + (this._tweenLength ? 1 - (ratio * ratio * ratio) : 1) * this._lengthDif) - ((this._textHasEmoji ? _emojiSafeSplit(str) : str).length) + 0.5) | 0).join("");
} else {
startText = endText.substr(0, ((this._length + (this._tweenLength ? 1 - (ratio * ratio * ratio) : 1) * this._lengthDif) - ((this._textHasEmoji ? _emojiSafeSplit(str) : str).length) + 0.5) | 0);
}
endText = str;
}
} else {
startText = this._text.slice(0, i).join(delim);
i2 = (this._textHasEmoji ? _emojiSafeSplit(startText) : startText).length;
if (this._charsHaveEmoji) {
endText = _emojiSafeSplit(endText).slice(i2, ((this._length + (this._tweenLength ? 1 - ((ratio = 1 - ratio) * ratio * ratio * ratio) : 1) * this._lengthDif) + 0.5) | 0).join("");
} else {
endText = endText.substr(i2, ((this._length + (this._tweenLength ? 1 - ((ratio = 1 - ratio) * ratio * ratio * ratio) : 1) * this._lengthDif) - i2 + 0.5) | 0);
}
}
if (this._hasClass) {
startClass = this._rightToLeft ? this._oldClass : this._newClass;
endClass = this._rightToLeft ? this._newClass : this._oldClass;
applyNew = (startClass && i !== 0);
applyOld = (endClass && i !== l);
str = (applyNew ? "<span class='" + startClass + "'>" : "") + startText + (applyNew ? "</span>" : "") + (applyOld ? "<span class='" + endClass + "'>" : "") + delim + endText + (applyOld ? "</span>" : "");
} else {
str = startText + delim + endText;
}
this._target[this._prop] = (this._fillChar === "&nbsp;" && str.indexOf(" ") !== -1) ? str.split(" ").join("&nbsp;&nbsp;") : str;
}
}),
p = ScrambleTextPlugin.prototype;
p._newClass = p._oldClass = "";
for (p in _charsLookup) {
_charsLookup[p.toLowerCase()] = _charsLookup[p];
_charsLookup[p.toUpperCase()] = _charsLookup[p];
}
}); if (_gsScope._gsDefine) { _gsScope._gsQueue.pop()(); }
//export to AMD/RequireJS and CommonJS/Node (precursor to full modular build system coming at a later date)
(function(name) {
"use strict";
var getGlobal = function() {
return (_gsScope.GreenSockGlobals || _gsScope)[name];
};
if (typeof(module) !== "undefined" && module.exports) { //node
require("gsap/umd/TweenLite");
module.exports = getGlobal();
} else if (typeof(define) === "function" && define.amd) { //AMD
define(["gsap/umd/TweenLite"], getGlobal);
}
}("ScrambleTextPlugin"));

View File

@ -0,0 +1,573 @@
/*!
* VERSION: 0.7.0
* DATE: 2019-02-07
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* SplitText is a Club GreenSock membership benefit; You must have a valid membership to use
* this code without violating the terms of use. Visit http://greensock.com/club/ to sign up or get more details.
* This work is subject to the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || window; //helps ensure compatibility with AMD/RequireJS and CommonJS/Node
(function(window) {
"use strict";
var _globals = window.GreenSockGlobals || window,
_namespace = function(ns) {
var a = ns.split("."),
p = _globals, i;
for (i = 0; i < a.length; i++) {
p[a[i]] = p = p[a[i]] || {};
}
return p;
},
pkg = _namespace("com.greensock.utils"),
_getText = function(e) {
var type = e.nodeType,
result = "";
if (type === 1 || type === 9 || type === 11) {
if (typeof(e.textContent) === "string") {
return e.textContent;
} else {
for ( e = e.firstChild; e; e = e.nextSibling ) {
result += _getText(e);
}
}
} else if (type === 3 || type === 4) {
return e.nodeValue;
}
return result;
},
_doc = _gsScope.document || {},
_computedStyleScope = (typeof(window) !== "undefined" ? window : _doc.defaultView || {getComputedStyle:function() {}}),
_getComputedStyle = function(e) {
return _computedStyleScope.getComputedStyle(e); //to avoid errors in Microsoft Edge, we need to call getComputedStyle() from a specific scope, typically window.
},
_capsExp = /([A-Z])/g,
_getStyle = function(t, p, cs, str) {
var result;
if ((cs = cs || _getComputedStyle(t, null))) {
t = cs.getPropertyValue(p.replace(_capsExp, "-$1").toLowerCase());
result = (t || cs.length) ? t : cs[p]; //Opera behaves VERY strangely - length is usually 0 and cs[p] is the only way to get accurate results EXCEPT when checking for -o-transform which only works with cs.getPropertyValue()!
} else if (t.currentStyle) {
cs = t.currentStyle;
result = cs[p];
}
return str ? result : parseInt(result, 10) || 0;
},
_isArrayLike = function(e) {
return (e.length && e[0] && ((e[0].nodeType && e[0].style && !e.nodeType) || (e[0].length && e[0][0]))) ? true : false; //could be an array of jQuery objects too, so accommodate that.
},
_flattenArray = function(a) {
var result = [],
l = a.length,
i, e, j;
for (i = 0; i < l; i++) {
e = a[i];
if (_isArrayLike(e)) {
j = e.length;
for (j = 0; j < e.length; j++) {
result.push(e[j]);
}
} else {
result.push(e);
}
}
return result;
},
//some characters are combining marks (think diacritics/accents in European languages) which involve 2 or 4 characters that combine in the browser to form a single character. Pass in the remaining text and an array of the special characters to search for and if the text starts with one of those special characters, it'll spit back the number of characters to retain (often 2 or 4). Used in the specialChars features that was introduced in 0.6.0.
_findSpecialChars = function(text, chars) {
var i = chars.length,
s;
while (--i > -1) {
s = chars[i];
if (text.substr(0, s.length) === s) {
return s.length;
}
}
},
_stripExp = /(?:\r|\n|\t\t)/g, //find carriage returns, new line feeds and double-tabs.
_multipleSpacesExp = /(?:\s\s+)/g,
_emojiStart = 0xD800,
_emojiEnd = 0xDBFF,
_emojiLowStart = 0xDC00,
_emojiRegionStart = 0x1F1E6,
_emojiRegionEnd = 0x1F1FF,
_emojiModStart = 0x1f3fb,
_emojiModEnd = 0x1f3ff,
_emojiPairCode = function(s) {
return ((s.charCodeAt(0) - _emojiStart) << 10) + (s.charCodeAt(1) - _emojiLowStart) + 0x10000;
},
_isOldIE = (_doc.all && !_doc.addEventListener),
_divStart = " style='position:relative;display:inline-block;" + (_isOldIE ? "*display:inline;*zoom:1;'" : "'"), //note: we must use both display:inline-block and *display:inline for IE8 and earlier, otherwise it won't flow correctly (and if we only use display:inline, IE won't render most of the property tweens - very odd).
_cssClassFunc = function(cssClass, tag) {
cssClass = cssClass || "";
var iterate = (cssClass.indexOf("++") !== -1),
num = 1;
if (iterate) {
cssClass = cssClass.split("++").join("");
}
return function() {
return "<" + tag + _divStart + (cssClass ? " class='" + cssClass + (iterate ? num++ : "") + "'>" : ">");
};
},
SplitText = pkg.SplitText = _globals.SplitText = function(element, vars) {
if (typeof(element) === "string") {
element = SplitText.selector(element);
}
if (!element) {
throw("cannot split a null element.");
}
this.elements = _isArrayLike(element) ? _flattenArray(element) : [element];
this.chars = [];
this.words = [];
this.lines = [];
this._originals = [];
this.vars = vars || {};
this.split(vars);
},
_swapText = function(element, oldText, newText) {
var type = element.nodeType;
if (type === 1 || type === 9 || type === 11) {
for (element = element.firstChild; element; element = element.nextSibling) {
_swapText(element, oldText, newText);
}
} else if (type === 3 || type === 4) {
element.nodeValue = element.nodeValue.split(oldText).join(newText);
}
},
_pushReversed = function(a, merge) {
var i = merge.length;
while (--i > -1) {
a.push(merge[i]);
}
},
_slice = function(a) { //don't use Array.prototype.slice.call(target, 0) because that doesn't work in IE8 with a NodeList that's returned by querySelectorAll()
var b = [],
l = a.length,
i;
for (i = 0; i !== l; b.push(a[i++])) {}
return b;
},
_isBeforeWordDelimiter = function(e, root, wordDelimiter) {
var next;
while (e && e !== root) {
next = e._next || e.nextSibling;
if (next) {
return next.textContent.charAt(0) === wordDelimiter;
}
e = e.parentNode || e._parent;
}
return false;
},
_deWordify = function(e) {
var children = _slice(e.childNodes),
l = children.length,
i, child;
for (i = 0; i < l; i++) {
child = children[i];
if (child._isSplit) {
_deWordify(child);
} else {
if (i && child.previousSibling.nodeType === 3) {
child.previousSibling.nodeValue += (child.nodeType === 3) ? child.nodeValue : child.firstChild.nodeValue;
} else if (child.nodeType !== 3) {
e.insertBefore(child.firstChild, child);
}
e.removeChild(child);
}
}
},
_setPositionsAfterSplit = function(element, vars, allChars, allWords, allLines, origWidth, origHeight) {
var cs = _getComputedStyle(element),
paddingLeft = _getStyle(element, "paddingLeft", cs),
lineOffsetY = -999,
borderTopAndBottom = _getStyle(element, "borderBottomWidth", cs) + _getStyle(element, "borderTopWidth", cs),
borderLeftAndRight = _getStyle(element, "borderLeftWidth", cs) + _getStyle(element, "borderRightWidth", cs),
padTopAndBottom = _getStyle(element, "paddingTop", cs) + _getStyle(element, "paddingBottom", cs),
padLeftAndRight = _getStyle(element, "paddingLeft", cs) + _getStyle(element, "paddingRight", cs),
lineThreshold = _getStyle(element, "fontSize") * 0.2,
textAlign = _getStyle(element, "textAlign", cs, true),
charArray = [],
wordArray = [],
lineArray = [],
wordDelimiter = vars.wordDelimiter || " ",
tag = vars.tag ? vars.tag : (vars.span ? "span" : "div"),
types = vars.type || vars.split || "chars,words,lines",
lines = (allLines && types.indexOf("lines") !== -1) ? [] : null,
words = (types.indexOf("words") !== -1),
chars = (types.indexOf("chars") !== -1),
absolute = (vars.position === "absolute" || vars.absolute === true),
linesClass = vars.linesClass,
iterateLine = ((linesClass || "").indexOf("++") !== -1),
spaceNodesToRemove = [],
i, j, l, node, nodes, isChild, curLine, addWordSpaces, style, lineNode, lineWidth, offset;
if (iterateLine) {
linesClass = linesClass.split("++").join("");
}
//copy all the descendant nodes into an array (we can't use a regular nodeList because it's live and we may need to renest things)
j = element.getElementsByTagName("*");
l = j.length;
nodes = [];
for (i = 0; i < l; i++) {
nodes[i] = j[i];
}
//for absolute positioning, we need to record the x/y offsets and width/height for every <div>. And even if we're not positioning things absolutely, in order to accommodate lines, we must figure out where the y offset changes so that we can sense where the lines break, and we populate the lines array.
if (lines || absolute) {
for (i = 0; i < l; i++) {
node = nodes[i];
isChild = (node.parentNode === element);
if (isChild || absolute || (chars && !words)) {
offset = node.offsetTop;
if (lines && isChild && Math.abs(offset - lineOffsetY) > lineThreshold && (node.nodeName !== "BR" || i === 0)) { //we found some rare occasions where a certain character like &#8209; could cause the offsetTop to be off by 1 pixel, so we build in a threshold.
curLine = [];
lines.push(curLine);
lineOffsetY = offset;
}
if (absolute) { //record offset x and y, as well as width and height so that we can access them later for positioning. Grabbing them at once ensures we don't trigger a browser paint & we maximize performance.
node._x = node.offsetLeft;
node._y = offset;
node._w = node.offsetWidth;
node._h = node.offsetHeight;
}
if (lines) {
if ((node._isSplit && isChild) || (!chars && isChild) || (words && isChild) || (!words && node.parentNode.parentNode === element && !node.parentNode._isSplit)) {
curLine.push(node);
node._x -= paddingLeft;
if (_isBeforeWordDelimiter(node, element, wordDelimiter)) {
node._wordEnd = true;
}
}
if (node.nodeName === "BR" && ((node.nextSibling && node.nextSibling.nodeName === "BR") || i === 0)) { //two consecutive <br> tags signify a new [empty] line. Also, if the entire block of content STARTS with a <br>, add a line.
lines.push([]);
}
}
}
}
}
for (i = 0; i < l; i++) {
node = nodes[i];
isChild = (node.parentNode === element);
if (node.nodeName === "BR") {
if (lines || absolute) {
if (node.parentNode) {
node.parentNode.removeChild(node);
}
nodes.splice(i--, 1);
l--;
} else if (!words) {
element.appendChild(node);
}
continue;
}
if (absolute) {
style = node.style;
if (!words && !isChild) {
node._x += node.parentNode._x;
node._y += node.parentNode._y;
}
style.left = node._x + "px";
style.top = node._y + "px";
style.position = "absolute";
style.display = "block";
//if we don't set the width/height, things collapse in older versions of IE and the origin for transforms is thrown off in all browsers.
style.width = (node._w + 1) + "px"; //IE is 1px short sometimes. Avoid wrapping
style.height = node._h + "px";
}
if (!words && chars) {
//we always start out wrapping words in their own <div> so that line breaks happen correctly, but here we'll remove those <div> tags if necessary and renest the characters directly into the element rather than inside the word <div>
if (node._isSplit) {
node._next = node.nextSibling;
node.parentNode.appendChild(node); //put it at the end to keep the order correct.
} else if (node.parentNode._isSplit) {
node._parent = node.parentNode;
if (!node.previousSibling && node.firstChild) {
node.firstChild._isFirst = true;
}
if (node.nextSibling && node.nextSibling.textContent === " " && !node.nextSibling.nextSibling) { //if the last node inside a nested element is just a space (like T<span>nested </span>), remove it otherwise it'll get placed in the wrong order. Don't remove it right away, though, because we need to sense when words/characters are before a space like _isBeforeWordDelimiter(). Removing it now would make that a false negative.
spaceNodesToRemove.push(node.nextSibling);
}
node._next = (node.nextSibling && node.nextSibling._isFirst) ? null : node.nextSibling;
node.parentNode.removeChild(node);
nodes.splice(i--, 1);
l--;
} else if (!isChild) {
offset = (!node.nextSibling && _isBeforeWordDelimiter(node.parentNode, element, wordDelimiter)); //if this is the last letter in the word (and we're not breaking by lines and not positioning things absolutely), we need to add a space afterwards so that the characters don't just mash together
if (node.parentNode._parent) {
node.parentNode._parent.appendChild(node);
}
if (offset) {
node.parentNode.appendChild(_doc.createTextNode(" "));
}
if (tag === "span") {
node.style.display = "inline"; //so that word breaks are honored properly.
}
charArray.push(node);
}
} else if (node.parentNode._isSplit && !node._isSplit && node.innerHTML !== "") {
wordArray.push(node);
} else if (chars && !node._isSplit) {
if (tag === "span") {
node.style.display = "inline";
}
charArray.push(node);
}
}
i = spaceNodesToRemove.length;
while (--i > -1) {
spaceNodesToRemove[i].parentNode.removeChild(spaceNodesToRemove[i]);
}
if (lines) {
//the next 7 lines just give us the line width in the most reliable way and figure out the left offset (if position isn't relative or absolute). We must set the width along with text-align to ensure everything works properly for various alignments.
if (absolute) {
lineNode = _doc.createElement(tag);
element.appendChild(lineNode);
lineWidth = lineNode.offsetWidth + "px";
offset = (lineNode.offsetParent === element) ? 0 : element.offsetLeft;
element.removeChild(lineNode);
}
style = element.style.cssText;
element.style.cssText = "display:none;"; //to improve performance, set display:none on the element so that the browser doesn't have to worry about reflowing or rendering while we're renesting things. We'll revert the cssText later.
//we can't use element.innerHTML = "" because that causes IE to literally delete all the nodes and their content even though we've stored them in an array! So we must loop through the children and remove them.
while (element.firstChild) {
element.removeChild(element.firstChild);
}
addWordSpaces = (wordDelimiter === " " && (!absolute || (!words && !chars)));
for (i = 0; i < lines.length; i++) {
curLine = lines[i];
lineNode = _doc.createElement(tag);
lineNode.style.cssText = "display:block;text-align:" + textAlign + ";position:" + (absolute ? "absolute;" : "relative;");
if (linesClass) {
lineNode.className = linesClass + (iterateLine ? i+1 : "");
}
lineArray.push(lineNode);
l = curLine.length;
for (j = 0; j < l; j++) {
if (curLine[j].nodeName !== "BR") {
node = curLine[j];
lineNode.appendChild(node);
if (addWordSpaces && node._wordEnd) {
lineNode.appendChild(_doc.createTextNode(" "));
}
if (absolute) {
if (j === 0) {
lineNode.style.top = (node._y) + "px";
lineNode.style.left = (paddingLeft + offset) + "px";
}
node.style.top = "0px";
if (offset) {
node.style.left = (node._x - offset) + "px";
}
}
}
}
if (l === 0) { //if there are no nodes in the line (typically meaning there were two consecutive <br> tags, just add a non-breaking space so that things display properly.
lineNode.innerHTML = "&nbsp;";
} else if (!words && !chars) {
_deWordify(lineNode);
_swapText(lineNode, String.fromCharCode(160), " ");
}
if (absolute) {
lineNode.style.width = lineWidth;
lineNode.style.height = node._h + "px";
}
element.appendChild(lineNode);
}
element.style.cssText = style;
}
//if everything shifts to being position:absolute, the container can collapse in terms of height or width, so fix that here.
if (absolute) {
if (origHeight > element.clientHeight) {
element.style.height = (origHeight - padTopAndBottom) + "px";
if (element.clientHeight < origHeight) { //IE8 and earlier use a different box model - we must include padding and borders
element.style.height = (origHeight + borderTopAndBottom)+ "px";
}
}
if (origWidth > element.clientWidth) {
element.style.width = (origWidth - padLeftAndRight) + "px";
if (element.clientWidth < origWidth) { //IE8 and earlier use a different box model - we must include padding and borders
element.style.width = (origWidth + borderLeftAndRight)+ "px";
}
}
}
_pushReversed(allChars, charArray);
if (words) {
_pushReversed(allWords, wordArray);
}
_pushReversed(allLines, lineArray);
},
_splitRawText = function(element, vars, wordStart, charStart) {
var tag = vars.tag ? vars.tag : (vars.span ? "span" : "div"),
types = vars.type || vars.split || "chars,words,lines",
//words = (types.indexOf("words") !== -1),
chars = (types.indexOf("chars") !== -1),
absolute = (vars.position === "absolute" || vars.absolute === true),
wordDelimiter = vars.wordDelimiter || " ",
space = wordDelimiter !== " " ? "" : (absolute ? "&#173; " : " "),
wordEnd = "</" + tag + ">",
wordIsOpen = true,
specialChars = vars.specialChars ? (typeof(vars.specialChars) === "function" ? vars.specialChars : _findSpecialChars) : null, //specialChars can be an array or a function. For performance reasons, we always set this local "specialChars" to a function to which we pass the remaining text and whatever the original vars.specialChars was so that if it's an array, it works with the _findSpecialChars() function.
text, splitText, i, j, l, character, hasTagStart, emojiPair1, emojiPair2, testResult,
container = _doc.createElement("div"),
parent = element.parentNode;
parent.insertBefore(container, element);
container.textContent = element.nodeValue;
parent.removeChild(element);
element = container;
text = _getText(element);
hasTagStart = text.indexOf("<") !== -1;
if (vars.reduceWhiteSpace !== false) {
text = text.replace(_multipleSpacesExp, " ").replace(_stripExp, "");
}
if (hasTagStart) {
text = text.split("<").join("{{LT}}"); //we can't leave "<" in the string, or when we set the innerHTML, it can be interpreted as a node
}
l = text.length;
splitText = ((text.charAt(0) === " ") ? space : "") + wordStart();
for (i = 0; i < l; i++) {
character = text.charAt(i);
if (specialChars && (testResult = specialChars(text.substr(i), vars.specialChars))) { // look for any specialChars that were declared. Remember, they can be passed in like {specialChars:["मी", "पा", "है"]} or a function could be defined instead. Either way, the function should return the number of characters that should be grouped together for this "character".
character = text.substr(i, testResult || 1);
splitText += (chars && character !== " ") ? charStart() + character + "</" + tag + ">" : character;
i += testResult - 1;
} else if (character === wordDelimiter && text.charAt(i-1) !== wordDelimiter && i) {
splitText += wordIsOpen ? wordEnd : "";
wordIsOpen = false;
while (text.charAt(i + 1) === wordDelimiter) { //skip over empty spaces (to avoid making them words)
splitText += space;
i++;
}
if (i === l-1) {
splitText += space;
} else if (text.charAt(i + 1) !== ")") {
splitText += space + wordStart();
wordIsOpen = true;
}
} else if (character === "{" && text.substr(i, 6) === "{{LT}}") {
splitText += chars ? charStart() + "{{LT}}" + "</" + tag + ">" : "{{LT}}";
i += 5;
} else if ((character.charCodeAt(0) >= _emojiStart && character.charCodeAt(0) <= _emojiEnd) || (text.charCodeAt(i+1) >= 0xFE00 && text.charCodeAt(i+1) <= 0xFE0F)) { //special emoji characters use 2 or 4 unicode characters that we must keep together.
emojiPair1 = _emojiPairCode(text.substr(i, 2));
emojiPair2 = _emojiPairCode(text.substr(i + 2, 2));
j = ((emojiPair1 >= _emojiRegionStart && emojiPair1 <= _emojiRegionEnd && emojiPair2 >= _emojiRegionStart && emojiPair2 <= _emojiRegionEnd) || (emojiPair2 >= _emojiModStart && emojiPair2 <= _emojiModEnd)) ? 4 : 2;
splitText += (chars && character !== " ") ? charStart() + text.substr(i, j) + "</" + tag + ">" : text.substr(i, j);
i += j - 1;
} else {
splitText += (chars && character !== " ") ? charStart() + character + "</" + tag + ">" : character;
}
}
element.outerHTML = splitText + (wordIsOpen ? wordEnd : "");
if (hasTagStart) {
_swapText(parent, "{{LT}}", "<"); //note: don't perform this on "element" because that gets replaced with all new elements when we set element.outerHTML.
}
},
_split = function(element, vars, wordStart, charStart) {
var children = _slice(element.childNodes),
l = children.length,
absolute = (vars.position === "absolute" || vars.absolute === true),
i, child;
if (element.nodeType !== 3 || l > 1) {
vars.absolute = false;
for (i = 0; i < l; i++) {
child = children[i];
if (child.nodeType !== 3 || /\S+/.test(child.nodeValue)) {
if (absolute && child.nodeType !== 3 && _getStyle(child, "display", null, true) === "inline") { //if there's a child node that's display:inline, switch it to inline-block so that absolute positioning works properly (most browsers don't report offsetTop/offsetLeft properly inside a <span> for example)
child.style.display = "inline-block";
child.style.position = "relative";
}
child._isSplit = true;
_split(child, vars, wordStart, charStart); //don't split lines on child elements
}
}
vars.absolute = absolute;
element._isSplit = true;
return;
}
_splitRawText(element, vars, wordStart, charStart);
},
p = SplitText.prototype;
p.split = function(vars) {
if (this.isSplit) {
this.revert();
}
this.vars = vars = vars || this.vars;
this._originals.length = this.chars.length = this.words.length = this.lines.length = 0;
var i = this.elements.length,
tag = vars.tag ? vars.tag : (vars.span ? "span" : "div"),
wordStart = _cssClassFunc(vars.wordsClass, tag),
charStart = _cssClassFunc(vars.charsClass, tag),
origHeight, origWidth, e;
//we split in reversed order so that if/when we position:absolute elements, they don't affect the position of the ones after them in the document flow (shifting them up as they're taken out of the document flow).
while (--i > -1) {
e = this.elements[i];
this._originals[i] = e.innerHTML;
origHeight = e.clientHeight;
origWidth = e.clientWidth;
_split(e, vars, wordStart, charStart);
_setPositionsAfterSplit(e, vars, this.chars, this.words, this.lines, origWidth, origHeight);
}
this.chars.reverse();
this.words.reverse();
this.lines.reverse();
this.isSplit = true;
return this;
};
p.revert = function() {
if (!this._originals) {
throw("revert() call wasn't scoped properly.");
}
var i = this._originals.length;
while (--i > -1) {
this.elements[i].innerHTML = this._originals[i];
}
this.chars = [];
this.words = [];
this.lines = [];
this.isSplit = false;
return this;
};
SplitText.selector = window.$ || window.jQuery || function(e) {
var selector = window.$ || window.jQuery;
if (selector) {
SplitText.selector = selector;
return selector(e);
}
return (typeof(document) === "undefined") ? e : (document.querySelectorAll ? document.querySelectorAll(e) : document.getElementById((e.charAt(0) === "#") ? e.substr(1) : e));
};
SplitText.version = "0.7.0";
})(_gsScope);
//export to AMD/RequireJS and CommonJS/Node (precursor to full modular build system coming at a later date)
(function(name) {
"use strict";
var getGlobal = function() {
return (_gsScope.GreenSockGlobals || _gsScope)[name];
};
if (typeof(module) !== "undefined" && module.exports) { //node
module.exports = getGlobal();
} else if (typeof(define) === "function" && define.amd) { //AMD
define([], getGlobal);
}
}("SplitText"));

View File

@ -0,0 +1,740 @@
/*!
* VERSION: 0.11.2
* DATE: 2019-02-07
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* ThrowPropsPlugin is a Club GreenSock membership benefit; You must have a valid membership to use
* this code without violating the terms of use. Visit http://greensock.com/club/ to sign up or get more details.
* This work is subject to the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || window; //helps ensure compatibility with AMD/RequireJS and CommonJS/Node
(_gsScope._gsQueue || (_gsScope._gsQueue = [])).push( function() {
"use strict";
_gsScope._gsDefine("plugins.ThrowPropsPlugin", ["plugins.TweenPlugin", "TweenLite", "easing.Ease", "utils.VelocityTracker"], function(TweenPlugin, TweenLite, Ease, VelocityTracker) {
var ThrowPropsPlugin = function(props, priority) {
TweenPlugin.call(this, "throwProps");
this._overwriteProps.length = 0;
},
_max = 999999999999999,
_min = 0.0000000001,
_globals = _gsScope._gsDefine.globals,
_recordEndMode = false,//in a typical throwProps css tween that has an "end" defined as a function, it grabs that value initially when the tween is rendered, then again when we calculate the necessary duration, and then a 3rd time after we invalidate() the tween, so we toggle _recordEndMode to true when we're about to begin such a tween which tells the engine to grab the end value(s) once and record them as "max" and "min" on the throwProps object, thus we can skip those extra calls. Then we set it back to false when we're done with our fancy initialization routine.
_transforms = {x:1,y:1,z:2,scale:1,scaleX:1,scaleY:1,rotation:1,rotationZ:1,rotationX:2,rotationY:2,skewX:1,skewY:1,xPercent:1,yPercent:1},
_getClosest = function(n, values, max, min, radius) {
var i = values.length,
closest = 0,
absDif = _max,
val, dif, p, dist;
if (typeof(n) === "object") {
while (--i > -1) {
val = values[i];
dif = 0;
for (p in n) {
dist = val[p] - n[p];
dif += dist * dist;
}
if (dif < absDif) {
closest = i;
absDif = dif;
}
}
if ((radius || _max) < _max && radius < Math.sqrt(absDif)) {
return n;
}
} else {
while (--i > -1) {
val = values[i];
dif = val - n;
if (dif < 0) {
dif = -dif;
}
if (dif < absDif && val >= min && val <= max) {
closest = i;
absDif = dif;
}
}
}
return values[closest];
},
_parseEnd = function(curProp, end, max, min, name, radius) {
if (curProp.end === "auto") {
return curProp;
}
var endVar = curProp.end,
adjustedEnd, p;
max = isNaN(max) ? _max : max;
min = isNaN(min) ? -_max : min;
if (typeof(end) === "object") { //for objects, like {x, y} where they're linked and we must pass an object to the function or find the closest value in an array.
adjustedEnd = end.calculated ? end : ((typeof(endVar) === "function") ? endVar(end) : _getClosest(end, endVar, max, min, radius)) || end;
if (!end.calculated) {
for (p in adjustedEnd) {
end[p] = adjustedEnd[p];
}
end.calculated = true;
}
adjustedEnd = adjustedEnd[name];
} else {
adjustedEnd = (typeof(endVar) === "function") ? endVar(end) : (endVar instanceof Array) ? _getClosest(end, endVar, max, min, radius) : Number(endVar);
}
if (adjustedEnd > max) {
adjustedEnd = max;
} else if (adjustedEnd < min) {
adjustedEnd = min;
}
return {max:adjustedEnd, min:adjustedEnd, unitFactor:curProp.unitFactor};
},
_extend = function(decoratee, extras, exclude) {
for (var p in extras) {
if (decoratee[p] === undefined && p !== exclude) {
decoratee[p] = extras[p];
}
}
return decoratee;
},
_calculateChange = ThrowPropsPlugin.calculateChange = function(velocity, ease, duration, checkpoint) {
if (checkpoint == null) {
checkpoint = 0.05;
}
var e = (ease instanceof Ease) ? ease : (!ease) ? TweenLite.defaultEase : new Ease(ease);
return (duration * checkpoint * velocity) / e.getRatio(checkpoint);
},
_calculateDuration = ThrowPropsPlugin.calculateDuration = function(start, end, velocity, ease, checkpoint) {
checkpoint = checkpoint || 0.05;
var e = (ease instanceof Ease) ? ease : (!ease) ? TweenLite.defaultEase : new Ease(ease);
return Math.abs( (end - start) * e.getRatio(checkpoint) / velocity / checkpoint );
},
_calculateTweenDuration = ThrowPropsPlugin.calculateTweenDuration = function(target, vars, maxDuration, minDuration, overshootTolerance, recordEnd) {
if (typeof(target) === "string") {
target = TweenLite.selector(target);
}
if (!target) {
return 0;
}
if (maxDuration == null) {
maxDuration = 10;
}
if (minDuration == null) {
minDuration = 0.2;
}
if (overshootTolerance == null) {
overshootTolerance = 1;
}
if (target.length) {
target = target[0] || target;
}
var duration = 0,
clippedDuration = 9999999999,
throwPropsVars = vars.throwProps || vars,
ease = (vars.ease instanceof Ease) ? vars.ease : (!vars.ease) ? TweenLite.defaultEase : new Ease(vars.ease),
checkpoint = isNaN(throwPropsVars.checkpoint) ? 0.05 : Number(throwPropsVars.checkpoint),
resistance = isNaN(throwPropsVars.resistance) ? ThrowPropsPlugin.defaultResistance : Number(throwPropsVars.resistance),
p, curProp, curDuration, curVelocity, curResistance, curVal, end, curClippedDuration, tracker, unitFactor,
linkedProps, linkedPropNames, i;
if (throwPropsVars.linkedProps) { //when there are linkedProps (typically "x,y" where snapping has to factor in multiple properties, we must first populate an object with all of those end values, then feed it to the function that make any necessary alterations. So the point of this first loop is to simply build an object (like {x:100, y:204.5}) for feeding into that function which we'll do later in the "real" loop.
linkedPropNames = throwPropsVars.linkedProps.split(",");
linkedProps = {};
for (i = 0; i < linkedPropNames.length; i++) {
p = linkedPropNames[i];
curProp = throwPropsVars[p];
if (curProp) {
if (curProp.velocity !== undefined && typeof(curProp.velocity) === "number") {
curVelocity = Number(curProp.velocity) || 0;
} else {
tracker = tracker || VelocityTracker.getByTarget(target);
curVelocity = (tracker && tracker.isTrackingProp(p)) ? tracker.getVelocity(p) : 0;
}
curResistance = isNaN(curProp.resistance) ? resistance : Number(curProp.resistance);
curDuration = (curVelocity * curResistance > 0) ? curVelocity / curResistance : curVelocity / -curResistance;
curVal = (typeof(target[p]) === "function") ? target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]() : target[p] || 0;
linkedProps[p] = curVal + _calculateChange(curVelocity, ease, curDuration, checkpoint);
}
}
}
for (p in throwPropsVars) {
if (p !== "resistance" && p !== "checkpoint" && p !== "preventOvershoot" && p !== "linkedProps" && p !== "radius") {
curProp = throwPropsVars[p];
if (typeof(curProp) !== "object") {
tracker = tracker || VelocityTracker.getByTarget(target);
if (tracker && tracker.isTrackingProp(p)) {
curProp = (typeof(curProp) === "number") ? {velocity:curProp} : {velocity:tracker.getVelocity(p)}; //if we're tracking this property, we should use the tracking velocity and then use the numeric value that was passed in as the min and max so that it tweens exactly there.
} else {
curVelocity = Number(curProp) || 0;
curDuration = (curVelocity * resistance > 0) ? curVelocity / resistance : curVelocity / -resistance;
}
}
if (typeof(curProp) === "object") {
if (curProp.velocity !== undefined && typeof(curProp.velocity) === "number") {
curVelocity = Number(curProp.velocity) || 0;
} else {
tracker = tracker || VelocityTracker.getByTarget(target);
curVelocity = (tracker && tracker.isTrackingProp(p)) ? tracker.getVelocity(p) : 0;
}
curResistance = isNaN(curProp.resistance) ? resistance : Number(curProp.resistance);
curDuration = (curVelocity * curResistance > 0) ? curVelocity / curResistance : curVelocity / -curResistance;
curVal = (typeof(target[p]) === "function") ? target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]() : target[p] || 0;
end = curVal + _calculateChange(curVelocity, ease, curDuration, checkpoint);
if (curProp.end !== undefined) {
curProp = _parseEnd(curProp, (linkedProps && p in linkedProps) ? linkedProps : end, curProp.max, curProp.min, p, throwPropsVars.radius);
if (recordEnd || _recordEndMode) {
throwPropsVars[p] = _extend(curProp, throwPropsVars[p], "end");
}
}
if (curProp.max !== undefined && end > Number(curProp.max) + _min) {
unitFactor = curProp.unitFactor || ThrowPropsPlugin.defaultUnitFactors[p] || 1; //some values are measured in special units like radians in which case our thresholds need to be adjusted accordingly.
//if the value is already exceeding the max or the velocity is too low, the duration can end up being uncomfortably long but in most situations, users want the snapping to occur relatively quickly (0.75 seconds), so we implement a cap here to make things more intuitive. If the max and min match, it means we're animating to a particular value and we don't want to shorten the time unless the velocity is really slow. Example: a rotation where the start and natural end value are less than the snapping spot, but the natural end is pretty close to the snap.
curClippedDuration = ((curVal > curProp.max && curProp.min !== curProp.max) || (curVelocity * unitFactor > -15 && curVelocity * unitFactor < 45)) ? (minDuration + (maxDuration - minDuration) * 0.1) : _calculateDuration(curVal, curProp.max, curVelocity, ease, checkpoint);
if (curClippedDuration + overshootTolerance < clippedDuration) {
clippedDuration = curClippedDuration + overshootTolerance;
}
} else if (curProp.min !== undefined && end < Number(curProp.min) - _min) {
unitFactor = curProp.unitFactor || ThrowPropsPlugin.defaultUnitFactors[p] || 1; //some values are measured in special units like radians in which case our thresholds need to be adjusted accordingly.
//if the value is already exceeding the min or if the velocity is too low, the duration can end up being uncomfortably long but in most situations, users want the snapping to occur relatively quickly (0.75 seconds), so we implement a cap here to make things more intuitive.
curClippedDuration = ((curVal < curProp.min && curProp.min !== curProp.max) || (curVelocity * unitFactor > -45 && curVelocity * unitFactor < 15)) ? (minDuration + (maxDuration - minDuration) * 0.1) : _calculateDuration(curVal, curProp.min, curVelocity, ease, checkpoint);
if (curClippedDuration + overshootTolerance < clippedDuration) {
clippedDuration = curClippedDuration + overshootTolerance;
}
}
if (curClippedDuration > duration) {
duration = curClippedDuration;
}
}
if (curDuration > duration) {
duration = curDuration;
}
}
}
if (duration > clippedDuration) {
duration = clippedDuration;
}
if (duration > maxDuration) {
return maxDuration;
} else if (duration < minDuration) {
return minDuration;
}
return duration;
},
p = ThrowPropsPlugin.prototype = new TweenPlugin("throwProps"),
_cssProxy, _cssVars, _last, _lastValue; //these serve as a cache of sorts, recording the last css-related proxy and the throwProps vars that get calculated in the _cssRegister() method. This allows us to grab them in the ThrowPropsPlugin.to() function and calculate the duration. Of course we could have structured things in a more "clean" fashion, but performance is of paramount importance.
p.constructor = ThrowPropsPlugin;
ThrowPropsPlugin.version = "0.11.2";
ThrowPropsPlugin.API = 2;
ThrowPropsPlugin._autoCSS = true; //indicates that this plugin can be inserted into the "css" object using the autoCSS feature of TweenLite
ThrowPropsPlugin.defaultResistance = 100;
ThrowPropsPlugin.defaultUnitFactors = {time:1000, totalTime:1000}; //setting the unitFactor to a higher value (default is 1) reduces the chance of the auto-accelerating behavior kicking in when determining durations when the initial velocity is adequately low - imagine dragging something past a boundary and then letting go - snapping back relatively quickly should be prioritized over matching the initial velocity (at least that's the behavior most people consider intuitive). But in some situations when the units are very low (like "time" of a timeline or rotation when using radians), it can kick in too frequently so this allows tweaking.
ThrowPropsPlugin.track = function(target, props, types) {
return VelocityTracker.track(target, props, types);
};
ThrowPropsPlugin.untrack = function(target, props) {
VelocityTracker.untrack(target, props);
};
ThrowPropsPlugin.isTracking = function(target, prop) {
return VelocityTracker.isTracking(target, prop);
};
ThrowPropsPlugin.getVelocity = function(target, prop) {
var vt = VelocityTracker.getByTarget(target);
return vt ? vt.getVelocity(prop) : NaN;
};
ThrowPropsPlugin._cssRegister = function() {
var CSSPlugin = _globals.com.greensock.plugins.CSSPlugin;
if (!CSSPlugin) {
return;
}
var _internals = CSSPlugin._internals,
_parseToProxy = _internals._parseToProxy,
_setPluginRatio = _internals._setPluginRatio,
CSSPropTween = _internals.CSSPropTween;
_internals._registerComplexSpecialProp("throwProps", {parser:function(t, e, prop, cssp, pt, plugin) {
plugin = new ThrowPropsPlugin();
var velocities = {},
min = {},
max = {},
end = {},
res = {},
preventOvershoot = {},
hasResistance, val, p, data, tracker;
_cssVars = {};
for (p in e) {
if (p !== "resistance" && p !== "preventOvershoot" && p !== "linkedProps" && p !== "radius") {
val = e[p];
if (typeof(val) === "object") {
if (val.velocity !== undefined && typeof(val.velocity) === "number") {
velocities[p] = Number(val.velocity) || 0;
} else {
tracker = tracker || VelocityTracker.getByTarget(t);
velocities[p] = (tracker && tracker.isTrackingProp(p)) ? tracker.getVelocity(p) : 0; //rotational values are actually converted to radians in CSSPlugin, but our tracking velocity is in radians already, so make it into degrees to avoid a funky conversion
}
if (val.end !== undefined) {
end[p] = val.end;
}
if (val.min !== undefined) {
min[p] = val.min;
}
if (val.max !== undefined) {
max[p] = val.max;
}
if (val.preventOvershoot) {
preventOvershoot[p] = true;
}
if (val.resistance !== undefined) {
hasResistance = true;
res[p] = val.resistance;
}
} else if (typeof(val) === "number") {
velocities[p] = val;
} else {
tracker = tracker || VelocityTracker.getByTarget(t);
if (tracker && tracker.isTrackingProp(p)) {
velocities[p] = tracker.getVelocity(p);
} else {
velocities[p] = val || 0;
}
}
if (_transforms[p]) {
cssp._enableTransforms((_transforms[p] === 2));
}
}
}
data = _parseToProxy(t, velocities, cssp, pt, plugin);
_cssProxy = data.proxy;
velocities = data.end;
for (p in _cssProxy) {
_cssVars[p] = {velocity:velocities[p], min:min[p], max:max[p], end:end[p], resistance:res[p], preventOvershoot:preventOvershoot[p]};
}
if (e.resistance != null) {
_cssVars.resistance = e.resistance;
}
if (e.linkedProps != null) {
_cssVars.linkedProps = e.linkedProps;
}
if (e.radius != null) {
_cssVars.radius = e.radius;
}
if (e.preventOvershoot) {
_cssVars.preventOvershoot = true;
}
pt = new CSSPropTween(t, "throwProps", 0, 0, data.pt, 2);
cssp._overwriteProps.pop(); //don't overwrite all other throwProps tweens. In the CSSPropTween constructor, we add the property to the _overwriteProps, so remove it here.
pt.plugin = plugin;
pt.setRatio = _setPluginRatio;
pt.data = data;
plugin._onInitTween(_cssProxy, _cssVars, cssp._tween);
return pt;
}});
};
ThrowPropsPlugin.to = function(target, vars, maxDuration, minDuration, overshootTolerance) {
if (!vars.throwProps) {
vars = {throwProps:vars};
}
if (overshootTolerance === 0) {
vars.throwProps.preventOvershoot = true;
}
_recordEndMode = true; //if we encounter a function-based "end" value, ThrowPropsPlugin will record it as "max" and "min" properties, replacing "end" (this is an optimization so that the function only gets called once)
var tween = new TweenLite(target, minDuration || 1, vars);
tween.render(0, true, true); //we force a render so that the CSSPlugin instantiates and populates the _cssProxy and _cssVars which we need in order to calculate the tween duration. Remember, we can't use the regular target for calculating the duration because the current values wouldn't be able to be grabbed like target["propertyName"], as css properties can be complex like boxShadow:"10px 10px 20px 30px red" or backgroundPosition:"25px 50px". The proxy is the result of breaking all that complex data down and finding just the numeric values and assigning them to a generic proxy object with unique names. THAT is what the _calculateTweenDuration() can look at. We also needed to do the same break down of any min or max or velocity data
if (tween.vars.css) {
tween.duration(_calculateTweenDuration(_cssProxy, {throwProps:_cssVars, ease:vars.ease}, maxDuration, minDuration, overshootTolerance));
if (tween._delay && !tween.vars.immediateRender) {
tween.invalidate(); //if there's a delay, the starting values could be off, so invalidate() to force reinstantiation when the tween actually starts.
} else {
_last._onInitTween(_cssProxy, _lastValue, tween);
}
_recordEndMode = false;
return tween;
} else {
tween.kill();
tween = new TweenLite(target, _calculateTweenDuration(target, vars, maxDuration, minDuration, overshootTolerance), vars);
_recordEndMode = false;
return tween;
}
};
p._onInitTween = function(target, value, tween, index) {
this.target = target;
this._props = [];
_last = this;
_lastValue = value;
var ease = tween._ease,
checkpoint = isNaN(value.checkpoint) ? 0.05 : Number(value.checkpoint),
duration = tween._duration,
preventOvershoot = value.preventOvershoot,
cnt = 0,
p, curProp, curVal, isFunc, velocity, change1, end, change2, tracker,
linkedProps, linkedPropNames, i;
if (value.linkedProps) { //when there are linkedProps (typically "x,y" where snapping has to factor in multiple properties, we must first populate an object with all of those end values, then feed it to the function that make any necessary alterations. So the point of this first loop is to simply build an object (like {x:100, y:204.5}) for feeding into that function which we'll do later in the "real" loop.
linkedPropNames = value.linkedProps.split(",");
linkedProps = {};
for (i = 0; i < linkedPropNames.length; i++) {
p = linkedPropNames[i];
curProp = value[p];
if (curProp) {
if (curProp.velocity !== undefined && typeof(curProp.velocity) === "number") {
velocity = Number(curProp.velocity) || 0;
} else {
tracker = tracker || VelocityTracker.getByTarget(target);
velocity = (tracker && tracker.isTrackingProp(p)) ? tracker.getVelocity(p) : 0;
}
curVal = (typeof(target[p]) === "function") ? target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]() : target[p] || 0;
linkedProps[p] = curVal + _calculateChange(velocity, ease, duration, checkpoint);
}
}
}
for (p in value) {
if (p !== "resistance" && p !== "checkpoint" && p !== "preventOvershoot" && p !== "linkedProps" && p !== "radius") {
curProp = value[p];
if (typeof(curProp) === "function") {
curProp = curProp(index, target);
}
if (typeof(curProp) === "number") {
velocity = Number(curProp) || 0;
} else if (typeof(curProp) === "object" && !isNaN(curProp.velocity)) {
velocity = Number(curProp.velocity);
} else {
tracker = tracker || VelocityTracker.getByTarget(target);
if (tracker && tracker.isTrackingProp(p)) {
velocity = tracker.getVelocity(p);
} else {
throw("ERROR: No velocity was defined in the throwProps tween of " + target + " property: " + p);
}
}
change1 = _calculateChange(velocity, ease, duration, checkpoint);
change2 = 0;
isFunc = (typeof(target[p]) === "function");
curVal = (isFunc) ? target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]() : target[p];
if (typeof(curProp) === "object") {
end = curVal + change1;
if (curProp.end !== undefined) {
curProp = _parseEnd(curProp, (linkedProps && p in linkedProps) ? linkedProps : end, curProp.max, curProp.min, p, value.radius);
if (_recordEndMode) {
value[p] = _extend(curProp, value[p], "end");
}
}
if (curProp.max !== undefined && Number(curProp.max) < end) {
if (preventOvershoot || curProp.preventOvershoot) {
change1 = curProp.max - curVal;
} else {
change2 = (curProp.max - curVal) - change1;
}
} else if (curProp.min !== undefined && Number(curProp.min) > end) {
if (preventOvershoot || curProp.preventOvershoot) {
change1 = curProp.min - curVal;
} else {
change2 = (curProp.min - curVal) - change1;
}
}
}
this._overwriteProps[cnt] = p;
this._props[cnt++] = {p:p, s:curVal, c1:change1, c2:change2, f:isFunc, r:false};
}
}
return true;
};
p._kill = function(lookup) {
var i = this._props.length;
while (--i > -1) {
if (lookup[this._props[i].p] != null) {
this._props.splice(i, 1);
}
}
return TweenPlugin.prototype._kill.call(this, lookup);
};
p._mod = function(lookup) {
var p = this._props,
i = p.length,
val;
while (--i > -1) {
val = lookup[p[i].p] || lookup.throwProps;
if (typeof(val) === "function") {
p[i].m = val;
}
}
};
p.setRatio = function(v) {
var i = this._props.length,
cp, val;
while (--i > -1) {
cp = this._props[i];
val = cp.s + cp.c1 * v + cp.c2 * v * v;
if (cp.m) {
val = cp.m(val, this.target);
} else if (v === 1) {
val = ((val * 10000 + (val < 0 ? -0.5 : 0.5)) | 0) / 10000; //if we don't round things at the very end, binary math issues can creep in and cause snapping not to be exact (like landing on 20.000000000001 instead of 20).
}
if (cp.f) {
this.target[cp.p](val);
} else {
this.target[cp.p] = val;
}
}
};
TweenPlugin.activate([ThrowPropsPlugin]);
return ThrowPropsPlugin;
}, true);
/*
* ----------------------------------------------------------------
* VelocityTracker
* ----------------------------------------------------------------
*/
_gsScope._gsDefine("utils.VelocityTracker", ["TweenLite"], function(TweenLite) {
var _first, _initted, _time1, _time2,
_capsExp = /([A-Z])/g,
_empty = {},
_doc = _gsScope.document,
_transforms = {x:1,y:1,z:2,scale:1,scaleX:1,scaleY:1,rotation:1,rotationZ:1,rotationX:2,rotationY:2,skewX:1,skewY:1,xPercent:1,yPercent:1},
_computedStyleScope = (typeof(window) !== "undefined" ? window : _doc.defaultView || {getComputedStyle:function() {}}),
_getComputedStyle = function(e) {
return _computedStyleScope.getComputedStyle(e); //to avoid errors in Microsoft Edge, we need to call getComputedStyle() from a specific scope, typically window.
},
_getStyle = function(t, p, cs) {
var rv = (t._gsTransform || _empty)[p];
if (rv || rv === 0) {
return rv;
} else if (t.style[p]) {
rv = t.style[p];
} else if ((cs = cs || _getComputedStyle(t, null))) {
rv = cs[p] || cs.getPropertyValue(p) || cs.getPropertyValue(p.replace(_capsExp, "-$1").toLowerCase());
} else if (t.currentStyle) {
rv = t.currentStyle[p];
}
return parseFloat(rv) || 0;
},
_ticker = TweenLite.ticker,
VelocityProp = function(p, isFunc, next) {
this.p = p;
this.f = isFunc;
this.v1 = this.v2 = 0;
this.t1 = this.t2 = _ticker.time;
this.css = false;
this.type = "";
this._prev = null;
if (next) {
this._next = next;
next._prev = this;
}
},
_update = function() {
var vt = _first,
t = _ticker.time,
val, vp;
//if the frame rate is too high, we won't be able to track the velocity as well, so only update the values about 33 times per second
if (t - _time1 >= 0.03) {
_time2 = _time1;
_time1 = t;
while (vt) {
vp = vt._firstVP;
while (vp) {
val = vp.css ? _getStyle(vt.target, vp.p) : vp.f ? vt.target[vp.p]() : vt.target[vp.p];
if (val !== vp.v1 || t - vp.t1 > 0.15) { //use a threshold of 0.15 seconds for zeroing-out velocity. If we only use 0.03 and things update slightly slower, like some Android devices dispatch "touchmove" events sluggishly so 2 or 3 ticks of the TweenLite.ticker may elapse inbetween, thus it may appear like the object is not moving but it actually is but it's not updating as frequently. A threshold of 0.15 seconds seems to be a good balance. We want to update things frequently (0.03 seconds) when they're moving so that we can respond to fast motions accurately, but we want to be more resistant to go back to a zero velocity.
vp.v2 = vp.v1;
vp.v1 = val;
vp.t2 = vp.t1;
vp.t1 = t;
}
vp = vp._next;
}
vt = vt._next;
}
}
},
VelocityTracker = function(target) {
this._lookup = {};
this.target = target;
this.elem = (target.style && target.nodeType) ? true : false;
if (!_initted) {
_ticker.addEventListener("tick", _update, null, false, -100);
_time1 = _time2 = _ticker.time;
_initted = true;
}
if (_first) {
this._next = _first;
_first._prev = this;
}
_first = this;
},
getByTarget = VelocityTracker.getByTarget = function(target) {
var vt = _first;
while (vt) {
if (vt.target === target) {
return vt;
}
vt = vt._next;
}
},
p = VelocityTracker.prototype;
p.addProp = function(prop, type) {
if (!this._lookup[prop]) {
var t = this.target,
isFunc = (typeof(t[prop]) === "function"),
alt = isFunc ? this._altProp(prop) : prop,
vp = this._firstVP;
this._firstVP = this._lookup[prop] = this._lookup[alt] = vp = new VelocityProp((alt !== prop && prop.indexOf("set") === 0) ? alt : prop, isFunc, vp);
vp.css = (this.elem && (this.target.style[vp.p] !== undefined || _transforms[vp.p]));
if (vp.css && _transforms[vp.p] && !t._gsTransform) {
TweenLite.set(t, {x:"+=0", overwrite:false}); //just forces CSSPlugin to create a _gsTransform for the element if it doesn't exist
}
vp.type = type || (vp.css && prop.indexOf("rotation") === 0) ? "deg" : "";
vp.v1 = vp.v2 = vp.css ? _getStyle(t, vp.p) : isFunc ? t[vp.p]() : t[vp.p];
}
};
p.removeProp = function(prop) {
var vp = this._lookup[prop];
if (vp) {
if (vp._prev) {
vp._prev._next = vp._next;
} else if (vp === this._firstVP) {
this._firstVP = vp._next;
}
if (vp._next) {
vp._next._prev = vp._prev;
}
this._lookup[prop] = 0;
if (vp.f) {
this._lookup[this._altProp(prop)] = 0; //if it's a getter/setter, we should remove the matching counterpart (if one exists)
}
}
};
p.isTrackingProp = function(prop) {
return (this._lookup[prop] instanceof VelocityProp);
};
p.getVelocity = function(prop) {
var vp = this._lookup[prop],
target = this.target,
val, dif, rotationCap;
if (!vp) {
throw "The velocity of " + prop + " is not being tracked.";
}
val = vp.css ? _getStyle(target, vp.p) : vp.f ? target[vp.p]() : target[vp.p];
dif = (val - vp.v2);
if (vp.type === "rad" || vp.type === "deg") { //rotational values need special interpretation so that if, for example, they go from 179 to -178 degrees it is interpreted as a change of 3 instead of -357.
rotationCap = (vp.type === "rad") ? Math.PI * 2 : 360;
dif = dif % rotationCap;
if (dif !== dif % (rotationCap / 2)) {
dif = (dif < 0) ? dif + rotationCap : dif - rotationCap;
}
}
return dif / (_ticker.time - vp.t2);
};
p._altProp = function(p) { //for getters/setters like getCustomProp() and setCustomProp() - we should accommodate both
var pre = p.substr(0, 3),
alt = ((pre === "get") ? "set" : (pre === "set") ? "get" : pre) + p.substr(3);
return (typeof(this.target[alt]) === "function") ? alt : p;
};
VelocityTracker.getByTarget = function(target) {
var vt = _first;
if (typeof(target) === "string") {
target = TweenLite.selector(target);
}
if (target.length && target !== window && target[0] && target[0].style && !target.nodeType) {
target = target[0];
}
while (vt) {
if (vt.target === target) {
return vt;
}
vt = vt._next;
}
};
VelocityTracker.track = function(target, props, types) {
var vt = getByTarget(target),
a = props.split(","),
i = a.length;
types = (types || "").split(",");
if (!vt) {
vt = new VelocityTracker(target);
}
while (--i > -1) {
vt.addProp(a[i], types[i] || types[0]);
}
return vt;
};
VelocityTracker.untrack = function(target, props) {
var vt = getByTarget(target),
a = (props || "").split(","),
i = a.length;
if (!vt) {
return;
}
while (--i > -1) {
vt.removeProp(a[i]);
}
if (!vt._firstVP || !props) {
if (vt._prev) {
vt._prev._next = vt._next;
} else if (vt === _first) {
_first = vt._next;
}
if (vt._next) {
vt._next._prev = vt._prev;
}
}
};
VelocityTracker.isTracking = function(target, prop) {
var vt = getByTarget(target);
return (!vt) ? false : (!prop && vt._firstVP) ? true : vt.isTrackingProp(prop);
};
return VelocityTracker;
}, true);
}); if (_gsScope._gsDefine) { _gsScope._gsQueue.pop()(); }
//export to AMD/RequireJS and CommonJS/Node (precursor to full modular build system coming at a later date)
(function(name) {
"use strict";
var getGlobal = function() {
return (_gsScope.GreenSockGlobals || _gsScope)[name];
};
if (typeof(module) !== "undefined" && module.exports) { //node
require("gsap/umd/TweenLite");
module.exports = getGlobal();
} else if (typeof(define) === "function" && define.amd) { //AMD
define(["gsap/umd/TweenLite"], getGlobal);
}
}("ThrowPropsPlugin"));

43
lib/3rdparty/gsap/src/esm/AttrPlugin.js vendored Normal file
View File

@ -0,0 +1,43 @@
/*!
* VERSION: 0.6.1
* DATE: 2018-08-27
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
import { _gsScope } from "./TweenLite.js";
export var AttrPlugin = _gsScope._gsDefine.plugin({
propName: "attr",
API: 2,
version: "0.6.1",
//called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
init: function(target, value, tween, index) {
var p, end;
if (typeof(target.setAttribute) !== "function") {
return false;
}
for (p in value) {
end = value[p];
if (typeof(end) === "function") {
end = end(index, target);
}
this._addTween(target, "setAttribute", target.getAttribute(p) + "", end + "", p, false, p);
this._overwriteProps.push(p);
}
return true;
}
});
export { AttrPlugin as default };

View File

@ -0,0 +1,604 @@
/*!
* VERSION: 1.3.8
* DATE: 2018-05-30
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
/* eslint-disable */
import { _gsScope } from "./TweenLite.js";
var _RAD2DEG = 180 / Math.PI,
_r1 = [],
_r2 = [],
_r3 = [],
_corProps = {},
_globals = _gsScope._gsDefine.globals,
Segment = function(a, b, c, d) {
if (c === d) { //if c and d match, the final autoRotate value could lock at -90 degrees, so differentiate them slightly.
c = d - (d - b) / 1000000;
}
if (a === b) { //if a and b match, the starting autoRotate value could lock at -90 degrees, so differentiate them slightly.
b = a + (c - a) / 1000000;
}
this.a = a;
this.b = b;
this.c = c;
this.d = d;
this.da = d - a;
this.ca = c - a;
this.ba = b - a;
},
_correlate = ",x,y,z,left,top,right,bottom,marginTop,marginLeft,marginRight,marginBottom,paddingLeft,paddingTop,paddingRight,paddingBottom,backgroundPosition,backgroundPosition_y,",
cubicToQuadratic = function(a, b, c, d) {
var q1 = {a:a},
q2 = {},
q3 = {},
q4 = {c:d},
mab = (a + b) / 2,
mbc = (b + c) / 2,
mcd = (c + d) / 2,
mabc = (mab + mbc) / 2,
mbcd = (mbc + mcd) / 2,
m8 = (mbcd - mabc) / 8;
q1.b = mab + (a - mab) / 4;
q2.b = mabc + m8;
q1.c = q2.a = (q1.b + q2.b) / 2;
q2.c = q3.a = (mabc + mbcd) / 2;
q3.b = mbcd - m8;
q4.b = mcd + (d - mcd) / 4;
q3.c = q4.a = (q3.b + q4.b) / 2;
return [q1, q2, q3, q4];
},
_calculateControlPoints = function(a, curviness, quad, basic, correlate) {
var l = a.length - 1,
ii = 0,
cp1 = a[0].a,
i, p1, p2, p3, seg, m1, m2, mm, cp2, qb, r1, r2, tl;
for (i = 0; i < l; i++) {
seg = a[ii];
p1 = seg.a;
p2 = seg.d;
p3 = a[ii+1].d;
if (correlate) {
r1 = _r1[i];
r2 = _r2[i];
tl = ((r2 + r1) * curviness * 0.25) / (basic ? 0.5 : _r3[i] || 0.5);
m1 = p2 - (p2 - p1) * (basic ? curviness * 0.5 : (r1 !== 0 ? tl / r1 : 0));
m2 = p2 + (p3 - p2) * (basic ? curviness * 0.5 : (r2 !== 0 ? tl / r2 : 0));
mm = p2 - (m1 + (((m2 - m1) * ((r1 * 3 / (r1 + r2)) + 0.5) / 4) || 0));
} else {
m1 = p2 - (p2 - p1) * curviness * 0.5;
m2 = p2 + (p3 - p2) * curviness * 0.5;
mm = p2 - (m1 + m2) / 2;
}
m1 += mm;
m2 += mm;
seg.c = cp2 = m1;
if (i !== 0) {
seg.b = cp1;
} else {
seg.b = cp1 = seg.a + (seg.c - seg.a) * 0.6; //instead of placing b on a exactly, we move it inline with c so that if the user specifies an ease like Back.easeIn or Elastic.easeIn which goes BEYOND the beginning, it will do so smoothly.
}
seg.da = p2 - p1;
seg.ca = cp2 - p1;
seg.ba = cp1 - p1;
if (quad) {
qb = cubicToQuadratic(p1, cp1, cp2, p2);
a.splice(ii, 1, qb[0], qb[1], qb[2], qb[3]);
ii += 4;
} else {
ii++;
}
cp1 = m2;
}
seg = a[ii];
seg.b = cp1;
seg.c = cp1 + (seg.d - cp1) * 0.4; //instead of placing c on d exactly, we move it inline with b so that if the user specifies an ease like Back.easeOut or Elastic.easeOut which goes BEYOND the end, it will do so smoothly.
seg.da = seg.d - seg.a;
seg.ca = seg.c - seg.a;
seg.ba = cp1 - seg.a;
if (quad) {
qb = cubicToQuadratic(seg.a, cp1, seg.c, seg.d);
a.splice(ii, 1, qb[0], qb[1], qb[2], qb[3]);
}
},
_parseAnchors = function(values, p, correlate, prepend) {
var a = [],
l, i, p1, p2, p3, tmp;
if (prepend) {
values = [prepend].concat(values);
i = values.length;
while (--i > -1) {
if (typeof( (tmp = values[i][p]) ) === "string") if (tmp.charAt(1) === "=") {
values[i][p] = prepend[p] + Number(tmp.charAt(0) + tmp.substr(2)); //accommodate relative values. Do it inline instead of breaking it out into a function for speed reasons
}
}
}
l = values.length - 2;
if (l < 0) {
a[0] = new Segment(values[0][p], 0, 0, values[0][p]);
return a;
}
for (i = 0; i < l; i++) {
p1 = values[i][p];
p2 = values[i+1][p];
a[i] = new Segment(p1, 0, 0, p2);
if (correlate) {
p3 = values[i+2][p];
_r1[i] = (_r1[i] || 0) + (p2 - p1) * (p2 - p1);
_r2[i] = (_r2[i] || 0) + (p3 - p2) * (p3 - p2);
}
}
a[i] = new Segment(values[i][p], 0, 0, values[i+1][p]);
return a;
},
bezierThrough = function(values, curviness, quadratic, basic, correlate, prepend) {
var obj = {},
props = [],
first = prepend || values[0],
i, p, a, j, r, l, seamless, last;
correlate = (typeof(correlate) === "string") ? ","+correlate+"," : _correlate;
if (curviness == null) {
curviness = 1;
}
for (p in values[0]) {
props.push(p);
}
//check to see if the last and first values are identical (well, within 0.05). If so, make seamless by appending the second element to the very end of the values array and the 2nd-to-last element to the very beginning (we'll remove those segments later)
if (values.length > 1) {
last = values[values.length - 1];
seamless = true;
i = props.length;
while (--i > -1) {
p = props[i];
if (Math.abs(first[p] - last[p]) > 0.05) { //build in a tolerance of +/-0.05 to accommodate rounding errors.
seamless = false;
break;
}
}
if (seamless) {
values = values.concat(); //duplicate the array to avoid contaminating the original which the user may be reusing for other tweens
if (prepend) {
values.unshift(prepend);
}
values.push(values[1]);
prepend = values[values.length - 3];
}
}
_r1.length = _r2.length = _r3.length = 0;
i = props.length;
while (--i > -1) {
p = props[i];
_corProps[p] = (correlate.indexOf(","+p+",") !== -1);
obj[p] = _parseAnchors(values, p, _corProps[p], prepend);
}
i = _r1.length;
while (--i > -1) {
_r1[i] = Math.sqrt(_r1[i]);
_r2[i] = Math.sqrt(_r2[i]);
}
if (!basic) {
i = props.length;
while (--i > -1) {
if (_corProps[p]) {
a = obj[props[i]];
l = a.length - 1;
for (j = 0; j < l; j++) {
r = (a[j+1].da / _r2[j] + a[j].da / _r1[j]) || 0;
_r3[j] = (_r3[j] || 0) + r * r;
}
}
}
i = _r3.length;
while (--i > -1) {
_r3[i] = Math.sqrt(_r3[i]);
}
}
i = props.length;
j = quadratic ? 4 : 1;
while (--i > -1) {
p = props[i];
a = obj[p];
_calculateControlPoints(a, curviness, quadratic, basic, _corProps[p]); //this method requires that _parseAnchors() and _setSegmentRatios() ran first so that _r1, _r2, and _r3 values are populated for all properties
if (seamless) {
a.splice(0, j);
a.splice(a.length - j, j);
}
}
return obj;
},
_parseBezierData = function(values, type, prepend) {
type = type || "soft";
var obj = {},
inc = (type === "cubic") ? 3 : 2,
soft = (type === "soft"),
props = [],
a, b, c, d, cur, i, j, l, p, cnt, tmp;
if (soft && prepend) {
values = [prepend].concat(values);
}
if (values == null || values.length < inc + 1) { throw "invalid Bezier data"; }
for (p in values[0]) {
props.push(p);
}
i = props.length;
while (--i > -1) {
p = props[i];
obj[p] = cur = [];
cnt = 0;
l = values.length;
for (j = 0; j < l; j++) {
a = (prepend == null) ? values[j][p] : (typeof( (tmp = values[j][p]) ) === "string" && tmp.charAt(1) === "=") ? prepend[p] + Number(tmp.charAt(0) + tmp.substr(2)) : Number(tmp);
if (soft) if (j > 1) if (j < l - 1) {
cur[cnt++] = (a + cur[cnt-2]) / 2;
}
cur[cnt++] = a;
}
l = cnt - inc + 1;
cnt = 0;
for (j = 0; j < l; j += inc) {
a = cur[j];
b = cur[j+1];
c = cur[j+2];
d = (inc === 2) ? 0 : cur[j+3];
cur[cnt++] = tmp = (inc === 3) ? new Segment(a, b, c, d) : new Segment(a, (2 * b + a) / 3, (2 * b + c) / 3, c);
}
cur.length = cnt;
}
return obj;
},
_addCubicLengths = function(a, steps, resolution) {
var inc = 1 / resolution,
j = a.length,
d, d1, s, da, ca, ba, p, i, inv, bez, index;
while (--j > -1) {
bez = a[j];
s = bez.a;
da = bez.d - s;
ca = bez.c - s;
ba = bez.b - s;
d = d1 = 0;
for (i = 1; i <= resolution; i++) {
p = inc * i;
inv = 1 - p;
d = d1 - (d1 = (p * p * da + 3 * inv * (p * ca + inv * ba)) * p);
index = j * resolution + i - 1;
steps[index] = (steps[index] || 0) + d * d;
}
}
},
_parseLengthData = function(obj, resolution) {
resolution = resolution >> 0 || 6;
var a = [],
lengths = [],
d = 0,
total = 0,
threshold = resolution - 1,
segments = [],
curLS = [], //current length segments array
p, i, l, index;
for (p in obj) {
_addCubicLengths(obj[p], a, resolution);
}
l = a.length;
for (i = 0; i < l; i++) {
d += Math.sqrt(a[i]);
index = i % resolution;
curLS[index] = d;
if (index === threshold) {
total += d;
index = (i / resolution) >> 0;
segments[index] = curLS;
lengths[index] = total;
d = 0;
curLS = [];
}
}
return {length:total, lengths:lengths, segments:segments};
},
BezierPlugin = _gsScope._gsDefine.plugin({
propName: "bezier",
priority: -1,
version: "1.3.8",
API: 2,
global:true,
//gets called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
init: function(target, vars, tween) {
this._target = target;
if (vars instanceof Array) {
vars = {values:vars};
}
this._func = {};
this._mod = {};
this._props = [];
this._timeRes = (vars.timeResolution == null) ? 6 : parseInt(vars.timeResolution, 10);
var values = vars.values || [],
first = {},
second = values[0],
autoRotate = vars.autoRotate || tween.vars.orientToBezier,
p, isFunc, i, j, prepend;
this._autoRotate = autoRotate ? (autoRotate instanceof Array) ? autoRotate : [["x","y","rotation",((autoRotate === true) ? 0 : Number(autoRotate) || 0)]] : null;
for (p in second) {
this._props.push(p);
}
i = this._props.length;
while (--i > -1) {
p = this._props[i];
this._overwriteProps.push(p);
isFunc = this._func[p] = (typeof(target[p]) === "function");
first[p] = (!isFunc) ? parseFloat(target[p]) : target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]();
if (!prepend) if (first[p] !== values[0][p]) {
prepend = first;
}
}
this._beziers = (vars.type !== "cubic" && vars.type !== "quadratic" && vars.type !== "soft") ? bezierThrough(values, isNaN(vars.curviness) ? 1 : vars.curviness, false, (vars.type === "thruBasic"), vars.correlate, prepend) : _parseBezierData(values, vars.type, first);
this._segCount = this._beziers[p].length;
if (this._timeRes) {
var ld = _parseLengthData(this._beziers, this._timeRes);
this._length = ld.length;
this._lengths = ld.lengths;
this._segments = ld.segments;
this._l1 = this._li = this._s1 = this._si = 0;
this._l2 = this._lengths[0];
this._curSeg = this._segments[0];
this._s2 = this._curSeg[0];
this._prec = 1 / this._curSeg.length;
}
if ((autoRotate = this._autoRotate)) {
this._initialRotations = [];
if (!(autoRotate[0] instanceof Array)) {
this._autoRotate = autoRotate = [autoRotate];
}
i = autoRotate.length;
while (--i > -1) {
for (j = 0; j < 3; j++) {
p = autoRotate[i][j];
this._func[p] = (typeof(target[p]) === "function") ? target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ] : false;
}
p = autoRotate[i][2];
this._initialRotations[i] = (this._func[p] ? this._func[p].call(this._target) : this._target[p]) || 0;
this._overwriteProps.push(p);
}
}
this._startRatio = tween.vars.runBackwards ? 1 : 0; //we determine the starting ratio when the tween inits which is always 0 unless the tween has runBackwards:true (indicating it's a from() tween) in which case it's 1.
return true;
},
//called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.)
set: function(v) {
var segments = this._segCount,
func = this._func,
target = this._target,
notStart = (v !== this._startRatio),
curIndex, inv, i, p, b, t, val, l, lengths, curSeg;
if (!this._timeRes) {
curIndex = (v < 0) ? 0 : (v >= 1) ? segments - 1 : (segments * v) >> 0;
t = (v - (curIndex * (1 / segments))) * segments;
} else {
lengths = this._lengths;
curSeg = this._curSeg;
v *= this._length;
i = this._li;
//find the appropriate segment (if the currently cached one isn't correct)
if (v > this._l2 && i < segments - 1) {
l = segments - 1;
while (i < l && (this._l2 = lengths[++i]) <= v) { }
this._l1 = lengths[i-1];
this._li = i;
this._curSeg = curSeg = this._segments[i];
this._s2 = curSeg[(this._s1 = this._si = 0)];
} else if (v < this._l1 && i > 0) {
while (i > 0 && (this._l1 = lengths[--i]) >= v) { }
if (i === 0 && v < this._l1) {
this._l1 = 0;
} else {
i++;
}
this._l2 = lengths[i];
this._li = i;
this._curSeg = curSeg = this._segments[i];
this._s1 = curSeg[(this._si = curSeg.length - 1) - 1] || 0;
this._s2 = curSeg[this._si];
}
curIndex = i;
//now find the appropriate sub-segment (we split it into the number of pieces that was defined by "precision" and measured each one)
v -= this._l1;
i = this._si;
if (v > this._s2 && i < curSeg.length - 1) {
l = curSeg.length - 1;
while (i < l && (this._s2 = curSeg[++i]) <= v) { }
this._s1 = curSeg[i-1];
this._si = i;
} else if (v < this._s1 && i > 0) {
while (i > 0 && (this._s1 = curSeg[--i]) >= v) { }
if (i === 0 && v < this._s1) {
this._s1 = 0;
} else {
i++;
}
this._s2 = curSeg[i];
this._si = i;
}
t = ((i + (v - this._s1) / (this._s2 - this._s1)) * this._prec) || 0;
}
inv = 1 - t;
i = this._props.length;
while (--i > -1) {
p = this._props[i];
b = this._beziers[p][curIndex];
val = (t * t * b.da + 3 * inv * (t * b.ca + inv * b.ba)) * t + b.a;
if (this._mod[p]) {
val = this._mod[p](val, target);
}
if (func[p]) {
target[p](val);
} else {
target[p] = val;
}
}
if (this._autoRotate) {
var ar = this._autoRotate,
b2, x1, y1, x2, y2, add, conv;
i = ar.length;
while (--i > -1) {
p = ar[i][2];
add = ar[i][3] || 0;
conv = (ar[i][4] === true) ? 1 : _RAD2DEG;
b = this._beziers[ar[i][0]];
b2 = this._beziers[ar[i][1]];
if (b && b2) { //in case one of the properties got overwritten.
b = b[curIndex];
b2 = b2[curIndex];
x1 = b.a + (b.b - b.a) * t;
x2 = b.b + (b.c - b.b) * t;
x1 += (x2 - x1) * t;
x2 += ((b.c + (b.d - b.c) * t) - x2) * t;
y1 = b2.a + (b2.b - b2.a) * t;
y2 = b2.b + (b2.c - b2.b) * t;
y1 += (y2 - y1) * t;
y2 += ((b2.c + (b2.d - b2.c) * t) - y2) * t;
val = notStart ? Math.atan2(y2 - y1, x2 - x1) * conv + add : this._initialRotations[i];
if (this._mod[p]) {
val = this._mod[p](val, target); //for modProps
}
if (func[p]) {
target[p](val);
} else {
target[p] = val;
}
}
}
}
}
}),
p = BezierPlugin.prototype;
BezierPlugin.bezierThrough = bezierThrough;
BezierPlugin.cubicToQuadratic = cubicToQuadratic;
BezierPlugin._autoCSS = true; //indicates that this plugin can be inserted into the "css" object using the autoCSS feature of TweenLite
BezierPlugin.quadraticToCubic = function(a, b, c) {
return new Segment(a, (2 * b + a) / 3, (2 * b + c) / 3, c);
};
BezierPlugin._cssRegister = function() {
var CSSPlugin = _globals.CSSPlugin;
if (!CSSPlugin) {
return;
}
var _internals = CSSPlugin._internals,
_parseToProxy = _internals._parseToProxy,
_setPluginRatio = _internals._setPluginRatio,
CSSPropTween = _internals.CSSPropTween;
_internals._registerComplexSpecialProp("bezier", {parser:function(t, e, prop, cssp, pt, plugin) {
if (e instanceof Array) {
e = {values:e};
}
plugin = new BezierPlugin();
var values = e.values,
l = values.length - 1,
pluginValues = [],
v = {},
i, p, data;
if (l < 0) {
return pt;
}
for (i = 0; i <= l; i++) {
data = _parseToProxy(t, values[i], cssp, pt, plugin, (l !== i));
pluginValues[i] = data.end;
}
for (p in e) {
v[p] = e[p]; //duplicate the vars object because we need to alter some things which would cause problems if the user plans to reuse the same vars object for another tween.
}
v.values = pluginValues;
pt = new CSSPropTween(t, "bezier", 0, 0, data.pt, 2);
pt.data = data;
pt.plugin = plugin;
pt.setRatio = _setPluginRatio;
if (v.autoRotate === 0) {
v.autoRotate = true;
}
if (v.autoRotate && !(v.autoRotate instanceof Array)) {
i = (v.autoRotate === true) ? 0 : Number(v.autoRotate);
v.autoRotate = (data.end.left != null) ? [["left","top","rotation",i,false]] : (data.end.x != null) ? [["x","y","rotation",i,false]] : false;
}
if (v.autoRotate) {
if (!cssp._transform) {
cssp._enableTransforms(false);
}
data.autoRotate = cssp._target._gsTransform;
data.proxy.rotation = data.autoRotate.rotation || 0;
cssp._overwriteProps.push("rotation");
}
plugin._onInitTween(data.proxy, v, cssp._tween);
return pt;
}});
};
p._mod = function(lookup) {
var op = this._overwriteProps,
i = op.length,
val;
while (--i > -1) {
val = lookup[op[i]];
if (val && typeof(val) === "function") {
this._mod[op[i]] = val;
}
}
};
p._kill = function(lookup) {
var a = this._props,
p, i;
for (p in this._beziers) {
if (p in lookup) {
delete this._beziers[p];
delete this._func[p];
i = a.length;
while (--i > -1) {
if (a[i] === p) {
a.splice(i, 1);
}
}
}
}
a = this._autoRotate;
if (a) {
i = a.length;
while (--i > -1) {
if (lookup[a[i][2]]) {
a.splice(i, 1);
}
}
}
return this._super._kill.call(this, lookup);
};
export { BezierPlugin, BezierPlugin as default };

2917
lib/3rdparty/gsap/src/esm/CSSPlugin.js vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,106 @@
/*!
* VERSION: 0.6.7
* DATE: 2018-08-27
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
import TweenLite, { _gsScope, globals, TweenPlugin } from "./TweenLite.js";
import CSSPlugin from "./CSSPlugin.js";
_gsScope._gsDefine("plugins.CSSRulePlugin", ["plugins.TweenPlugin","TweenLite","plugins.CSSPlugin"], function() {
/** @constructor **/
var CSSRulePlugin = function() {
TweenPlugin.call(this, "cssRule");
this._overwriteProps.length = 0;
},
_doc = _gsScope.document,
_superSetRatio = CSSPlugin.prototype.setRatio,
p = CSSRulePlugin.prototype = new CSSPlugin();
p._propName = "cssRule";
p.constructor = CSSRulePlugin;
CSSRulePlugin.version = "0.6.7";
CSSRulePlugin.API = 2;
/**
* Searches the style sheets in the document for a particular selector like ".myClass" or "a" or "a:hover" or ":after" and
* returns a reference to that style sheet (or an array of them in the case of a pseudo selector like ":after"). Then you
* can animate the individual properties of the style sheet.
*
* @param {!string} selector a string describing the selector, like ".myClass" or "a" or "a:hover" or ":after"
* @return a reference to the style sheet (or an array of them in the case of a pseudo selector). If none was found, null is returned (or an empty array for a pseudo selector)
*/
CSSRulePlugin.getRule = function(selector) {
var ruleProp = _doc.all ? "rules" : "cssRules",
ss = _doc.styleSheets,
i = ss.length,
pseudo = (selector.charAt(0) === ":"),
j, curSS, cs, a;
selector = (pseudo ? "" : ",") + selector.split("::").join(":").toLowerCase() + ","; //note: old versions of IE report tag name selectors as upper case, so we just change everything to lowercase.
if (pseudo) {
a = [];
}
while (--i > -1) {
//Firefox may throw insecure operation errors when css is loaded from other domains, so try/catch.
try {
curSS = ss[i][ruleProp];
if (!curSS) {
continue;
}
j = curSS.length;
} catch (e) {
console.log(e);
continue;
}
while (--j > -1) {
cs = curSS[j];
if (cs.selectorText && ("," + cs.selectorText.split("::").join(":").toLowerCase() + ",").indexOf(selector) !== -1) { //note: IE adds an extra ":" to pseudo selectors, so .myClass:after becomes .myClass::after, so we need to strip the extra one out.
if (pseudo) {
a.push(cs.style);
} else {
return cs.style;
}
}
}
}
return a;
};
// @private gets called when the tween renders for the first time. This kicks everything off, recording start/end values, etc.
p._onInitTween = function(target, value, tween) {
if (target.cssText === undefined) {
return false;
}
var div = target._gsProxy = target._gsProxy || _doc.createElement("div");
this._ss = target;
this._proxy = div.style;
div.style.cssText = target.cssText;
CSSPlugin.prototype._onInitTween.call(this, div, value, tween); //we just offload all the work to the regular CSSPlugin and then copy the cssText back over to the rule in the setRatio() method. This allows us to have all of the updates to CSSPlugin automatically flow through to CSSRulePlugin instead of having to maintain both
return true;
};
// @private gets called every time the tween updates, passing the new ratio (typically a value between 0 and 1, but not always (for example, if an Elastic.easeOut is used, the value can jump above 1 mid-tween). It will always start and 0 and end at 1.
p.setRatio = function(v) {
_superSetRatio.call(this, v);
this._ss.cssText = this._proxy.cssText;
};
TweenPlugin.activate([CSSRulePlugin]);
return CSSRulePlugin;
}, true);
export var CSSRulePlugin = globals.CSSRulePlugin;
export { CSSRulePlugin as default };

View File

@ -0,0 +1,232 @@
/*!
* VERSION: 1.5.3
* DATE: 2018-05-30
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
/* eslint-disable */
import { _gsScope } from "./TweenLite.js";
var _numExp = /(\d|\.)+/g,
_relNumExp = /(?:\d|\-\d|\.\d|\-\.\d|\+=\d|\-=\d|\+=.\d|\-=\.\d)+/g,
_colorLookup = {aqua:[0,255,255],
lime:[0,255,0],
silver:[192,192,192],
black:[0,0,0],
maroon:[128,0,0],
teal:[0,128,128],
blue:[0,0,255],
navy:[0,0,128],
white:[255,255,255],
fuchsia:[255,0,255],
olive:[128,128,0],
yellow:[255,255,0],
orange:[255,165,0],
gray:[128,128,128],
purple:[128,0,128],
green:[0,128,0],
red:[255,0,0],
pink:[255,192,203],
cyan:[0,255,255],
transparent:[255,255,255,0]},
_hue = function(h, m1, m2) {
h = (h < 0) ? h + 1 : (h > 1) ? h - 1 : h;
return ((((h * 6 < 1) ? m1 + (m2 - m1) * h * 6 : (h < 0.5) ? m2 : (h * 3 < 2) ? m1 + (m2 - m1) * (2 / 3 - h) * 6 : m1) * 255) + 0.5) | 0;
},
/**
* @private Parses a color (like #9F0, #FF9900, rgb(255,51,153) or hsl(108, 50%, 10%)) into an array with 3 elements for red, green, and blue or if toHSL parameter is true, it will populate the array with hue, saturation, and lightness values. If a relative value is found in an hsl() or hsla() string, it will preserve those relative prefixes and all the values in the array will be strings instead of numbers (in all other cases it will be populated with numbers).
* @param {(string|number)} v The value the should be parsed which could be a string like #9F0 or rgb(255,102,51) or rgba(255,0,0,0.5) or it could be a number like 0xFF00CC or even a named color like red, blue, purple, etc.
* @param {(boolean)} toHSL If true, an hsl() or hsla() value will be returned instead of rgb() or rgba()
* @return {Array.<number>} An array containing red, green, and blue (and optionally alpha) in that order, or if the toHSL parameter was true, the array will contain hue, saturation and lightness (and optionally alpha) in that order. Always numbers unless there's a relative prefix found in an hsl() or hsla() string and toHSL is true.
*/
_parseColor = function(v, toHSL) {
var a, r, g, b, h, s, l, max, min, d, wasHSL;
if (!v) {
a = _colorLookup.black;
} else if (typeof(v) === "number") {
a = [v >> 16, (v >> 8) & 255, v & 255];
} else {
if (v.charAt(v.length - 1) === ",") { //sometimes a trailing comma is included and we should chop it off (typically from a comma-delimited list of values like a textShadow:"2px 2px 2px blue, 5px 5px 5px rgb(255,0,0)" - in this example "blue," has a trailing comma. We could strip it out inside parseComplex() but we'd need to do it to the beginning and ending values plus it wouldn't provide protection from other potential scenarios like if the user passes in a similar value.
v = v.substr(0, v.length - 1);
}
if (_colorLookup[v]) {
a = _colorLookup[v];
} else if (v.charAt(0) === "#") {
if (v.length === 4) { //for shorthand like #9F0
r = v.charAt(1);
g = v.charAt(2);
b = v.charAt(3);
v = "#" + r + r + g + g + b + b;
}
v = parseInt(v.substr(1), 16);
a = [v >> 16, (v >> 8) & 255, v & 255];
} else if (v.substr(0, 3) === "hsl") {
a = wasHSL = v.match(_numExp);
if (!toHSL) {
h = (Number(a[0]) % 360) / 360;
s = Number(a[1]) / 100;
l = Number(a[2]) / 100;
g = (l <= 0.5) ? l * (s + 1) : l + s - l * s;
r = l * 2 - g;
if (a.length > 3) {
a[3] = Number(a[3]);
}
a[0] = _hue(h + 1 / 3, r, g);
a[1] = _hue(h, r, g);
a[2] = _hue(h - 1 / 3, r, g);
} else if (v.indexOf("=") !== -1) { //if relative values are found, just return the raw strings with the relative prefixes in place.
return v.match(_relNumExp);
}
} else {
a = v.match(_numExp) || _colorLookup.transparent;
}
a[0] = Number(a[0]);
a[1] = Number(a[1]);
a[2] = Number(a[2]);
if (a.length > 3) {
a[3] = Number(a[3]);
}
}
if (toHSL && !wasHSL) {
r = a[0] / 255;
g = a[1] / 255;
b = a[2] / 255;
max = Math.max(r, g, b);
min = Math.min(r, g, b);
l = (max + min) / 2;
if (max === min) {
h = s = 0;
} else {
d = max - min;
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
h = (max === r) ? (g - b) / d + (g < b ? 6 : 0) : (max === g) ? (b - r) / d + 2 : (r - g) / d + 4;
h *= 60;
}
a[0] = (h + 0.5) | 0;
a[1] = (s * 100 + 0.5) | 0;
a[2] = (l * 100 + 0.5) | 0;
}
return a;
},
_formatColors = function(s, toHSL) {
var colors = (s + "").match(_colorExp) || [],
charIndex = 0,
parsed = "",
i, color, temp;
if (!colors.length) {
return s;
}
for (i = 0; i < colors.length; i++) {
color = colors[i];
temp = s.substr(charIndex, s.indexOf(color, charIndex)-charIndex);
charIndex += temp.length + color.length;
color = _parseColor(color, toHSL);
if (color.length === 3) {
color.push(1);
}
parsed += temp + (toHSL ? "hsla(" + color[0] + "," + color[1] + "%," + color[2] + "%," + color[3] : "rgba(" + color.join(",")) + ")";
}
return parsed + s.substr(charIndex);
}, p, _colorStringFilter,
TweenLite = (_gsScope.GreenSockGlobals || _gsScope).TweenLite,
_colorExp = "(?:\\b(?:(?:rgb|rgba|hsl|hsla)\\(.+?\\))|\\B#(?:[0-9a-f]{3}){1,2}\\b", //we'll dynamically build this Regular Expression to conserve file size. After building it, it will be able to find rgb(), rgba(), # (hexadecimal), and named color values like red, blue, purple, etc.
ColorPropsPlugin = _gsScope._gsDefine.plugin({
propName: "colorProps",
version: "1.5.3",
priority: -1,
API: 2,
global: true,
//called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
init: function(target, value, tween, index) {
var p, proxy, pt, val;
this._target = target;
this._proxy = proxy = ((value.format + "").toUpperCase() === "NUMBER") ? {} : 0;
for (p in value) {
if (p !== "format") {
if (proxy) {
this._firstNumPT = pt = {_next:this._firstNumPT, t:target, p:p, f:(typeof(target[p]) === "function")};
proxy[p] = "rgb(" + _parseColor(!pt.f ? target[p] : target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]()).join(",") + ")";
val = value[p];
if (typeof(val) === "function") {
val = val(index, target);
}
this._addTween(proxy, p, "get", ((typeof(val) === "number") ? "rgb(" + _parseColor(val, false).join(",") + ")" : val), p, null, null, _colorStringFilter);
} else {
this._addTween(target, p, "get", value[p], p, null, null, _colorStringFilter, index);
}
}
}
return true;
},
//called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.)
set: function(v) {
var pt = this._firstNumPT,
val;
this._super.setRatio.call(this, v);
while (pt) {
val = _parseColor(this._proxy[pt.p], false);
val = val[0] << 16 | val[1] << 8 | val[2];
if (pt.f) {
this._target[pt.p](val);
} else {
this._target[pt.p] = val;
}
pt = pt._next;
}
}
});
for (p in _colorLookup) {
_colorExp += "|" + p + "\\b";
}
_colorExp = new RegExp(_colorExp+")", "gi");
ColorPropsPlugin.colorStringFilter = _colorStringFilter = function(a) {
var combined = a[0] + " " + a[1],
toHSL;
_colorExp.lastIndex = 0;
if (_colorExp.test(combined)) {
toHSL = (combined.indexOf("hsl(") !== -1 || combined.indexOf("hsla(") !== -1);
a[0] = _formatColors(a[0], toHSL);
a[1] = _formatColors(a[1], toHSL);
}
};
if (!TweenLite.defaultStringFilter) {
TweenLite.defaultStringFilter = ColorPropsPlugin.colorStringFilter;
}
ColorPropsPlugin.parseColor = _parseColor;
p = ColorPropsPlugin.prototype;
p._firstNumPT = null;
p._kill = function(lookup) {
var pt = this._firstNumPT,
prev;
while (pt) {
if (pt.p in lookup) {
if (pt === p._firstNumPT) {
this._firstNumPT = pt._next;
}
if (prev) {
prev._next = pt._next;
}
} else {
prev = pt;
}
pt = pt._next;
}
return this._super._kill(lookup);
};
export { ColorPropsPlugin, ColorPropsPlugin as default };

View File

@ -0,0 +1,86 @@
/*!
* VERSION: 0.3.1
* DATE: 2018-08-27
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
/* eslint-disable */
import { _gsScope } from "./TweenLite.js";
export var DirectionalRotationPlugin = _gsScope._gsDefine.plugin({
propName: "directionalRotation",
version: "0.3.1",
API: 2,
//called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
init: function(target, value, tween, index) {
if (typeof(value) !== "object") {
value = {rotation:value};
}
this.finals = {};
var cap = (value.useRadians === true) ? Math.PI * 2 : 360,
min = 0.000001,
p, v, start, end, dif, split;
for (p in value) {
if (p !== "useRadians") {
end = value[p];
if (typeof(end) === "function") {
end = end(index, target);
}
split = (end + "").split("_");
v = split[0];
start = parseFloat( (typeof(target[p]) !== "function") ? target[p] : target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]() );
end = this.finals[p] = (typeof(v) === "string" && v.charAt(1) === "=") ? start + parseInt(v.charAt(0) + "1", 10) * Number(v.substr(2)) : Number(v) || 0;
dif = end - start;
if (split.length) {
v = split.join("_");
if (v.indexOf("short") !== -1) {
dif = dif % cap;
if (dif !== dif % (cap / 2)) {
dif = (dif < 0) ? dif + cap : dif - cap;
}
}
if (v.indexOf("_cw") !== -1 && dif < 0) {
dif = ((dif + cap * 9999999999) % cap) - ((dif / cap) | 0) * cap;
} else if (v.indexOf("ccw") !== -1 && dif > 0) {
dif = ((dif - cap * 9999999999) % cap) - ((dif / cap) | 0) * cap;
}
}
if (dif > min || dif < -min) {
this._addTween(target, p, start, start + dif, p);
this._overwriteProps.push(p);
}
}
}
return true;
},
//called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.)
set: function(ratio) {
var pt;
if (ratio !== 1) {
this._super.setRatio.call(this, ratio);
} else {
pt = this._firstPT;
while (pt) {
if (pt.f) {
pt.t[pt.p](this.finals[pt.p]);
} else {
pt.t[pt.p] = this.finals[pt.p];
}
pt = pt._next;
}
}
}
});
DirectionalRotationPlugin._autoCSS = true;
export { DirectionalRotationPlugin as default };

2502
lib/3rdparty/gsap/src/esm/Draggable.js vendored Normal file

File diff suppressed because it is too large Load Diff

375
lib/3rdparty/gsap/src/esm/EasePack.js vendored Normal file
View File

@ -0,0 +1,375 @@
/*!
* VERSION: 1.16.1
* DATE: 2018-08-27
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
/* eslint-disable */
import { _gsScope, globals, Ease, Linear, Power0, Power1, Power2, Power3, Power4 } from "./TweenLite.js";
_gsScope._gsDefine("easing.Back", ["easing.Ease"], function() {
var w = (_gsScope.GreenSockGlobals || _gsScope),
gs = w.com.greensock,
_2PI = Math.PI * 2,
_HALF_PI = Math.PI / 2,
_class = gs._class,
_create = function(n, f) {
var C = _class("easing." + n, function(){}, true),
p = C.prototype = new Ease();
p.constructor = C;
p.getRatio = f;
return C;
},
_easeReg = Ease.register || function(){}, //put an empty function in place just as a safety measure in case someone loads an OLD version of TweenLite.js where Ease.register doesn't exist.
_wrap = function(name, EaseOut, EaseIn, EaseInOut, aliases) {
var C = _class("easing."+name, {
easeOut:new EaseOut(),
easeIn:new EaseIn(),
easeInOut:new EaseInOut()
}, true);
_easeReg(C, name);
return C;
},
EasePoint = function(time, value, next) {
this.t = time;
this.v = value;
if (next) {
this.next = next;
next.prev = this;
this.c = next.v - value;
this.gap = next.t - time;
}
},
//Back
_createBack = function(n, f) {
var C = _class("easing." + n, function(overshoot) {
this._p1 = (overshoot || overshoot === 0) ? overshoot : 1.70158;
this._p2 = this._p1 * 1.525;
}, true),
p = C.prototype = new Ease();
p.constructor = C;
p.getRatio = f;
p.config = function(overshoot) {
return new C(overshoot);
};
return C;
},
Back = _wrap("Back",
_createBack("BackOut", function(p) {
return ((p = p - 1) * p * ((this._p1 + 1) * p + this._p1) + 1);
}),
_createBack("BackIn", function(p) {
return p * p * ((this._p1 + 1) * p - this._p1);
}),
_createBack("BackInOut", function(p) {
return ((p *= 2) < 1) ? 0.5 * p * p * ((this._p2 + 1) * p - this._p2) : 0.5 * ((p -= 2) * p * ((this._p2 + 1) * p + this._p2) + 2);
})
),
//SlowMo
SlowMo = _class("easing.SlowMo", function(linearRatio, power, yoyoMode) {
power = (power || power === 0) ? power : 0.7;
if (linearRatio == null) {
linearRatio = 0.7;
} else if (linearRatio > 1) {
linearRatio = 1;
}
this._p = (linearRatio !== 1) ? power : 0;
this._p1 = (1 - linearRatio) / 2;
this._p2 = linearRatio;
this._p3 = this._p1 + this._p2;
this._calcEnd = (yoyoMode === true);
}, true),
p = SlowMo.prototype = new Ease(),
SteppedEase, ExpoScaleEase, RoughEase, _createElastic;
p.constructor = SlowMo;
p.getRatio = function(p) {
var r = p + (0.5 - p) * this._p;
if (p < this._p1) {
return this._calcEnd ? 1 - ((p = 1 - (p / this._p1)) * p) : r - ((p = 1 - (p / this._p1)) * p * p * p * r);
} else if (p > this._p3) {
return this._calcEnd ? (p === 1 ? 0 : 1 - (p = (p - this._p3) / this._p1) * p) : r + ((p - r) * (p = (p - this._p3) / this._p1) * p * p * p); //added p === 1 ? 0 to avoid floating point rounding errors from affecting the final value, like 1 - 0.7 = 0.30000000000000004 instead of 0.3
}
return this._calcEnd ? 1 : r;
};
SlowMo.ease = new SlowMo(0.7, 0.7);
p.config = SlowMo.config = function(linearRatio, power, yoyoMode) {
return new SlowMo(linearRatio, power, yoyoMode);
};
//SteppedEase
SteppedEase = _class("easing.SteppedEase", function(steps, immediateStart) {
steps = steps || 1;
this._p1 = 1 / steps;
this._p2 = steps + (immediateStart ? 0 : 1);
this._p3 = immediateStart ? 1 : 0;
}, true);
p = SteppedEase.prototype = new Ease();
p.constructor = SteppedEase;
p.getRatio = function(p) {
if (p < 0) {
p = 0;
} else if (p >= 1) {
p = 0.999999999;
}
return (((this._p2 * p) | 0) + this._p3) * this._p1;
};
p.config = SteppedEase.config = function(steps, immediateStart) {
return new SteppedEase(steps, immediateStart);
};
//ExpoScaleEase
ExpoScaleEase = _class("easing.ExpoScaleEase", function(start, end, ease) {
this._p1 = Math.log(end / start);
this._p2 = end - start;
this._p3 = start;
this._ease = ease;
}, true);
p = ExpoScaleEase.prototype = new Ease();
p.constructor = ExpoScaleEase;
p.getRatio = function(p) {
if (this._ease) {
p = this._ease.getRatio(p);
}
return (this._p3 * Math.exp(this._p1 * p) - this._p3) / this._p2;
};
p.config = ExpoScaleEase.config = function(start, end, ease) {
return new ExpoScaleEase(start, end, ease);
};
//RoughEase
RoughEase = _class("easing.RoughEase", function(vars) {
vars = vars || {};
var taper = vars.taper || "none",
a = [],
cnt = 0,
points = (vars.points || 20) | 0,
i = points,
randomize = (vars.randomize !== false),
clamp = (vars.clamp === true),
template = (vars.template instanceof Ease) ? vars.template : null,
strength = (typeof(vars.strength) === "number") ? vars.strength * 0.4 : 0.4,
x, y, bump, invX, obj, pnt;
while (--i > -1) {
x = randomize ? Math.random() : (1 / points) * i;
y = template ? template.getRatio(x) : x;
if (taper === "none") {
bump = strength;
} else if (taper === "out") {
invX = 1 - x;
bump = invX * invX * strength;
} else if (taper === "in") {
bump = x * x * strength;
} else if (x < 0.5) { //"both" (start)
invX = x * 2;
bump = invX * invX * 0.5 * strength;
} else { //"both" (end)
invX = (1 - x) * 2;
bump = invX * invX * 0.5 * strength;
}
if (randomize) {
y += (Math.random() * bump) - (bump * 0.5);
} else if (i % 2) {
y += bump * 0.5;
} else {
y -= bump * 0.5;
}
if (clamp) {
if (y > 1) {
y = 1;
} else if (y < 0) {
y = 0;
}
}
a[cnt++] = {x:x, y:y};
}
a.sort(function(a, b) {
return a.x - b.x;
});
pnt = new EasePoint(1, 1, null);
i = points;
while (--i > -1) {
obj = a[i];
pnt = new EasePoint(obj.x, obj.y, pnt);
}
this._prev = new EasePoint(0, 0, (pnt.t !== 0) ? pnt : pnt.next);
}, true);
p = RoughEase.prototype = new Ease();
p.constructor = RoughEase;
p.getRatio = function(p) {
var pnt = this._prev;
if (p > pnt.t) {
while (pnt.next && p >= pnt.t) {
pnt = pnt.next;
}
pnt = pnt.prev;
} else {
while (pnt.prev && p <= pnt.t) {
pnt = pnt.prev;
}
}
this._prev = pnt;
return (pnt.v + ((p - pnt.t) / pnt.gap) * pnt.c);
};
p.config = function(vars) {
return new RoughEase(vars);
};
RoughEase.ease = new RoughEase();
//Bounce
_wrap("Bounce",
_create("BounceOut", function(p) {
if (p < 1 / 2.75) {
return 7.5625 * p * p;
} else if (p < 2 / 2.75) {
return 7.5625 * (p -= 1.5 / 2.75) * p + 0.75;
} else if (p < 2.5 / 2.75) {
return 7.5625 * (p -= 2.25 / 2.75) * p + 0.9375;
}
return 7.5625 * (p -= 2.625 / 2.75) * p + 0.984375;
}),
_create("BounceIn", function(p) {
if ((p = 1 - p) < 1 / 2.75) {
return 1 - (7.5625 * p * p);
} else if (p < 2 / 2.75) {
return 1 - (7.5625 * (p -= 1.5 / 2.75) * p + 0.75);
} else if (p < 2.5 / 2.75) {
return 1 - (7.5625 * (p -= 2.25 / 2.75) * p + 0.9375);
}
return 1 - (7.5625 * (p -= 2.625 / 2.75) * p + 0.984375);
}),
_create("BounceInOut", function(p) {
var invert = (p < 0.5);
if (invert) {
p = 1 - (p * 2);
} else {
p = (p * 2) - 1;
}
if (p < 1 / 2.75) {
p = 7.5625 * p * p;
} else if (p < 2 / 2.75) {
p = 7.5625 * (p -= 1.5 / 2.75) * p + 0.75;
} else if (p < 2.5 / 2.75) {
p = 7.5625 * (p -= 2.25 / 2.75) * p + 0.9375;
} else {
p = 7.5625 * (p -= 2.625 / 2.75) * p + 0.984375;
}
return invert ? (1 - p) * 0.5 : p * 0.5 + 0.5;
})
);
//CIRC
_wrap("Circ",
_create("CircOut", function(p) {
return Math.sqrt(1 - (p = p - 1) * p);
}),
_create("CircIn", function(p) {
return -(Math.sqrt(1 - (p * p)) - 1);
}),
_create("CircInOut", function(p) {
return ((p*=2) < 1) ? -0.5 * (Math.sqrt(1 - p * p) - 1) : 0.5 * (Math.sqrt(1 - (p -= 2) * p) + 1);
})
);
//Elastic
_createElastic = function(n, f, def) {
var C = _class("easing." + n, function(amplitude, period) {
this._p1 = (amplitude >= 1) ? amplitude : 1; //note: if amplitude is < 1, we simply adjust the period for a more natural feel. Otherwise the math doesn't work right and the curve starts at 1.
this._p2 = (period || def) / (amplitude < 1 ? amplitude : 1);
this._p3 = this._p2 / _2PI * (Math.asin(1 / this._p1) || 0);
this._p2 = _2PI / this._p2; //precalculate to optimize
}, true),
p = C.prototype = new Ease();
p.constructor = C;
p.getRatio = f;
p.config = function(amplitude, period) {
return new C(amplitude, period);
};
return C;
};
_wrap("Elastic",
_createElastic("ElasticOut", function(p) {
return this._p1 * Math.pow(2, -10 * p) * Math.sin( (p - this._p3) * this._p2 ) + 1;
}, 0.3),
_createElastic("ElasticIn", function(p) {
return -(this._p1 * Math.pow(2, 10 * (p -= 1)) * Math.sin( (p - this._p3) * this._p2 ));
}, 0.3),
_createElastic("ElasticInOut", function(p) {
return ((p *= 2) < 1) ? -0.5 * (this._p1 * Math.pow(2, 10 * (p -= 1)) * Math.sin( (p - this._p3) * this._p2)) : this._p1 * Math.pow(2, -10 *(p -= 1)) * Math.sin( (p - this._p3) * this._p2 ) * 0.5 + 1;
}, 0.45)
);
//Expo
_wrap("Expo",
_create("ExpoOut", function(p) {
return 1 - Math.pow(2, -10 * p);
}),
_create("ExpoIn", function(p) {
return Math.pow(2, 10 * (p - 1)) - 0.001;
}),
_create("ExpoInOut", function(p) {
return ((p *= 2) < 1) ? 0.5 * Math.pow(2, 10 * (p - 1)) : 0.5 * (2 - Math.pow(2, -10 * (p - 1)));
})
);
//Sine
_wrap("Sine",
_create("SineOut", function(p) {
return Math.sin(p * _HALF_PI);
}),
_create("SineIn", function(p) {
return -Math.cos(p * _HALF_PI) + 1;
}),
_create("SineInOut", function(p) {
return -0.5 * (Math.cos(Math.PI * p) - 1);
})
);
_class("easing.EaseLookup", {
find:function(s) {
return Ease.map[s];
}
}, true);
//register the non-standard eases
_easeReg(w.SlowMo, "SlowMo", "ease,");
_easeReg(RoughEase, "RoughEase", "ease,");
_easeReg(SteppedEase, "SteppedEase", "ease,");
return Back;
}, true);
export var Back = globals.Back;
export var Elastic = globals.Elastic;
export var Bounce = globals.Bounce;
export var RoughEase = globals.RoughEase;
export var SlowMo = globals.SlowMo;
export var SteppedEase = globals.SteppedEase;
export var Circ = globals.Circ;
export var Expo = globals.Expo;
export var Sine = globals.Sine;
export var ExpoScaleEase = globals.ExpoScaleEase;
export { Linear, Power0, Power1, Power2, Power3, Power4 };

312
lib/3rdparty/gsap/src/esm/EaselPlugin.js vendored Normal file
View File

@ -0,0 +1,312 @@
/*!
* VERSION: 0.2.2
* DATE: 2018-05-30
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
/* eslint-disable */
import { _gsScope } from "./TweenLite.js";
var _numExp = /(\d|\.)+/g,
_ColorFilter, _ColorMatrixFilter,
_colorProps = ["redMultiplier","greenMultiplier","blueMultiplier","alphaMultiplier","redOffset","greenOffset","blueOffset","alphaOffset"],
_colorLookup = {aqua:[0,255,255],
lime:[0,255,0],
silver:[192,192,192],
black:[0,0,0],
maroon:[128,0,0],
teal:[0,128,128],
blue:[0,0,255],
navy:[0,0,128],
white:[255,255,255],
fuchsia:[255,0,255],
olive:[128,128,0],
yellow:[255,255,0],
orange:[255,165,0],
gray:[128,128,128],
purple:[128,0,128],
green:[0,128,0],
red:[255,0,0],
pink:[255,192,203],
cyan:[0,255,255],
transparent:[255,255,255,0]},
_parseColor = function(color) {
if (color === "" || color == null || color === "none") {
return _colorLookup.transparent;
} else if (_colorLookup[color]) {
return _colorLookup[color];
} else if (typeof(color) === "number") {
return [color >> 16, (color >> 8) & 255, color & 255];
} else if (color.charAt(0) === "#") {
if (color.length === 4) { //for shorthand like #9F0
color = "#" + color.charAt(1) + color.charAt(1) + color.charAt(2) + color.charAt(2) + color.charAt(3) + color.charAt(3);
}
color = parseInt(color.substr(1), 16);
return [color >> 16, (color >> 8) & 255, color & 255];
}
return color.match(_numExp) || _colorLookup.transparent;
},
_parseColorFilter = function(t, v, pg) {
if (!_ColorFilter) {
_ColorFilter = (_gsScope.ColorFilter || _gsScope.createjs.ColorFilter);
if (!_ColorFilter) {
throw("EaselPlugin error: The EaselJS ColorFilter JavaScript file wasn't loaded.");
}
}
var filters = t.filters || [],
i = filters.length,
c, s, e, a, p;
while (--i > -1) {
if (filters[i] instanceof _ColorFilter) {
s = filters[i];
break;
}
}
if (!s) {
s = new _ColorFilter();
filters.push(s);
t.filters = filters;
}
e = s.clone();
if (v.tint != null) {
c = _parseColor(v.tint);
a = (v.tintAmount != null) ? Number(v.tintAmount) : 1;
e.redOffset = Number(c[0]) * a;
e.greenOffset = Number(c[1]) * a;
e.blueOffset = Number(c[2]) * a;
e.redMultiplier = e.greenMultiplier = e.blueMultiplier = 1 - a;
} else {
for (p in v) {
if (p !== "exposure") if (p !== "brightness") {
e[p] = Number(v[p]);
}
}
}
if (v.exposure != null) {
e.redOffset = e.greenOffset = e.blueOffset = 255 * (Number(v.exposure) - 1);
e.redMultiplier = e.greenMultiplier = e.blueMultiplier = 1;
} else if (v.brightness != null) {
a = Number(v.brightness) - 1;
e.redOffset = e.greenOffset = e.blueOffset = (a > 0) ? a * 255 : 0;
e.redMultiplier = e.greenMultiplier = e.blueMultiplier = 1 - Math.abs(a);
}
i = 8;
while (--i > -1) {
p = _colorProps[i];
if (s[p] !== e[p]) {
pg._addTween(s, p, s[p], e[p], "easel_colorFilter");
}
}
pg._overwriteProps.push("easel_colorFilter");
if (!t.cacheID) {
throw("EaselPlugin warning: for filters to display in EaselJS, you must call the object's cache() method first. " + t);
}
},
_idMatrix = [1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],
_lumR = 0.212671,
_lumG = 0.715160,
_lumB = 0.072169,
_applyMatrix = function(m, m2) {
if (!(m instanceof Array) || !(m2 instanceof Array)) {
return m2;
}
var temp = [],
i = 0,
z = 0,
y, x;
for (y = 0; y < 4; y++) {
for (x = 0; x < 5; x++) {
z = (x === 4) ? m[i + 4] : 0;
temp[i + x] = m[i] * m2[x] + m[i+1] * m2[x + 5] + m[i+2] * m2[x + 10] + m[i+3] * m2[x + 15] + z;
}
i += 5;
}
return temp;
},
_setSaturation = function(m, n) {
if (isNaN(n)) {
return m;
}
var inv = 1 - n,
r = inv * _lumR,
g = inv * _lumG,
b = inv * _lumB;
return _applyMatrix([r + n, g, b, 0, 0, r, g + n, b, 0, 0, r, g, b + n, 0, 0, 0, 0, 0, 1, 0], m);
},
_colorize = function(m, color, amount) {
if (isNaN(amount)) {
amount = 1;
}
var c = _parseColor(color),
r = c[0] / 255,
g = c[1] / 255,
b = c[2] / 255,
inv = 1 - amount;
return _applyMatrix([inv + amount * r * _lumR, amount * r * _lumG, amount * r * _lumB, 0, 0, amount * g * _lumR, inv + amount * g * _lumG, amount * g * _lumB, 0, 0, amount * b * _lumR, amount * b * _lumG, inv + amount * b * _lumB, 0, 0, 0, 0, 0, 1, 0], m);
},
_setHue = function(m, n) {
if (isNaN(n)) {
return m;
}
n *= Math.PI / 180;
var c = Math.cos(n),
s = Math.sin(n);
return _applyMatrix([(_lumR + (c * (1 - _lumR))) + (s * (-_lumR)), (_lumG + (c * (-_lumG))) + (s * (-_lumG)), (_lumB + (c * (-_lumB))) + (s * (1 - _lumB)), 0, 0, (_lumR + (c * (-_lumR))) + (s * 0.143), (_lumG + (c * (1 - _lumG))) + (s * 0.14), (_lumB + (c * (-_lumB))) + (s * -0.283), 0, 0, (_lumR + (c * (-_lumR))) + (s * (-(1 - _lumR))), (_lumG + (c * (-_lumG))) + (s * _lumG), (_lumB + (c * (1 - _lumB))) + (s * _lumB), 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1], m);
},
_setContrast = function(m, n) {
if (isNaN(n)) {
return m;
}
n += 0.01;
return _applyMatrix([n,0,0,0,128 * (1 - n), 0,n,0,0,128 * (1 - n), 0,0,n,0,128 * (1 - n), 0,0,0,1,0], m);
},
_parseColorMatrixFilter = function(t, v, pg) {
if (!_ColorMatrixFilter) {
_ColorMatrixFilter = (_gsScope.ColorMatrixFilter || _gsScope.createjs.ColorMatrixFilter);
if (!_ColorMatrixFilter) {
throw("EaselPlugin error: The EaselJS ColorMatrixFilter JavaScript file wasn't loaded.");
}
}
var filters = t.filters || [],
i = filters.length,
matrix, startMatrix, s;
while (--i > -1) {
if (filters[i] instanceof _ColorMatrixFilter) {
s = filters[i];
break;
}
}
if (!s) {
s = new _ColorMatrixFilter(_idMatrix.slice());
filters.push(s);
t.filters = filters;
}
startMatrix = s.matrix;
matrix = _idMatrix.slice();
if (v.colorize != null) {
matrix = _colorize(matrix, v.colorize, Number(v.colorizeAmount));
}
if (v.contrast != null) {
matrix = _setContrast(matrix, Number(v.contrast));
}
if (v.hue != null) {
matrix = _setHue(matrix, Number(v.hue));
}
if (v.saturation != null) {
matrix = _setSaturation(matrix, Number(v.saturation));
}
i = matrix.length;
while (--i > -1) {
if (matrix[i] !== startMatrix[i]) {
pg._addTween(startMatrix, i, startMatrix[i], matrix[i], "easel_colorMatrixFilter");
}
}
pg._overwriteProps.push("easel_colorMatrixFilter");
if (!t.cacheID) {
throw("EaselPlugin warning: for filters to display in EaselJS, you must call the object's cache() method first. " + t);
}
pg._matrix = startMatrix;
};
var EaselPlugin = _gsScope._gsDefine.plugin({
propName: "easel",
priority: -1,
version: "0.2.2",
API: 2,
//called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
init: function(target, value, tween, index) {
this._target = target;
var p, pt, tint, colorMatrix, end, labels, i;
for (p in value) {
end = value[p];
if (typeof(end) === "function") {
end = end(index, target);
}
if (p === "colorFilter" || p === "tint" || p === "tintAmount" || p === "exposure" || p === "brightness") {
if (!tint) {
_parseColorFilter(target, value.colorFilter || value, this);
tint = true;
}
} else if (p === "saturation" || p === "contrast" || p === "hue" || p === "colorize" || p === "colorizeAmount") {
if (!colorMatrix) {
_parseColorMatrixFilter(target, value.colorMatrixFilter || value, this);
colorMatrix = true;
}
} else if (p === "frame") {
this._firstPT = pt = {_next:this._firstPT, t:target, p:"gotoAndStop", s:target.currentFrame, f:true, n:"frame", pr:0, type:0, m:Math.round};
if (typeof(end) === "string" && end.charAt(1) !== "=" && (labels = target.labels)) {
for (i = 0; i < labels.length; i++) {
if (labels[i].label === end) {
end = labels[i].position;
}
}
}
pt.c = (typeof(end) === "number") ? end - pt.s : parseFloat((end+"").split("=").join(""));
if (pt._next) {
pt._next._prev = pt;
}
} else if (target[p] != null) {
this._firstPT = pt = {_next:this._firstPT, t:target, p:p, f:(typeof(target[p]) === "function"), n:p, pr:0, type:0};
pt.s = (!pt.f) ? parseFloat(target[p]) : target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]();
pt.c = (typeof(end) === "number") ? end - pt.s : (typeof(end) === "string") ? parseFloat(end.split("=").join("")) : 0;
if (pt._next) {
pt._next._prev = pt;
}
}
}
return true;
},
//called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.)
set: function(v) {
var pt = this._firstPT,
min = 0.000001,
val;
while (pt) {
val = pt.c * v + pt.s;
if (pt.m) {
val = pt.m(val, pt.t);
} else if (val < min && val > -min) {
val = 0;
}
if (pt.f) {
pt.t[pt.p](val);
} else {
pt.t[pt.p] = val;
}
pt = pt._next;
}
if (this._target.cacheID) {
this._target.updateCache();
}
}
});
export { EaselPlugin, EaselPlugin as default };

View File

@ -0,0 +1,70 @@
/*!
* VERSION: 0.1.3
* DATE: 2018-08-27
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
import { _gsScope } from "./TweenLite.js";
export var EndArrayPlugin = _gsScope._gsDefine.plugin({
propName: "endArray",
API: 2,
version: "0.1.3",
//called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
init: function(target, value, tween) {
var i = value.length,
a = this.a = [],
start, end;
this.target = target;
this._mod = 0;
if (!i) {
return false;
}
while (--i > -1) {
start = target[i];
end = value[i];
if (start !== end) {
a.push({i:i, s:start, c:end - start});
}
}
return true;
},
mod: function(lookup) {
if (typeof(lookup.endArray) === "function") {
this._mod = lookup.endArray;
}
},
//called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.)
set: function(ratio) {
var target = this.target,
a = this.a,
i = a.length,
mod = this._mod,
e, val;
if (mod) {
while (--i > -1) {
e = a[i];
target[e.i] = mod(e.s + e.c * ratio, target);
}
} else {
while (--i > -1) {
e = a[i];
val = e.s + e.c * ratio;
target[e.i] = (val < 0.000001 && val > -0.000001) ? 0 : val;
}
}
}
});
export { EndArrayPlugin as default };

View File

@ -0,0 +1,170 @@
/*!
* VERSION: 0.0.4
* DATE: 2018-05-30
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
import { _gsScope } from "./TweenLite.js";
var _cssRatioSetter = function(pt, cssp, mod) { //Takes an individual CSSPropTween and converts it into a type:2 that has a setRatio that does everything the regular CSSPlugin.setRatio() method does but applying the mod() too. We do this to keep the main CSSPlugin.setRatio() as fast as possible (the vast majority of times, no mod() will be necessary)
var type = pt.type,
oldSetRatio = pt.setRatio,
tween = cssp._tween,
target = cssp._target;
pt.type = 2;
pt.m = mod;
pt.setRatio = function(v) {
var min = 0.000001,
val, str, i;
if (v === 1 && (tween._time === tween._duration || tween._time === 0)) {
if (type !== 2) {
if (pt.r && type !== -1) {
val = Math.round(pt.s + pt.c);
if (!type) {
pt.t[pt.p] = mod.call(tween, val + pt.xs0, target, tween);
} else if (type === 1) {
str = pt.xs0 + val + pt.xs1;
for (i = 1; i < pt.l; i++) {
str += pt["xn"+i] + pt["xs"+(i+1)];
}
pt.t[pt.p] = mod.call(tween, str, target, tween);
}
} else {
pt.t[pt.p] = mod.call(tween, pt.e, target, tween);
}
} else {
oldSetRatio.call(pt, v);
}
} else if (v || !(tween._time === tween._duration || tween._time === 0) || tween._rawPrevTime === -0.000001) {
val = pt.c * v + pt.s;
if (pt.r) {
val = Math.round(val);
} else if (val < min) if (val > -min) {
val = 0;
}
if (!type) {
pt.t[pt.p] = mod.call(tween, val + pt.xs0, target, tween);
} else if (type === 1) {
str = pt.xs0 + val + pt.xs1;
for (i = 1; i < pt.l; i++) {
str += pt["xn"+i] + pt["xs"+(i+1)];
}
pt.t[pt.p] = mod.call(tween, str, target, tween);
} else if (type === -1) { //non-tweening value
pt.t[pt.p] = mod.call(tween, pt.xs0, target, tween);
} else if (oldSetRatio) {
oldSetRatio.call(pt, v);
}
} else {
if (type !== 2) {
pt.t[pt.p] = mod.call(tween, pt.b, target, tween);
} else {
oldSetRatio.call(pt, v);
}
}
};
},
_modCSS = function(lookup, cssp) {
var pt = cssp._firstPT,
hasBezier = (lookup.rotation && cssp._overwriteProps.join("").indexOf("bezier") !== -1); //when a Bezier tween is applying autoRotation, it's a very special case we need to handle differently.
if (lookup.scale) {
lookup.scaleX = lookup.scaleY = lookup.scale;
} else if (lookup.rotationZ) {
lookup.rotation = lookup.rotationZ;
}
while (pt) {
if (typeof(lookup[pt.p]) === "function") {
_cssRatioSetter(pt, cssp, lookup[pt.p]);
} else if (hasBezier && pt.n === "bezier" && pt.plugin._overwriteProps.join("").indexOf("rotation") !== -1) {
pt.data.mod = lookup.rotation;
}
pt = pt._next;
}
},
ModifiersPlugin = _gsScope._gsDefine.plugin({
propName: "modifiers",
version: "0.0.4",
API: 2,
//called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
init: function(target, value, tween) {
this._tween = tween;
this._vars = value;
return true;
},
initAll: function() {
var tween = this._tween,
lookup = this._vars,
mpt = this,
pt = tween._firstPT,
val, next;
//initAll() gets called for each and every ModifiersPlugin instance in a tween, so if there are multiple targets, there will be multiple instances. Since we're ripping through the whole tween (and all the PropTweens), we only need to run this code ONCE. So we're setting a toggle on the first PropTween that just tells us if we've done it already. We don't set it on the tween instance because if it gets invalidated, we don't want to have to track this property and reset it. PropTweens get blown away when a tween is invalidated.
if (pt._modInitted) {
return false;
} else {
pt._modInitted = 1;
}
while (pt) {
next = pt._next; //record here, because it may get removed
val = lookup[pt.n];
if (pt.pg) {
if (pt.t._propName === "css") { //handle CSSPlugin uniquely (for performance, due to the fact that the values almost always are a concatenation of numbers and strings, like suffixes, and we don't want to slow down the regular CSSPlugin setRatio() performance with conditional checks for if the value needs to be modded, so we pull any modding prop out and change it to a type:2 one that simply calls a setRatio() method where we encapsulate the modding and update all together. That way, it says in the main CSSProp linked list and just has some custom logic applied to it inside its setRatio())
_modCSS(lookup, pt.t);
} else if (pt.t !== mpt) { //don't run modProps on modProps :)
val = lookup[pt.t._propName];
pt.t._tween = tween;
pt.t._mod((typeof(val) === "object") ? val : lookup);
}
} else if (typeof(val) === "function") {
if (pt.f === 2 && pt.t) { //a blob (text containing multiple numeric values)
pt.t._applyPT.m = val;
pt.t._tween = tween;
} else {
this._add(pt.t, pt.p, pt.s, pt.c, val);
//remove from linked list
if (next) {
next._prev = pt._prev;
}
if (pt._prev) {
pt._prev._next = next;
} else if (tween._firstPT === pt) {
tween._firstPT = next;
}
pt._next = pt._prev = null;
tween._propLookup[pt.n] = mpt;
}
}
pt = next;
}
return false;
}
}),
p = ModifiersPlugin.prototype;
p._add = function(target, p, s, c, mod) {
this._addTween(target, p, s, s + c, p, mod);
this._overwriteProps.push(p);
};
p = _gsScope._gsDefine.globals.TweenLite.version.split(".");
if (Number(p[0]) <= 1 && Number(p[1]) < 19 && _gsScope.console) {
console.log("ModifiersPlugin requires GSAP 1.19.0 or later.");
}
export { ModifiersPlugin, ModifiersPlugin as default };

464
lib/3rdparty/gsap/src/esm/PixiPlugin.js vendored Normal file
View File

@ -0,0 +1,464 @@
/*!
* VERSION: 0.2.1
* DATE: 2018-05-30
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* PixiPlugin is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
import { _gsScope } from "./TweenLite.js";
var _numExp = /(\d|\.)+/g,
_relNumExp = /(?:\d|\-\d|\.\d|\-\.\d|\+=\d|\-=\d|\+=.\d|\-=\.\d)+/g,
_colorLookup = {aqua:[0,255,255],
lime:[0,255,0],
silver:[192,192,192],
black:[0,0,0],
maroon:[128,0,0],
teal:[0,128,128],
blue:[0,0,255],
navy:[0,0,128],
white:[255,255,255],
fuchsia:[255,0,255],
olive:[128,128,0],
yellow:[255,255,0],
orange:[255,165,0],
gray:[128,128,128],
purple:[128,0,128],
green:[0,128,0],
red:[255,0,0],
pink:[255,192,203],
cyan:[0,255,255],
transparent:[255,255,255,0]},
_hue = function(h, m1, m2) {
h = (h < 0) ? h + 1 : (h > 1) ? h - 1 : h;
return ((((h * 6 < 1) ? m1 + (m2 - m1) * h * 6 : (h < 0.5) ? m2 : (h * 3 < 2) ? m1 + (m2 - m1) * (2 / 3 - h) * 6 : m1) * 255) + 0.5) | 0;
},
/**
* @private Parses a color (like #9F0, #FF9900, rgb(255,51,153) or hsl(108, 50%, 10%)) into an array with 3 elements for red, green, and blue or if "format" parameter is "hsl", it will populate the array with hue, saturation, and lightness values. Or if "format" is "number", it'll return a number like 0xFF0000 instead of an array. If a relative value is found in an hsl() or hsla() string, it will preserve those relative prefixes and all the values in the array will be strings instead of numbers (in all other cases it will be populated with numbers).
* @param {(string|number)} v The value the should be parsed which could be a string like #9F0 or rgb(255,102,51) or rgba(255,0,0,0.5) or it could be a number like 0xFF00CC or even a named color like red, blue, purple, etc.
* @param {(string)} format If "hsl", an hsl() or hsla() value will be returned instead of rgb() or rgba(). Or if "number", then a numeric value will be returned, like 0xFF0000. Default is rgb.
* @return {(array|number)} An array containing red, green, and blue (and optionally alpha) in that order, or if the format parameter was "hsl", the array will contain hue, saturation and lightness (and optionally alpha) in that order. Or if "format" is defined as "number", it'll return a number like 0xFF0000. Always numbers unless there's a relative prefix found in an hsl() or hsla() string and "format" is "hsl".
*/
_parseColor = function(v, format) {
var toHSL = (format === "hsl"),
a, r, g, b, h, s, l, max, min, d, wasHSL;
if (!v) {
a = _colorLookup.black;
} else if (typeof(v) === "number") {
a = [v >> 16, (v >> 8) & 255, v & 255];
} else {
if (v.charAt(v.length - 1) === ",") { //sometimes a trailing comma is included and we should chop it off (typically from a comma-delimited list of values like a textShadow:"2px 2px 2px blue, 5px 5px 5px rgb(255,0,0)" - in this example "blue," has a trailing comma. We could strip it out inside parseComplex() but we'd need to do it to the beginning and ending values plus it wouldn't provide protection from other potential scenarios like if the user passes in a similar value.
v = v.substr(0, v.length - 1);
}
if (_colorLookup[v]) {
a = _colorLookup[v];
} else if (v.charAt(0) === "#") {
if (v.length === 4) { //for shorthand like #9F0
r = v.charAt(1);
g = v.charAt(2);
b = v.charAt(3);
v = "#" + r + r + g + g + b + b;
}
v = parseInt(v.substr(1), 16);
a = [v >> 16, (v >> 8) & 255, v & 255];
} else if (v.substr(0, 3) === "hsl") {
a = wasHSL = v.match(_numExp);
if (!toHSL) {
h = (Number(a[0]) % 360) / 360;
s = Number(a[1]) / 100;
l = Number(a[2]) / 100;
g = (l <= 0.5) ? l * (s + 1) : l + s - l * s;
r = l * 2 - g;
if (a.length > 3) {
a[3] = Number(v[3]);
}
a[0] = _hue(h + 1 / 3, r, g);
a[1] = _hue(h, r, g);
a[2] = _hue(h - 1 / 3, r, g);
} else if (v.indexOf("=") !== -1) { //if relative values are found, just return the raw strings with the relative prefixes in place.
return v.match(_relNumExp);
}
} else {
a = v.match(_numExp) || _colorLookup.transparent;
}
a[0] = Number(a[0]);
a[1] = Number(a[1]);
a[2] = Number(a[2]);
if (a.length > 3) {
a[3] = Number(a[3]);
}
}
if (toHSL && !wasHSL) {
r = a[0] / 255;
g = a[1] / 255;
b = a[2] / 255;
max = Math.max(r, g, b);
min = Math.min(r, g, b);
l = (max + min) / 2;
if (max === min) {
h = s = 0;
} else {
d = max - min;
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
h = (max === r) ? (g - b) / d + (g < b ? 6 : 0) : (max === g) ? (b - r) / d + 2 : (r - g) / d + 4;
h *= 60;
}
a[0] = (h + 0.5) | 0;
a[1] = (s * 100 + 0.5) | 0;
a[2] = (l * 100 + 0.5) | 0;
}
return (format === "number") ? (a[0] << 16 | a[1] << 8 | a[2]) : a;
},
_formatColors = function(s, toHSL) {
var colors = (s + "").match(_colorExp) || [],
charIndex = 0,
parsed = "",
i, color, temp;
if (!colors.length) {
return s;
}
for (i = 0; i < colors.length; i++) {
color = colors[i];
temp = s.substr(charIndex, s.indexOf(color, charIndex)-charIndex);
charIndex += temp.length + color.length;
color = _parseColor(color, (toHSL ? "hsl" : "rgb"));
if (color.length === 3) {
color.push(1);
}
parsed += temp + (toHSL ? "hsla(" + color[0] + "," + color[1] + "%," + color[2] + "%," + color[3] : "rgba(" + color.join(",")) + ")";
}
return parsed + s.substr(charIndex);
}, _colorStringFilter,
TweenLite = (_gsScope.GreenSockGlobals || _gsScope).TweenLite,
_colorExp = "(?:\\b(?:(?:rgb|rgba|hsl|hsla)\\(.+?\\))|\\B#(?:[0-9a-f]{3}){1,2}\\b", //we'll dynamically build this Regular Expression to conserve file size. After building it, it will be able to find rgb(), rgba(), # (hexadecimal), and named color values like red, blue, purple, etc.
_idMatrix = [1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],
_lumR = 0.212671,
_lumG = 0.715160,
_lumB = 0.072169,
_applyMatrix = function(m, m2) {
var temp = [],
i = 0,
z = 0,
y, x;
for (y = 0; y < 4; y++) {
for (x = 0; x < 5; x++) {
z = (x === 4) ? m[i + 4] : 0;
temp[i + x] = m[i] * m2[x] + m[i+1] * m2[x + 5] + m[i+2] * m2[x + 10] + m[i+3] * m2[x + 15] + z;
}
i += 5;
}
return temp;
},
_setSaturation = function(m, n) {
var inv = 1 - n,
r = inv * _lumR,
g = inv * _lumG,
b = inv * _lumB;
return _applyMatrix([r + n, g, b, 0, 0, r, g + n, b, 0, 0, r, g, b + n, 0, 0, 0, 0, 0, 1, 0], m);
},
_colorize = function(m, color, amount) {
var c = _parseColor(color),
r = c[0] / 255,
g = c[1] / 255,
b = c[2] / 255,
inv = 1 - amount;
return _applyMatrix([inv + amount * r * _lumR, amount * r * _lumG, amount * r * _lumB, 0, 0, amount * g * _lumR, inv + amount * g * _lumG, amount * g * _lumB, 0, 0, amount * b * _lumR, amount * b * _lumG, inv + amount * b * _lumB, 0, 0, 0, 0, 0, 1, 0], m);
},
_setHue = function(m, n) {
n *= Math.PI / 180;
var c = Math.cos(n),
s = Math.sin(n);
return _applyMatrix([(_lumR + (c * (1 - _lumR))) + (s * (-_lumR)), (_lumG + (c * (-_lumG))) + (s * (-_lumG)), (_lumB + (c * (-_lumB))) + (s * (1 - _lumB)), 0, 0, (_lumR + (c * (-_lumR))) + (s * 0.143), (_lumG + (c * (1 - _lumG))) + (s * 0.14), (_lumB + (c * (-_lumB))) + (s * -0.283), 0, 0, (_lumR + (c * (-_lumR))) + (s * (-(1 - _lumR))), (_lumG + (c * (-_lumG))) + (s * _lumG), (_lumB + (c * (1 - _lumB))) + (s * _lumB), 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1], m);
},
_setContrast = function(m, n) {
return _applyMatrix([n,0,0,0,0.5 * (1 - n), 0,n,0,0,0.5 * (1 - n), 0,0,n,0,0.5 * (1 - n), 0,0,0,1,0], m);
},
_getFilter = function(t, type) {
var filterClass = _gsScope.PIXI.filters[type],
filters = t.filters || [],
i = filters.length,
filter;
if (!filterClass) {
throw("PixiPlugin error: " + type + " isn't present.");
}
while (--i > -1) {
if (filters[i] instanceof filterClass) {
return filters[i];
}
}
filter = new filterClass();
if (type === "BlurFilter") {
filter.blur = 0;
}
filters.push(filter);
t.filters = filters;
return filter;
},
_addColorMatrixFilterCacheTween = function(p, pg, cache, vars) { //we cache the ColorMatrixFilter components in a _gsColorMatrixFilter object attached to the target object so that it's easy to grab the current value at any time.
pg._addTween(cache, p, cache[p], vars[p], p);
pg._overwriteProps.push(p);
},
_applyBrightnessToMatrix = function(brightness, matrix) {
var temp = new _gsScope.PIXI.filters.ColorMatrixFilter();
temp.matrix = matrix;
temp.brightness(brightness, true);
return temp.matrix;
},
_CMFdefaults = {contrast:1, saturation:1, colorizeAmount:0, colorize:"rgb(255,255,255)", hue:0, brightness:1},
_parseColorMatrixFilter = function(t, v, pg) {
var filter = _getFilter(t, "ColorMatrixFilter"),
cache = t._gsColorMatrixFilter = t._gsColorMatrixFilter || {contrast:1, saturation:1, colorizeAmount:0, colorize:"rgb(255,255,255)", hue:0, brightness:1},
combine = v.combineCMF && !("colorMatrixFilter" in v && !v.colorMatrixFilter),
i, matrix, startMatrix;
startMatrix = filter.matrix;
if (v.resolution) {
filter.resolution = v.resolution;
}
if (v.matrix && v.matrix.length === startMatrix.length) {
matrix = v.matrix;
if (cache.contrast !== 1) {
_addColorMatrixFilterCacheTween("contrast", pg, cache, _CMFdefaults);
}
if (cache.hue) {
_addColorMatrixFilterCacheTween("hue", pg, cache, _CMFdefaults);
}
if (cache.brightness !== 1) {
_addColorMatrixFilterCacheTween("brightness", pg, cache, _CMFdefaults);
}
if (cache.colorizeAmount) {
_addColorMatrixFilterCacheTween("colorize", pg, cache, _CMFdefaults);
_addColorMatrixFilterCacheTween("colorizeAmount", pg, cache, _CMFdefaults);
}
if (cache.saturation !== 1) {
_addColorMatrixFilterCacheTween("saturation", pg, cache, _CMFdefaults);
}
} else {
matrix = _idMatrix.slice();
if (v.contrast != null) {
matrix = _setContrast(matrix, Number(v.contrast));
_addColorMatrixFilterCacheTween("contrast", pg, cache, v);
} else if (cache.contrast !== 1) {
if (combine) {
matrix = _setContrast(matrix, cache.contrast);
} else {
_addColorMatrixFilterCacheTween("contrast", pg, cache, _CMFdefaults);
}
}
if (v.hue != null) {
matrix = _setHue(matrix, Number(v.hue));
_addColorMatrixFilterCacheTween("hue", pg, cache, v);
} else if (cache.hue) {
if (combine) {
matrix = _setHue(matrix, cache.hue);
} else {
_addColorMatrixFilterCacheTween("hue", pg, cache, _CMFdefaults);
}
}
if (v.brightness != null) {
matrix = _applyBrightnessToMatrix(Number(v.brightness), matrix);
_addColorMatrixFilterCacheTween("brightness", pg, cache, v);
} else if (cache.brightness !== 1) {
if (combine) {
matrix = _applyBrightnessToMatrix(cache.brightness, matrix);
} else {
_addColorMatrixFilterCacheTween("brightness", pg, cache, _CMFdefaults);
}
}
if (v.colorize != null) {
v.colorizeAmount = ("colorizeAmount" in v) ? Number(v.colorizeAmount) : 1;
matrix = _colorize(matrix, v.colorize, v.colorizeAmount);
_addColorMatrixFilterCacheTween("colorize", pg, cache, v);
_addColorMatrixFilterCacheTween("colorizeAmount", pg, cache, v);
} else if (cache.colorizeAmount) {
if (combine) {
matrix = _colorize(matrix, cache.colorize, cache.colorizeAmount);
} else {
_addColorMatrixFilterCacheTween("colorize", pg, cache, _CMFdefaults);
_addColorMatrixFilterCacheTween("colorizeAmount", pg, cache, _CMFdefaults);
}
}
if (v.saturation != null) {
matrix = _setSaturation(matrix, Number(v.saturation));
_addColorMatrixFilterCacheTween("saturation", pg, cache, v);
} else if (cache.saturation !== 1) {
if (combine) {
matrix = _setSaturation(matrix, cache.saturation);
} else {
_addColorMatrixFilterCacheTween("saturation", pg, cache, _CMFdefaults);
}
}
}
i = matrix.length;
while (--i > -1) {
if (matrix[i] !== startMatrix[i]) {
pg._addTween(startMatrix, i, startMatrix[i], matrix[i], "colorMatrixFilter");
}
}
pg._overwriteProps.push("colorMatrixFilter");
},
_addColorTween = function(target, p, value, colorSetter, plugin) {
var pt = colorSetter._firstPT = {_next:colorSetter._firstPT, t:target, p:p, proxy:{}, f:(typeof(target[p]) === "function")};
pt.proxy[p] = "rgb(" + _parseColor(!pt.f ? target[p] : target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]()).join(",") + ")";
plugin._addTween(pt.proxy, p, "get", ((typeof(value) === "number") ? "rgb(" + _parseColor(value, false).join(",") + ")" : value), p, null, null, _colorStringFilter);
},
//to improve performance, when a color is sensed, we hijack the setRatio() method of the plugin instance with a new function that this method spits back. This is a special method that handles parsing color values on-the-fly and turns them into numeric values which PixiJS requires. In other words, instead of "rgb(255, 0, 0)", PixiJS wants 0xFF0000. This also works with hsl() values.
_buildColorSetter = function(tween, plugin) {
var setRatio = plugin.setRatio, //save the original (super) setRatio() function
func = function(v) {
var pt = func._firstPT,
val;
setRatio.call(plugin, v);
while (pt) {
val = _parseColor(pt.proxy[pt.p], "number");
if (pt.f) {
pt.t[pt.p](val);
} else {
pt.t[pt.p] = val;
}
pt = pt._next;
}
if (func.graphics) { //in order for PixiJS to actually redraw GraphicsData, we've gotta increment the "dirty" and "clearDirty" values. If we don't do this, the values will be tween properly, but not rendered.
func.graphics.dirty++;
func.graphics.clearDirty++;
}
};
plugin.setRatio = func;
return func;
},
_colorProps = {tint:1, lineColor:1, fillColor:1},
_xyContexts = "position,scale,skew,pivot,anchor,tilePosition,tileScale".split(","),
_contexts = {x:"position", y:"position", tileX:"tilePosition", tileY:"tilePosition"},
_colorMatrixFilterProps = {colorMatrixFilter:1, saturation:1, contrast:1, hue:1, colorize:1, colorizeAmount:1, brightness:1, combineCMF:1},
_DEG2RAD = Math.PI / 180,
_degreesToRadians = function(value) {
return (typeof(value) === "string" && value.charAt(1) === "=") ? value.substr(0, 2) + (parseFloat(value.substr(2)) * _DEG2RAD) : value * _DEG2RAD;
}, i, p;
//context setup...
for (i = 0; i < _xyContexts.length; i++) {
p = _xyContexts[i];
_contexts[p + "X"] = p;
_contexts[p + "Y"] = p;
}
//color parsing setup...
for (p in _colorLookup) {
_colorExp += "|" + p + "\\b";
}
_colorExp = new RegExp(_colorExp+")", "gi");
_colorStringFilter = function(a) {
var combined = a[0] + " " + a[1],
toHSL;
_colorExp.lastIndex = 0;
if (_colorExp.test(combined)) {
toHSL = (combined.indexOf("hsl(") !== -1 || combined.indexOf("hsla(") !== -1);
a[0] = _formatColors(a[0], toHSL);
a[1] = _formatColors(a[1], toHSL);
}
};
if (!TweenLite.defaultStringFilter) {
TweenLite.defaultStringFilter = _colorStringFilter;
}
var PixiPlugin = _gsScope._gsDefine.plugin({
propName: "pixi",
priority: 0,
API: 2,
global: true,
version: "0.2.1",
init: function (target, values, tween, index) {
if (!target instanceof _gsScope.PIXI.DisplayObject) {
return false;
}
var context, axis, value, colorMatrix, filter, p, padding, colorSetter, i, data, pt;
for (p in values) {
context = _contexts[p];
value = values[p];
if (typeof(value) === "function") {
value = value(index || 0, target);
}
if (context) {
axis = (p.charAt(p.length-1).toLowerCase().indexOf("x") !== -1) ? "x" : "y";
this._addTween(target[context], axis, target[context][axis], (context === "skew") ? _degreesToRadians(value) : value, p);
} else if (p === "scale" || p === "anchor" || p === "pivot" || p === "tileScale") {
this._addTween(target[p], "x", target[p].x, value, p + "X");
this._addTween(target[p], "y", target[p].y, value, p + "Y");
} else if (p === "rotation") { //PIXI expects rotation in radians, but as a convenience we let folks define it in degrees and we do the conversion.
this._addTween(target, p, target.rotation, _degreesToRadians(value), p);
} else if (_colorMatrixFilterProps[p]) {
if (!colorMatrix) {
_parseColorMatrixFilter(target, values.colorMatrixFilter || values, this);
colorMatrix = true;
}
} else if (p === "blur" || p === "blurX" || p === "blurY" || p === "blurPadding") {
filter = _getFilter(target, "BlurFilter");
this._addTween(filter, p, filter[p], value, p);
if (values.blurPadding !== 0) {
padding = values.blurPadding || Math.max(filter[p], value) * 2;
i = target.filters.length;
while (--i > -1) {
target.filters[i].padding = Math.max(target.filters[i].padding, padding); //if we don't expand the padding on all the filters, it can look clipped.
}
}
} else if (_colorProps[p]) {
if (!colorSetter) {
colorSetter = _buildColorSetter(tween, this);
}
if ((p === "lineColor" || p === "fillColor") && target instanceof _gsScope.PIXI.Graphics) {
data = target.graphicsData;
i = data.length;
while (--i > -1) {
_addColorTween(data[i], p, value, colorSetter, this);
}
colorSetter.graphics = target;
} else {
_addColorTween(target, p, value, colorSetter, this);
}
} else if (p === "autoAlpha") {
this._firstPT = pt = {t: {setRatio:function() { target.visible = !!target.alpha; }}, p: "setRatio", s: 0, c: 1, f: 1, pg: 0, n: "visible", pr: 0, m: 0, _next:this._firstPT};
if (pt._next) {
pt._next._prev = pt;
}
this._addTween(target, "alpha", target.alpha, value, "alpha");
this._overwriteProps.push("alpha", "visible");
} else {
this._addTween(target, p, target[p], value, p);
}
this._overwriteProps.push(p);
}
return true;
}
});
PixiPlugin.colorProps = _colorProps;
PixiPlugin.parseColor = _parseColor;
PixiPlugin.formatColors = _formatColors;
PixiPlugin.colorStringFilter = _colorStringFilter;
export { PixiPlugin, PixiPlugin as default };

View File

@ -0,0 +1,100 @@
/*!
* VERSION: 1.6.0
* DATE: 2018-08-27
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
/* eslint-disable */
import { _gsScope } from "./TweenLite.js";
export var RoundPropsPlugin = _gsScope._gsDefine.plugin({
propName: "roundProps",
version: "1.7.0",
priority: -1,
API: 2,
//called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
init: function(target, value, tween) {
this._tween = tween;
return true;
}
}),
_getRoundFunc = function(v) { //pass in 0.1 get a function that'll round to the nearest tenth, or 5 to round to the closest 5, or 0.001 to the closest 1000th, etc.
var p = v < 1 ? Math.pow(10, (v + "").length - 2) : 1; //to avoid floating point math errors (like 24 * 0.1 == 2.4000000000000004), we chop off at a specific number of decimal places (much faster than toFixed()
return function(n) {
return ((Math.round(n / v) * v * p) | 0) / p;
};
},
_roundLinkedList = function(node, mod) {
while (node) {
if (!node.f && !node.blob) {
node.m = mod || Math.round;
}
node = node._next;
}
},
p = RoundPropsPlugin.prototype;
p._onInitAllProps = function() {
var tween = this._tween,
rp = tween.vars.roundProps,
lookup = {},
rpt = tween._propLookup.roundProps,
pt, next, i, p;
if (typeof(rp) === "object" && !rp.push) {
for (p in rp) {
lookup[p] = _getRoundFunc(rp[p]);
}
} else {
if (typeof(rp) === "string") {
rp = rp.split(",");
}
i = rp.length;
while (--i > -1) {
lookup[rp[i]] = Math.round;
}
}
for (p in lookup) {
pt = tween._firstPT;
while (pt) {
next = pt._next; //record here, because it may get removed
if (pt.pg) {
pt.t._mod(lookup);
} else if (pt.n === p) {
if (pt.f === 2 && pt.t) { //a blob (text containing multiple numeric values)
_roundLinkedList(pt.t._firstPT, lookup[p]);
} else {
this._add(pt.t, p, pt.s, pt.c, lookup[p]);
//remove from linked list
if (next) {
next._prev = pt._prev;
}
if (pt._prev) {
pt._prev._next = next;
} else if (tween._firstPT === pt) {
tween._firstPT = next;
}
pt._next = pt._prev = null;
tween._propLookup[p] = rpt;
}
}
pt = next;
}
}
return false;
};
p._add = function(target, p, s, c, mod) {
this._addTween(target, p, s, s + c, p, mod || Math.round);
this._overwriteProps.push(p);
};
export { RoundPropsPlugin as default };

View File

@ -0,0 +1,182 @@
/*!
* VERSION: 1.9.2
* DATE: 2019-02-07
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
/* eslint-disable */
import { _gsScope } from "./TweenLite.js";
var _doc = (_gsScope.document || {}).documentElement,
_window = _gsScope,
_max = function(element, axis) {
var dim = (axis === "x") ? "Width" : "Height",
scroll = "scroll" + dim,
client = "client" + dim,
body = document.body;
return (element === _window || element === _doc || element === body) ? Math.max(_doc[scroll], body[scroll]) - (_window["inner" + dim] || _doc[client] || body[client]) : element[scroll] - element["offset" + dim];
},
_unwrapElement = function(value) {
if (typeof(value) === "string") {
value = TweenLite.selector(value);
}
if (value.length && value !== _window && value[0] && value[0].style && !value.nodeType) {
value = value[0];
}
return (value === _window || (value.nodeType && value.style)) ? value : null;
},
_buildGetter = function(e, axis) { //pass in an element and an axis ("x" or "y") and it'll return a getter function for the scroll position of that element (like scrollTop or scrollLeft, although if the element is the window, it'll use the pageXOffset/pageYOffset or the documentElement's scrollTop/scrollLeft or document.body's. Basically this streamlines things and makes a very fast getter across browsers.
var p = "scroll" + ((axis === "x") ? "Left" : "Top");
if (e === _window) {
if (e.pageXOffset != null) {
p = "page" + axis.toUpperCase() + "Offset";
} else if (_doc[p] != null) {
e = _doc;
} else {
e = document.body;
}
}
return function() {
return e[p];
};
},
_getOffset = function(element, container) {
var rect = _unwrapElement(element).getBoundingClientRect(),
b = document.body,
isRoot = (!container || container === _window || container === b),
cRect = isRoot ? {top:_doc.clientTop - (window.pageYOffset || _doc.scrollTop || b.scrollTop || 0), left:_doc.clientLeft - (window.pageXOffset || _doc.scrollLeft || b.scrollLeft || 0)} : container.getBoundingClientRect(),
offsets = {x: rect.left - cRect.left, y: rect.top - cRect.top};
if (!isRoot && container) { //only add the current scroll position if it's not the window/body.
offsets.x += _buildGetter(container, "x")();
offsets.y += _buildGetter(container, "y")();
}
return offsets;
/* PREVIOUS
var rect = _unwrapElement(element).getBoundingClientRect(),
isRoot = (!container || container === _window || container === document.body),
cRect = (isRoot ? _doc : container).getBoundingClientRect(),
offsets = {x: rect.left - cRect.left, y: rect.top - cRect.top};
if (!isRoot && container) { //only add the current scroll position if it's not the window/body.
offsets.x += _buildGetter(container, "x")();
offsets.y += _buildGetter(container, "y")();
}
return offsets;
*/
},
_parseVal = function(value, target, axis, currentVal) {
var type = typeof(value);
return !isNaN(value) ? parseFloat(value) : (type === "string" && value.charAt(1) === "=") ? parseInt(value.charAt(0) + "1", 10) * parseFloat(value.substr(2)) + currentVal : (value === "max") ? _max(target, axis) : Math.min(_max(target, axis), _getOffset(value, target)[axis]);
},
ScrollToPlugin = _gsScope._gsDefine.plugin({
propName: "scrollTo",
API: 2,
global: true,
version:"1.9.2",
//called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
init: function(target, value, tween) {
this._wdw = (target === _window);
this._target = target;
this._tween = tween;
if (typeof(value) !== "object") {
value = {y:value}; //if we don't receive an object as the parameter, assume the user intends "y".
if (typeof(value.y) === "string" && value.y !== "max" && value.y.charAt(1) !== "=") {
value.x = value.y;
}
} else if (value.nodeType) {
value = {y:value, x:value};
}
this.vars = value;
this._autoKill = (value.autoKill !== false);
this.getX = _buildGetter(target, "x");
this.getY = _buildGetter(target, "y");
this.x = this.xPrev = this.getX();
this.y = this.yPrev = this.getY();
if (value.x != null) {
this._addTween(this, "x", this.x, _parseVal(value.x, target, "x", this.x) - (value.offsetX || 0), "scrollTo_x", true);
this._overwriteProps.push("scrollTo_x");
} else {
this.skipX = true;
}
if (value.y != null) {
this._addTween(this, "y", this.y, _parseVal(value.y, target, "y", this.y) - (value.offsetY || 0), "scrollTo_y", true);
this._overwriteProps.push("scrollTo_y");
} else {
this.skipY = true;
}
return true;
},
//called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.)
set: function(v) {
this._super.setRatio.call(this, v);
var x = (this._wdw || !this.skipX) ? this.getX() : this.xPrev,
y = (this._wdw || !this.skipY) ? this.getY() : this.yPrev,
yDif = y - this.yPrev,
xDif = x - this.xPrev,
threshold = ScrollToPlugin.autoKillThreshold;
if (this.x < 0) { //can't scroll to a position less than 0! Might happen if someone uses a Back.easeOut or Elastic.easeOut when scrolling back to the top of the page (for example)
this.x = 0;
}
if (this.y < 0) {
this.y = 0;
}
if (this._autoKill) {
//note: iOS has a bug that throws off the scroll by several pixels, so we need to check if it's within 7 pixels of the previous one that we set instead of just looking for an exact match.
if (!this.skipX && (xDif > threshold || xDif < -threshold) && x < _max(this._target, "x")) {
this.skipX = true; //if the user scrolls separately, we should stop tweening!
}
if (!this.skipY && (yDif > threshold || yDif < -threshold) && y < _max(this._target, "y")) {
this.skipY = true; //if the user scrolls separately, we should stop tweening!
}
if (this.skipX && this.skipY) {
this._tween.kill();
if (this.vars.onAutoKill) {
this.vars.onAutoKill.apply(this.vars.onAutoKillScope || this._tween, this.vars.onAutoKillParams || []);
}
}
}
if (this._wdw) {
_window.scrollTo((!this.skipX) ? this.x : x, (!this.skipY) ? this.y : y);
} else {
if (!this.skipY) {
this._target.scrollTop = this.y;
}
if (!this.skipX) {
this._target.scrollLeft = this.x;
}
}
this.xPrev = this.x;
this.yPrev = this.y;
}
}),
p = ScrollToPlugin.prototype;
ScrollToPlugin.max = _max;
ScrollToPlugin.getOffset = _getOffset;
ScrollToPlugin.buildGetter = _buildGetter;
ScrollToPlugin.autoKillThreshold = 7;
p._kill = function(lookup) {
if (lookup.scrollTo_x) {
this.skipX = true;
}
if (lookup.scrollTo_y) {
this.skipY = true;
}
return this._super._kill.call(this, lookup);
};
export { ScrollToPlugin, ScrollToPlugin as default };

View File

@ -0,0 +1,75 @@
/*!
* VERSION: 1.2.0
* DATE: 2018-08-27
* UPDATES AND DOCS AT: http://greensock.com
*
* This file is to be used as a simple template for writing your own plugin. See the
* TweenPlugin docs for more details.
*
* You can start by doing a search for "yourCustomProperty" and replace it with whatever the name
* of your property is. This way of defining a plugin was introduced in version 1.9.0 - previous versions
* of TweenLite won't work with this.
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
/* eslint-disable */
import { _gsScope } from "./TweenLite.js";
export var YourPlugin = _gsScope._gsDefine.plugin({
propName: "yourCustomProperty", //the name of the property that will get intercepted and handled by this plugin (obviously change it to whatever you want, typically it is camelCase starting with lowercase).
priority: 0, //the priority in the rendering pipeline (0 by default). A priority of -1 would mean this plugin will run after all those with 0 or greater. A priority of 1 would get run before 0, etc. This only matters when a plugin relies on other plugins finishing their work before it runs (or visa-versa)
API: 2, //the API should stay 2 - it just gives us a way to know the method/property structure so that if in the future we change to a different TweenPlugin architecture, we can identify this plugin's structure.
version: "1.0.0", //your plugin's version number
overwriteProps: ["yourCustomProperty"], //an array of property names whose tweens should be overwritten by this plugin. For example, if you create a "scale" plugin that handles both "scaleX" and "scaleY", the overwriteProps would be ["scaleX","scaleY"] so that if there's a scaleX or scaleY tween in-progress when a new "scale" tween starts (using this plugin), it would overwrite the scaleX or scaleY tween.
/*
* The init function is called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run. It receives 3 parameters:
* 1) target [object] - the target of the tween. In cases where the tween's original target is an array (or jQuery object), this target will be the individual object inside that array (a new plugin instance is created for each target in the array). For example, TweenLite.to([obj1, obj2, obj3], 1, {x:100}) the target will be obj1 or obj2 or obj3 rather than the array containing them.
* 2) value [*] - whatever value is passed as the special property value. For example, TweenLite.to(element, 1, {yourCustomProperty:3}) the value would be 3. Or for TweenLite.to(element, 1, {yourCustomProperty:{subProp1:3, subProp2:"whatever"}});, value would be {subProp1:3, subProp2:"whatever"}.
* 3) tween [TweenLite] - the TweenLite (or TweenMax) instance that is managing this plugin instance. This can be useful if you need to check certain state-related properties on the tween (maybe in the set method) like its duration or time. Most of the time, however, you don't need to do anything with the tween. It is provided just in case you want to reference it.
* 4) index [integer] - the index number of the target in the tween. For example, if an array is passed in as the target (or selector text), this would be 0 for the first one, 1 for the second, 2 for the third, etc. This was introduced in GSAP 1.19.0
*
* This function should return true unless you want to have TweenLite/Max skip the plugin altogether and instead treat the property/value like a normal tween (as if the plugin wasn't activated). This is rarely useful, so you should almost always return true.
*/
init: function(target, value, tween, index) {
this._target = target; //we record the target so that we can refer to it in the set method when doing updates.
/* Next, we create a property tween for "scaleX" and "scaleY" properties of our target
* (we're just using them as a examples of how to set up a property tween with a name, start, and end value).
* the _addTween() method accepts the following parameters:
* 1) target [object] - target object whose property this tween will control.
* 2) property [string] - the name of the property, like "scaleX" or "scaleY"
* 3) start [number] - The starting value of the property. For example, if you're tweening from 0 to 100, start would be 0.
* 4) end [number] - the ending value of the property. For example, if you're tweening from 0 to 100, end would be 100.
* 5) overwriteProperty [string] - the name that gets registered as the overwrite property so that if another concurrent tween of the same target gets created and it is tweening a property with this name, this one will be overwritten. Typically this is the same as "property".
* 6) round [boolean] - if true, the updated value on each update will be rounded to the nearest integer. [false by default]
* You do NOT need to use _addTween() at all. It is merely a convenience. You can record your own values internally or whatever you want.
*/
this._addTween(target, "scaleX", target.scaleX, value, "scaleX", false);
this._addTween(target, "scaleY", target.scaleY, value, "scaleY", false);
//now, just for kicks, we'll record the starting "alpha" value and amount of change so that we can manage this manually rather than _addTween() (again, totally fictitious, just for an example)
this._alphaStart = target.alpha;
this._alphaChange = value.alpha - target.alpha;
//always return true unless we want to scrap the plugin and have the value treated as a normal property tween (very uncommon)
return true;
},
//[optional] - called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.). If you're using this._super._addTween() for all your tweens and you don't need to do anything special on each frame besides updating those values, you can omit this "set" function altogether.
set: function(ratio) {
//since we used _addTween() inside init function, it created some property tweens that we'll update by calling the parent prototype's setRatio() (otherwise, the property tweens wouldn't get their values updated). this._super refers to the TweenPlugin prototype from which the plugin inherits (not that you need to worry about that).
this._super.setRatio.call(this, ratio);
//now manually set the alpha
this._target.alpha = this._alphaStart + this._alphaChange * ratio;
}
});
// Now export it for ES6
export { YourPlugin as default };

157
lib/3rdparty/gsap/src/esm/TextPlugin.js vendored Normal file
View File

@ -0,0 +1,157 @@
/*!
* VERSION: 0.6.2
* DATE: 2018-05-30
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
import { _gsScope } from "./TweenLite.js";
var _getText = function(e) {
var type = e.nodeType,
result = "";
if (type === 1 || type === 9 || type === 11) {
if (typeof(e.textContent) === "string") {
return e.textContent;
} else {
for ( e = e.firstChild; e; e = e.nextSibling ) {
result += _getText(e);
}
}
} else if (type === 3 || type === 4) {
return e.nodeValue;
}
return result;
},
_emoji = "[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2694-\u2697]|\uD83E[\uDD10-\uDD5D]|[\uD800-\uDBFF][\uDC00-\uDFFF]",
_emojiExp = new RegExp(_emoji),
_emojiAndCharsExp = new RegExp(_emoji + "|.", "g"),
_emojiSafeSplit = function(text, delimiter) {
return ((delimiter === "" || !delimiter) && _emojiExp.test(text)) ? text.match(_emojiAndCharsExp) : text.split(delimiter || "");
},
/* //previous emoji-related splitting. New method above is faster and more concise.
_emojiStart = 0xD800,
_emojiEnd = 0xDBFF,
_emojiLowStart = 0xDC00,
_emojiRegionStart = 0x1F1E6,
_emojiRegionEnd = 0x1F1FF,
_emojiModStart = 0x1f3fb,
_emojiModEnd = 0x1f3ff,
_emojiPairCode = function(s) {
return ((s.charCodeAt(0) - _emojiStart) << 10) + (s.charCodeAt(1) - _emojiLowStart) + 0x10000;
},
_emojiSafeSplit = function(text, delimiter) { //like calling String.split(delimiter) except that it keeps emoji characters together.
if (delimiter !== "") {
return text.split(delimiter);
}
var l = text.length,
a = [],
character, i, emojiPair1, emojiPair2, j;
for (i = 0; i < l; i++) {
character = text.charAt(i);
if ((character.charCodeAt(0) >= _emojiStart && character.charCodeAt(0) <= _emojiEnd) || (text.charCodeAt(i+1) >= 0xFE00 && text.charCodeAt(i+1) <= 0xFE0F)) { //special emoji characters use 2 or 4 unicode characters that we must keep together.
emojiPair1 = _emojiPairCode(text.substr(i, 2));
emojiPair2 = _emojiPairCode(text.substr(i + 2, 2));
j = ((emojiPair1 >= _emojiRegionStart && emojiPair1 <= _emojiRegionEnd && emojiPair2 >= _emojiRegionStart && emojiPair2 <= _emojiRegionEnd) || (emojiPair2 >= _emojiModStart && emojiPair2 <= _emojiModEnd)) ? 4 : 2;
a.push(text.substr(i, j));
i += j - 1;
} else {
a.push(character);
}
}
return a;
},
*/
TextPlugin = _gsScope._gsDefine.plugin({
propName: "text",
API: 2,
version:"0.6.2",
//called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
init: function(target, value, tween, index) {
var i = target.nodeName.toUpperCase(),
shrt;
if (typeof(value) === "function") {
value = value(index, target);
}
this._svg = (target.getBBox && (i === "TEXT" || i === "TSPAN"));
if (!("innerHTML" in target) && !this._svg) {
return false;
}
this._target = target;
if (typeof(value) !== "object") {
value = {value:value};
}
if (value.value === undefined) {
this._text = this._original = [""];
return true;
}
this._delimiter = value.delimiter || "";
this._original = _emojiSafeSplit(_getText(target).replace(/\s+/g, " "), this._delimiter);
this._text = _emojiSafeSplit(value.value.replace(/\s+/g, " "), this._delimiter);
this._runBackwards = (tween.vars.runBackwards === true);
if (this._runBackwards) {
i = this._original;
this._original = this._text;
this._text = i;
}
if (typeof(value.newClass) === "string") {
this._newClass = value.newClass;
this._hasClass = true;
}
if (typeof(value.oldClass) === "string") {
this._oldClass = value.oldClass;
this._hasClass = true;
}
i = this._original.length - this._text.length;
shrt = (i < 0) ? this._original : this._text;
this._fillChar = value.fillChar || (value.padSpace ? "&nbsp;" : "");
if (i < 0) {
i = -i;
}
while (--i > -1) {
shrt.push(this._fillChar);
}
return true;
},
//called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.)
set: function(ratio) {
if (ratio > 1) {
ratio = 1;
} else if (ratio < 0) {
ratio = 0;
}
if (this._runBackwards) {
ratio = 1 - ratio;
}
var l = this._text.length,
i = (ratio * l + 0.5) | 0,
applyNew, applyOld, str;
if (this._hasClass) {
applyNew = (this._newClass && i !== 0);
applyOld = (this._oldClass && i !== l);
str = (applyNew ? "<span class='" + this._newClass + "'>" : "") + this._text.slice(0, i).join(this._delimiter) + (applyNew ? "</span>" : "") + (applyOld ? "<span class='" + this._oldClass + "'>" : "") + this._delimiter + this._original.slice(i).join(this._delimiter) + (applyOld ? "</span>" : "");
} else {
str = this._text.slice(0, i).join(this._delimiter) + this._delimiter + this._original.slice(i).join(this._delimiter);
}
if (this._svg) { //SVG text elements don't have an "innerHTML" in Microsoft browsers.
this._target.textContent = str;
} else {
this._target.innerHTML = (this._fillChar === "&nbsp;" && str.indexOf(" ") !== -1) ? str.split(" ").join("&nbsp;&nbsp;") : str;
}
}
}),
p = TextPlugin.prototype;
p._newClass = p._oldClass = p._delimiter = "";
export { TextPlugin, TextPlugin as default };

View File

@ -0,0 +1,844 @@
/*!
* VERSION: 2.1.0
* DATE: 2019-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
import TweenLite, { _gsScope, globals, Animation, SimpleTimeline } from "./TweenLite.js";
_gsScope._gsDefine("TimelineLite", ["core.Animation","core.SimpleTimeline","TweenLite"], function() {
var TimelineLite = function(vars) {
SimpleTimeline.call(this, vars);
var self = this,
v = self.vars,
val, p;
self._labels = {};
self.autoRemoveChildren = !!v.autoRemoveChildren;
self.smoothChildTiming = !!v.smoothChildTiming;
self._sortChildren = true;
self._onUpdate = v.onUpdate;
for (p in v) {
val = v[p];
if (_isArray(val)) if (val.join("").indexOf("{self}") !== -1) {
v[p] = self._swapSelfInParams(val);
}
}
if (_isArray(v.tweens)) {
self.add(v.tweens, 0, v.align, v.stagger);
}
},
_tinyNum = 0.00000001,
TweenLiteInternals = TweenLite._internals,
_internals = TimelineLite._internals = {},
_isSelector = TweenLiteInternals.isSelector,
_isArray = TweenLiteInternals.isArray,
_lazyTweens = TweenLiteInternals.lazyTweens,
_lazyRender = TweenLiteInternals.lazyRender,
_globals = _gsScope._gsDefine.globals,
_copy = function(vars) {
var copy = {}, p;
for (p in vars) {
copy[p] = vars[p];
}
return copy;
},
_applyCycle = function(vars, targets, i) {
var alt = vars.cycle,
p, val;
for (p in alt) {
val = alt[p];
vars[p] = (typeof(val) === "function") ? val(i, targets[i], targets) : val[i % val.length];
}
delete vars.cycle;
},
_pauseCallback = _internals.pauseCallback = function() {},
_slice = function(a) { //don't use [].slice because that doesn't work in IE8 with a NodeList that's returned by querySelectorAll()
var b = [],
l = a.length,
i;
for (i = 0; i !== l; b.push(a[i++]));
return b;
},
_defaultImmediateRender = function(tl, toVars, fromVars, defaultFalse) { //default to immediateRender:true unless otherwise set in toVars, fromVars or if defaultFalse is passed in as true
var ir = "immediateRender";
if (!(ir in toVars)) {
toVars[ir] = !(tl._paused || (fromVars && fromVars[ir] === false) || defaultFalse);
}
return toVars;
},
//for distributing values across an array. Can accept a number, a function or (most commonly) a function which can contain the following properties: {base, amount, from, ease, grid, axis, length}. Returns a function that expects the following parameters: index, target, array. Recognizes the following
_distribute = function(v) {
if (typeof(v) === "function") {
return v;
}
var vars = isNaN(v) ? v : {n:1, from:(v < 0) ? ((v = -v) && "end") : 0}, //n:1 is just to indicate v was a number; we leverage that later to set v according to the length we get. If a number is passed in, we treat it like the old stagger value where 0.1, for example, would mean that things would be distributed with 0.1 between each element in the array rather than a total "amount" that's chunked out among them all.
ease = vars.ease,
from = vars.from || 0,
base = vars.base || 0,
cache = {},
isFromKeyword = isNaN(from),
axis = vars.axis,
ratio = {center:0.5, end:1}[from] || 0;
return function(i, target, a) {
var l = (a || vars).length,
distances = cache[l],
originX, originY, x, y, d, j, max, min, wrap;
if (!distances) {
wrap = (vars.grid === "auto") ? 0 : (vars.grid || [Infinity])[0];
if (!wrap) {
max = -Infinity;
while (max < (max = a[wrap++].getBoundingClientRect().left) && wrap < l) { }
wrap--;
}
distances = cache[l] = [];
originX = isFromKeyword ? (Math.min(wrap, l) * ratio) - 0.5 : from % wrap;
originY = isFromKeyword ? l * ratio / wrap - 0.5 : (from / wrap) | 0;
max = 0;
min = Infinity;
for (j = 0; j < l; j++) {
x = (j % wrap) - originX;
y = originY - ((j / wrap) | 0);
distances[j] = d = !axis ? Math.sqrt(x * x + y * y) : Math.abs((axis === "y") ? y : x);
if (d > max) {
max = d;
}
if (d < min) {
min = d;
}
}
distances.max = max - min;
distances.min = min;
distances.v = vars.n ? l * (v || 0) : vars.amount;
}
l = (distances[i] - distances.min) / distances.max;
return base + (ease ? ease.getRatio(l) : l) * distances.v;
};
},
p = TimelineLite.prototype = new SimpleTimeline();
TimelineLite.version = "2.1.0";
TimelineLite.distribute = _distribute;
p.constructor = TimelineLite;
p.kill()._gc = p._forcingPlayhead = p._hasPause = false;
/* might use later...
//translates a local time inside an animation to the corresponding time on the root/global timeline, factoring in all nesting and timeScales.
function localToGlobal(time, animation) {
while (animation) {
time = (time / animation._timeScale) + animation._startTime;
animation = animation.timeline;
}
return time;
}
//translates the supplied time on the root/global timeline into the corresponding local time inside a particular animation, factoring in all nesting and timeScales
function globalToLocal(time, animation) {
var scale = 1;
time -= localToGlobal(0, animation);
while (animation) {
scale *= animation._timeScale;
animation = animation.timeline;
}
return time * scale;
}
*/
p.to = function(target, duration, vars, position) {
var Engine = (vars.repeat && _globals.TweenMax) || TweenLite;
return duration ? this.add( new Engine(target, duration, vars), position) : this.set(target, vars, position);
};
p.from = function(target, duration, vars, position) {
return this.add( ((vars.repeat && _globals.TweenMax) || TweenLite).from(target, duration, _defaultImmediateRender(this, vars)), position);
};
p.fromTo = function(target, duration, fromVars, toVars, position) {
var Engine = (toVars.repeat && _globals.TweenMax) || TweenLite;
toVars = _defaultImmediateRender(this, toVars, fromVars);
return duration ? this.add( Engine.fromTo(target, duration, fromVars, toVars), position) : this.set(target, toVars, position);
};
p.staggerTo = function(targets, duration, vars, stagger, position, onCompleteAll, onCompleteAllParams, onCompleteAllScope) {
var tl = new TimelineLite({onComplete:onCompleteAll, onCompleteParams:onCompleteAllParams, callbackScope:onCompleteAllScope, smoothChildTiming:this.smoothChildTiming}),
staggerFunc = _distribute(vars.stagger || stagger),
startAt = vars.startAt,
cycle = vars.cycle,
copy, i;
if (typeof(targets) === "string") {
targets = TweenLite.selector(targets) || targets;
}
targets = targets || [];
if (_isSelector(targets)) { //if the targets object is a selector, translate it into an array.
targets = _slice(targets);
}
for (i = 0; i < targets.length; i++) {
copy = _copy(vars);
if (startAt) {
copy.startAt = _copy(startAt);
if (startAt.cycle) {
_applyCycle(copy.startAt, targets, i);
}
}
if (cycle) {
_applyCycle(copy, targets, i);
if (copy.duration != null) {
duration = copy.duration;
delete copy.duration;
}
}
tl.to(targets[i], duration, copy, staggerFunc(i, targets[i], targets));
}
return this.add(tl, position);
};
p.staggerFrom = function(targets, duration, vars, stagger, position, onCompleteAll, onCompleteAllParams, onCompleteAllScope) {
vars.runBackwards = true;
return this.staggerTo(targets, duration, _defaultImmediateRender(this, vars), stagger, position, onCompleteAll, onCompleteAllParams, onCompleteAllScope);
};
p.staggerFromTo = function(targets, duration, fromVars, toVars, stagger, position, onCompleteAll, onCompleteAllParams, onCompleteAllScope) {
toVars.startAt = fromVars;
return this.staggerTo(targets, duration, _defaultImmediateRender(this, toVars, fromVars), stagger, position, onCompleteAll, onCompleteAllParams, onCompleteAllScope);
};
p.call = function(callback, params, scope, position) {
return this.add( TweenLite.delayedCall(0, callback, params, scope), position);
};
p.set = function(target, vars, position) {
return this.add( new TweenLite(target, 0, _defaultImmediateRender(this, vars, null, true)), position);
};
TimelineLite.exportRoot = function(vars, ignoreDelayedCalls) {
vars = vars || {};
if (vars.smoothChildTiming == null) {
vars.smoothChildTiming = true;
}
var tl = new TimelineLite(vars),
root = tl._timeline,
hasNegativeStart, time, tween, next;
if (ignoreDelayedCalls == null) {
ignoreDelayedCalls = true;
}
root._remove(tl, true);
tl._startTime = 0;
tl._rawPrevTime = tl._time = tl._totalTime = root._time;
tween = root._first;
while (tween) {
next = tween._next;
if (!ignoreDelayedCalls || !(tween instanceof TweenLite && tween.target === tween.vars.onComplete)) {
time = tween._startTime - tween._delay;
if (time < 0) {
hasNegativeStart = 1;
}
tl.add(tween, time);
}
tween = next;
}
root.add(tl, 0);
if (hasNegativeStart) { //calling totalDuration() will force the adjustment necessary to shift the children forward so none of them start before zero, and moves the timeline backwards the same amount, so the playhead is still aligned where it should be globally, but the timeline doesn't have illegal children that start before zero.
tl.totalDuration();
}
return tl;
};
p.add = function(value, position, align, stagger) {
var self = this,
curTime, l, i, child, tl, beforeRawTime;
if (typeof(position) !== "number") {
position = self._parseTimeOrLabel(position, 0, true, value);
}
if (!(value instanceof Animation)) {
if ((value instanceof Array) || (value && value.push && _isArray(value))) {
align = align || "normal";
stagger = stagger || 0;
curTime = position;
l = value.length;
for (i = 0; i < l; i++) {
if (_isArray(child = value[i])) {
child = new TimelineLite({tweens:child});
}
self.add(child, curTime);
if (typeof(child) !== "string" && typeof(child) !== "function") {
if (align === "sequence") {
curTime = child._startTime + (child.totalDuration() / child._timeScale);
} else if (align === "start") {
child._startTime -= child.delay();
}
}
curTime += stagger;
}
return self._uncache(true);
} else if (typeof(value) === "string") {
return self.addLabel(value, position);
} else if (typeof(value) === "function") {
value = TweenLite.delayedCall(0, value);
} else {
throw("Cannot add " + value + " into the timeline; it is not a tween, timeline, function, or string.");
}
}
SimpleTimeline.prototype.add.call(self, value, position);
if (value._time || (!value._duration && value._initted)) { //in case, for example, the _startTime is moved on a tween that has already rendered. Imagine it's at its end state, then the startTime is moved WAY later (after the end of this timeline), it should render at its beginning.
curTime = (self.rawTime() - value._startTime) * value._timeScale;
if (!value._duration || Math.abs(Math.max(0, Math.min(value.totalDuration(), curTime))) - value._totalTime > 0.00001) {
value.render(curTime, false, false);
}
}
//if the timeline has already ended but the inserted tween/timeline extends the duration, we should enable this timeline again so that it renders properly. We should also align the playhead with the parent timeline's when appropriate.
if (self._gc || self._time === self._duration) if (!self._paused) if (self._duration < self.duration()) {
//in case any of the ancestors had completed but should now be enabled...
tl = self;
beforeRawTime = (tl.rawTime() > value._startTime); //if the tween is placed on the timeline so that it starts BEFORE the current rawTime, we should align the playhead (move the timeline). This is because sometimes users will create a timeline, let it finish, and much later append a tween and expect it to run instead of jumping to its end state. While technically one could argue that it should jump to its end state, that's not what users intuitively expect.
while (tl._timeline) {
if (beforeRawTime && tl._timeline.smoothChildTiming) {
tl.totalTime(tl._totalTime, true); //moves the timeline (shifts its startTime) if necessary, and also enables it.
} else if (tl._gc) {
tl._enabled(true, false);
}
tl = tl._timeline;
}
}
return self;
};
p.remove = function(value) {
if (value instanceof Animation) {
this._remove(value, false);
var tl = value._timeline = value.vars.useFrames ? Animation._rootFramesTimeline : Animation._rootTimeline; //now that it's removed, default it to the root timeline so that if it gets played again, it doesn't jump back into this timeline.
value._startTime = (value._paused ? value._pauseTime : tl._time) - ((!value._reversed ? value._totalTime : value.totalDuration() - value._totalTime) / value._timeScale); //ensure that if it gets played again, the timing is correct.
return this;
} else if (value instanceof Array || (value && value.push && _isArray(value))) {
var i = value.length;
while (--i > -1) {
this.remove(value[i]);
}
return this;
} else if (typeof(value) === "string") {
return this.removeLabel(value);
}
return this.kill(null, value);
};
p._remove = function(tween, skipDisable) {
SimpleTimeline.prototype._remove.call(this, tween, skipDisable);
var last = this._last;
if (!last) {
this._time = this._totalTime = this._duration = this._totalDuration = 0;
} else if (this._time > this.duration()) {
this._time = this._duration;
this._totalTime = this._totalDuration;
}
return this;
};
p.append = function(value, offsetOrLabel) {
return this.add(value, this._parseTimeOrLabel(null, offsetOrLabel, true, value));
};
p.insert = p.insertMultiple = function(value, position, align, stagger) {
return this.add(value, position || 0, align, stagger);
};
p.appendMultiple = function(tweens, offsetOrLabel, align, stagger) {
return this.add(tweens, this._parseTimeOrLabel(null, offsetOrLabel, true, tweens), align, stagger);
};
p.addLabel = function(label, position) {
this._labels[label] = this._parseTimeOrLabel(position);
return this;
};
p.addPause = function(position, callback, params, scope) {
var t = TweenLite.delayedCall(0, _pauseCallback, params, scope || this);
t.vars.onComplete = t.vars.onReverseComplete = callback;
t.data = "isPause";
this._hasPause = true;
return this.add(t, position);
};
p.removeLabel = function(label) {
delete this._labels[label];
return this;
};
p.getLabelTime = function(label) {
return (this._labels[label] != null) ? this._labels[label] : -1;
};
p._parseTimeOrLabel = function(timeOrLabel, offsetOrLabel, appendIfAbsent, ignore) {
var clippedDuration, i;
//if we're about to add a tween/timeline (or an array of them) that's already a child of this timeline, we should remove it first so that it doesn't contaminate the duration().
if (ignore instanceof Animation && ignore.timeline === this) {
this.remove(ignore);
} else if (ignore && ((ignore instanceof Array) || (ignore.push && _isArray(ignore)))) {
i = ignore.length;
while (--i > -1) {
if (ignore[i] instanceof Animation && ignore[i].timeline === this) {
this.remove(ignore[i]);
}
}
}
clippedDuration = (typeof(timeOrLabel) === "number" && !offsetOrLabel) ? 0 : (this.duration() > 99999999999) ? this.recent().endTime(false) : this._duration; //in case there's a child that infinitely repeats, users almost never intend for the insertion point of a new child to be based on a SUPER long value like that so we clip it and assume the most recently-added child's endTime should be used instead.
if (typeof(offsetOrLabel) === "string") {
return this._parseTimeOrLabel(offsetOrLabel, (appendIfAbsent && typeof(timeOrLabel) === "number" && this._labels[offsetOrLabel] == null) ? timeOrLabel - clippedDuration : 0, appendIfAbsent);
}
offsetOrLabel = offsetOrLabel || 0;
if (typeof(timeOrLabel) === "string" && (isNaN(timeOrLabel) || this._labels[timeOrLabel] != null)) { //if the string is a number like "1", check to see if there's a label with that name, otherwise interpret it as a number (absolute value).
i = timeOrLabel.indexOf("=");
if (i === -1) {
if (this._labels[timeOrLabel] == null) {
return appendIfAbsent ? (this._labels[timeOrLabel] = clippedDuration + offsetOrLabel) : offsetOrLabel;
}
return this._labels[timeOrLabel] + offsetOrLabel;
}
offsetOrLabel = parseInt(timeOrLabel.charAt(i-1) + "1", 10) * Number(timeOrLabel.substr(i+1));
timeOrLabel = (i > 1) ? this._parseTimeOrLabel(timeOrLabel.substr(0, i-1), 0, appendIfAbsent) : clippedDuration;
} else if (timeOrLabel == null) {
timeOrLabel = clippedDuration;
}
return Number(timeOrLabel) + offsetOrLabel;
};
p.seek = function(position, suppressEvents) {
return this.totalTime((typeof(position) === "number") ? position : this._parseTimeOrLabel(position), (suppressEvents !== false));
};
p.stop = function() {
return this.paused(true);
};
p.gotoAndPlay = function(position, suppressEvents) {
return this.play(position, suppressEvents);
};
p.gotoAndStop = function(position, suppressEvents) {
return this.pause(position, suppressEvents);
};
p.render = function(time, suppressEvents, force) {
if (this._gc) {
this._enabled(true, false);
}
var self = this,
prevTime = self._time,
totalDur = (!self._dirty) ? self._totalDuration : self.totalDuration(),
prevStart = self._startTime,
prevTimeScale = self._timeScale,
prevPaused = self._paused,
tween, isComplete, next, callback, internalForce, pauseTween, curTime, pauseTime;
if (prevTime !== self._time) { //if totalDuration() finds a child with a negative startTime and smoothChildTiming is true, things get shifted around internally so we need to adjust the time accordingly. For example, if a tween starts at -30 we must shift EVERYTHING forward 30 seconds and move this timeline's startTime backward by 30 seconds so that things align with the playhead (no jump).
time += self._time - prevTime;
}
if (time >= totalDur - _tinyNum && time >= 0) { //to work around occasional floating point math artifacts.
self._totalTime = self._time = totalDur;
if (!self._reversed) if (!self._hasPausedChild()) {
isComplete = true;
callback = "onComplete";
internalForce = !!self._timeline.autoRemoveChildren; //otherwise, if the animation is unpaused/activated after it's already finished, it doesn't get removed from the parent timeline.
if (self._duration === 0) if ((time <= 0 && time >= -_tinyNum) || self._rawPrevTime < 0 || self._rawPrevTime === _tinyNum) if (self._rawPrevTime !== time && self._first) {
internalForce = true;
if (self._rawPrevTime > _tinyNum) {
callback = "onReverseComplete";
}
}
}
self._rawPrevTime = (self._duration || !suppressEvents || time || self._rawPrevTime === time) ? time : _tinyNum; //when the playhead arrives at EXACTLY time 0 (right on top) of a zero-duration timeline or tween, we need to discern if events are suppressed so that when the playhead moves again (next time), it'll trigger the callback. If events are NOT suppressed, obviously the callback would be triggered in this render. Basically, the callback should fire either when the playhead ARRIVES or LEAVES this exact spot, not both. Imagine doing a timeline.seek(0) and there's a callback that sits at 0. Since events are suppressed on that seek() by default, nothing will fire, but when the playhead moves off of that position, the callback should fire. This behavior is what people intuitively expect. We set the _rawPrevTime to be a precise tiny number to indicate this scenario rather than using another property/variable which would increase memory usage. This technique is less readable, but more efficient.
time = totalDur + 0.0001; //to avoid occasional floating point rounding errors - sometimes child tweens/timelines were not being fully completed (their progress might be 0.999999999999998 instead of 1 because when _time - tween._startTime is performed, floating point errors would return a value that was SLIGHTLY off). Try (999999999999.7 - 999999999999) * 1 = 0.699951171875 instead of 0.7.
} else if (time < _tinyNum) { //to work around occasional floating point math artifacts, round super small values to 0.
self._totalTime = self._time = 0;
if (time > -_tinyNum) {
time = 0;
}
if (prevTime !== 0 || (self._duration === 0 && self._rawPrevTime !== _tinyNum && (self._rawPrevTime > 0 || (time < 0 && self._rawPrevTime >= 0)))) {
callback = "onReverseComplete";
isComplete = self._reversed;
}
if (time < 0) {
self._active = false;
if (self._timeline.autoRemoveChildren && self._reversed) { //ensures proper GC if a timeline is resumed after it's finished reversing.
internalForce = isComplete = true;
callback = "onReverseComplete";
} else if (self._rawPrevTime >= 0 && self._first) { //when going back beyond the start, force a render so that zero-duration tweens that sit at the very beginning render their start values properly. Otherwise, if the parent timeline's playhead lands exactly at this timeline's startTime, and then moves backwards, the zero-duration tweens at the beginning would still be at their end state.
internalForce = true;
}
self._rawPrevTime = time;
} else {
self._rawPrevTime = (self._duration || !suppressEvents || time || self._rawPrevTime === time) ? time : _tinyNum; //when the playhead arrives at EXACTLY time 0 (right on top) of a zero-duration timeline or tween, we need to discern if events are suppressed so that when the playhead moves again (next time), it'll trigger the callback. If events are NOT suppressed, obviously the callback would be triggered in this render. Basically, the callback should fire either when the playhead ARRIVES or LEAVES this exact spot, not both. Imagine doing a timeline.seek(0) and there's a callback that sits at 0. Since events are suppressed on that seek() by default, nothing will fire, but when the playhead moves off of that position, the callback should fire. This behavior is what people intuitively expect. We set the _rawPrevTime to be a precise tiny number to indicate this scenario rather than using another property/variable which would increase memory usage. This technique is less readable, but more efficient.
if (time === 0 && isComplete) { //if there's a zero-duration tween at the very beginning of a timeline and the playhead lands EXACTLY at time 0, that tween will correctly render its end values, but we need to keep the timeline alive for one more render so that the beginning values render properly as the parent's playhead keeps moving beyond the begining. Imagine obj.x starts at 0 and then we do tl.set(obj, {x:100}).to(obj, 1, {x:200}) and then later we tl.reverse()...the goal is to have obj.x revert to 0. If the playhead happens to land on exactly 0, without this chunk of code, it'd complete the timeline and remove it from the rendering queue (not good).
tween = self._first;
while (tween && tween._startTime === 0) {
if (!tween._duration) {
isComplete = false;
}
tween = tween._next;
}
}
time = 0; //to avoid occasional floating point rounding errors (could cause problems especially with zero-duration tweens at the very beginning of the timeline)
if (!self._initted) {
internalForce = true;
}
}
} else {
if (self._hasPause && !self._forcingPlayhead && !suppressEvents) {
if (time >= prevTime) {
tween = self._first;
while (tween && tween._startTime <= time && !pauseTween) {
if (!tween._duration) if (tween.data === "isPause" && !tween.ratio && !(tween._startTime === 0 && self._rawPrevTime === 0)) {
pauseTween = tween;
}
tween = tween._next;
}
} else {
tween = self._last;
while (tween && tween._startTime >= time && !pauseTween) {
if (!tween._duration) if (tween.data === "isPause" && tween._rawPrevTime > 0) {
pauseTween = tween;
}
tween = tween._prev;
}
}
if (pauseTween) {
self._time = self._totalTime = time = pauseTween._startTime;
pauseTime = self._startTime + (time / self._timeScale);
}
}
self._totalTime = self._time = self._rawPrevTime = time;
}
if ((self._time === prevTime || !self._first) && !force && !internalForce && !pauseTween) {
return;
} else if (!self._initted) {
self._initted = true;
}
if (!self._active) if (!self._paused && self._time !== prevTime && time > 0) {
self._active = true; //so that if the user renders the timeline (as opposed to the parent timeline rendering it), it is forced to re-render and align it with the proper time/frame on the next rendering cycle. Maybe the timeline already finished but the user manually re-renders it as halfway done, for example.
}
if (prevTime === 0) if (self.vars.onStart) if (self._time !== 0 || !self._duration) if (!suppressEvents) {
self._callback("onStart");
}
curTime = self._time;
if (curTime >= prevTime) {
tween = self._first;
while (tween) {
next = tween._next; //record it here because the value could change after rendering...
if (curTime !== self._time || (self._paused && !prevPaused)) { //in case a tween pauses or seeks the timeline when rendering, like inside of an onUpdate/onComplete
break;
} else if (tween._active || (tween._startTime <= curTime && !tween._paused && !tween._gc)) {
if (pauseTween === tween) {
self.pause();
self._pauseTime = pauseTime; //so that when we resume(), it's starting from exactly the right spot (the pause() method uses the rawTime for the parent, but that may be a bit too far ahead)
}
if (!tween._reversed) {
tween.render((time - tween._startTime) * tween._timeScale, suppressEvents, force);
} else {
tween.render(((!tween._dirty) ? tween._totalDuration : tween.totalDuration()) - ((time - tween._startTime) * tween._timeScale), suppressEvents, force);
}
}
tween = next;
}
} else {
tween = self._last;
while (tween) {
next = tween._prev; //record it here because the value could change after rendering...
if (curTime !== self._time || (self._paused && !prevPaused)) { //in case a tween pauses or seeks the timeline when rendering, like inside of an onUpdate/onComplete
break;
} else if (tween._active || (tween._startTime <= prevTime && !tween._paused && !tween._gc)) {
if (pauseTween === tween) {
pauseTween = tween._prev; //the linked list is organized by _startTime, thus it's possible that a tween could start BEFORE the pause and end after it, in which case it would be positioned before the pause tween in the linked list, but we should render it before we pause() the timeline and cease rendering. This is only a concern when going in reverse.
while (pauseTween && pauseTween.endTime() > self._time) {
pauseTween.render( (pauseTween._reversed ? pauseTween.totalDuration() - ((time - pauseTween._startTime) * pauseTween._timeScale) : (time - pauseTween._startTime) * pauseTween._timeScale), suppressEvents, force);
pauseTween = pauseTween._prev;
}
pauseTween = null;
self.pause();
self._pauseTime = pauseTime; //so that when we resume(), it's starting from exactly the right spot (the pause() method uses the rawTime for the parent, but that may be a bit too far ahead)
}
if (!tween._reversed) {
tween.render((time - tween._startTime) * tween._timeScale, suppressEvents, force);
} else {
tween.render(((!tween._dirty) ? tween._totalDuration : tween.totalDuration()) - ((time - tween._startTime) * tween._timeScale), suppressEvents, force);
}
}
tween = next;
}
}
if (self._onUpdate) if (!suppressEvents) {
if (_lazyTweens.length) { //in case rendering caused any tweens to lazy-init, we should render them because typically when a timeline finishes, users expect things to have rendered fully. Imagine an onUpdate on a timeline that reports/checks tweened values.
_lazyRender();
}
self._callback("onUpdate");
}
if (callback) if (!self._gc) if (prevStart === self._startTime || prevTimeScale !== self._timeScale) if (self._time === 0 || totalDur >= self.totalDuration()) { //if one of the tweens that was rendered altered this timeline's startTime (like if an onComplete reversed the timeline), it probably isn't complete. If it is, don't worry, because whatever call altered the startTime would complete if it was necessary at the new time. The only exception is the timeScale property. Also check _gc because there's a chance that kill() could be called in an onUpdate
if (isComplete) {
if (_lazyTweens.length) { //in case rendering caused any tweens to lazy-init, we should render them because typically when a timeline finishes, users expect things to have rendered fully. Imagine an onComplete on a timeline that reports/checks tweened values.
_lazyRender();
}
if (self._timeline.autoRemoveChildren) {
self._enabled(false, false);
}
self._active = false;
}
if (!suppressEvents && self.vars[callback]) {
self._callback(callback);
}
}
};
p._hasPausedChild = function() {
var tween = this._first;
while (tween) {
if (tween._paused || ((tween instanceof TimelineLite) && tween._hasPausedChild())) {
return true;
}
tween = tween._next;
}
return false;
};
p.getChildren = function(nested, tweens, timelines, ignoreBeforeTime) {
ignoreBeforeTime = ignoreBeforeTime || -9999999999;
var a = [],
tween = this._first,
cnt = 0;
while (tween) {
if (tween._startTime < ignoreBeforeTime) {
//do nothing
} else if (tween instanceof TweenLite) {
if (tweens !== false) {
a[cnt++] = tween;
}
} else {
if (timelines !== false) {
a[cnt++] = tween;
}
if (nested !== false) {
a = a.concat(tween.getChildren(true, tweens, timelines));
cnt = a.length;
}
}
tween = tween._next;
}
return a;
};
p.getTweensOf = function(target, nested) {
var disabled = this._gc,
a = [],
cnt = 0,
tweens, i;
if (disabled) {
this._enabled(true, true); //getTweensOf() filters out disabled tweens, and we have to mark them as _gc = true when the timeline completes in order to allow clean garbage collection, so temporarily re-enable the timeline here.
}
tweens = TweenLite.getTweensOf(target);
i = tweens.length;
while (--i > -1) {
if (tweens[i].timeline === this || (nested && this._contains(tweens[i]))) {
a[cnt++] = tweens[i];
}
}
if (disabled) {
this._enabled(false, true);
}
return a;
};
p.recent = function() {
return this._recent;
};
p._contains = function(tween) {
var tl = tween.timeline;
while (tl) {
if (tl === this) {
return true;
}
tl = tl.timeline;
}
return false;
};
p.shiftChildren = function(amount, adjustLabels, ignoreBeforeTime) {
ignoreBeforeTime = ignoreBeforeTime || 0;
var tween = this._first,
labels = this._labels,
p;
while (tween) {
if (tween._startTime >= ignoreBeforeTime) {
tween._startTime += amount;
}
tween = tween._next;
}
if (adjustLabels) {
for (p in labels) {
if (labels[p] >= ignoreBeforeTime) {
labels[p] += amount;
}
}
}
return this._uncache(true);
};
p._kill = function(vars, target) {
if (!vars && !target) {
return this._enabled(false, false);
}
var tweens = (!target) ? this.getChildren(true, true, false) : this.getTweensOf(target),
i = tweens.length,
changed = false;
while (--i > -1) {
if (tweens[i]._kill(vars, target)) {
changed = true;
}
}
return changed;
};
p.clear = function(labels) {
var tweens = this.getChildren(false, true, true),
i = tweens.length;
this._time = this._totalTime = 0;
while (--i > -1) {
tweens[i]._enabled(false, false);
}
if (labels !== false) {
this._labels = {};
}
return this._uncache(true);
};
p.invalidate = function() {
var tween = this._first;
while (tween) {
tween.invalidate();
tween = tween._next;
}
return Animation.prototype.invalidate.call(this);;
};
p._enabled = function(enabled, ignoreTimeline) {
if (enabled === this._gc) {
var tween = this._first;
while (tween) {
tween._enabled(enabled, true);
tween = tween._next;
}
}
return SimpleTimeline.prototype._enabled.call(this, enabled, ignoreTimeline);
};
p.totalTime = function(time, suppressEvents, uncapped) {
this._forcingPlayhead = true;
var val = Animation.prototype.totalTime.apply(this, arguments);
this._forcingPlayhead = false;
return val;
};
p.duration = function(value) {
if (!arguments.length) {
if (this._dirty) {
this.totalDuration(); //just triggers recalculation
}
return this._duration;
}
if (this.duration() !== 0 && value !== 0) {
this.timeScale(this._duration / value);
}
return this;
};
p.totalDuration = function(value) {
if (!arguments.length) {
if (this._dirty) {
var max = 0,
self = this,
tween = self._last,
prevStart = 999999999999,
prev, end;
while (tween) {
prev = tween._prev; //record it here in case the tween changes position in the sequence...
if (tween._dirty) {
tween.totalDuration(); //could change the tween._startTime, so make sure the tween's cache is clean before analyzing it.
}
if (tween._startTime > prevStart && self._sortChildren && !tween._paused && !self._calculatingDuration) { //in case one of the tweens shifted out of order, it needs to be re-inserted into the correct position in the sequence
self._calculatingDuration = 1; //prevent endless recursive calls - there are methods that get triggered that check duration/totalDuration when we add(), like _parseTimeOrLabel().
self.add(tween, tween._startTime - tween._delay);
self._calculatingDuration = 0;
} else {
prevStart = tween._startTime;
}
if (tween._startTime < 0 && !tween._paused) { //children aren't allowed to have negative startTimes unless smoothChildTiming is true, so adjust here if one is found.
max -= tween._startTime;
if (self._timeline.smoothChildTiming) {
self._startTime += tween._startTime / self._timeScale;
self._time -= tween._startTime;
self._totalTime -= tween._startTime;
self._rawPrevTime -= tween._startTime;
}
self.shiftChildren(-tween._startTime, false, -9999999999);
prevStart = 0;
}
end = tween._startTime + (tween._totalDuration / tween._timeScale);
if (end > max) {
max = end;
}
tween = prev;
}
self._duration = self._totalDuration = max;
self._dirty = false;
}
return this._totalDuration;
}
return (value && this.totalDuration()) ? this.timeScale(this._totalDuration / value) : this;
};
p.paused = function(value) {
if (value === false && this._paused) { //if there's a pause directly at the spot from where we're unpausing, skip it.
var tween = this._first;
while (tween) {
if (tween._startTime === this._time && tween.data === "isPause") {
tween._rawPrevTime = 0; //remember, _rawPrevTime is how zero-duration tweens/callbacks sense directionality and determine whether or not to fire. If _rawPrevTime is the same as _startTime on the next render, it won't fire.
}
tween = tween._next;
}
}
return Animation.prototype.paused.apply(this, arguments);
};
p.usesFrames = function() {
var tl = this._timeline;
while (tl._timeline) {
tl = tl._timeline;
}
return (tl === Animation._rootFramesTimeline);
};
p.rawTime = function(wrapRepeats) {
return (wrapRepeats && (this._paused || (this._repeat && this.time() > 0 && this.totalProgress() < 1))) ? this._totalTime % (this._duration + this._repeatDelay) : this._paused ? this._totalTime : (this._timeline.rawTime(wrapRepeats) - this._startTime) * this._timeScale;
};
return TimelineLite;
}, true);
export var TimelineLite = globals.TimelineLite;
export { TimelineLite as default };

523
lib/3rdparty/gsap/src/esm/TimelineMax.js vendored Normal file
View File

@ -0,0 +1,523 @@
/*!
* VERSION: 2.1.0
* DATE: 2019-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
import TweenLite, { _gsScope, globals, Ease, Animation } from "./TweenLite.js";
import TimelineLite from "./TimelineLite.js";
_gsScope._gsDefine("TimelineMax", ["TimelineLite","TweenLite","easing.Ease"], function() {
var TimelineMax = function(vars) {
TimelineLite.call(this, vars);
this._repeat = this.vars.repeat || 0;
this._repeatDelay = this.vars.repeatDelay || 0;
this._cycle = 0;
this._yoyo = !!this.vars.yoyo;
this._dirty = true;
},
_tinyNum = 0.00000001,
TweenLiteInternals = TweenLite._internals,
_lazyTweens = TweenLiteInternals.lazyTweens,
_lazyRender = TweenLiteInternals.lazyRender,
_globals = _gsScope._gsDefine.globals,
_easeNone = new Ease(null, null, 1, 0),
p = TimelineMax.prototype = new TimelineLite();
p.constructor = TimelineMax;
p.kill()._gc = false;
TimelineMax.version = "2.1.0";
p.invalidate = function() {
this._yoyo = !!this.vars.yoyo;
this._repeat = this.vars.repeat || 0;
this._repeatDelay = this.vars.repeatDelay || 0;
this._uncache(true);
return TimelineLite.prototype.invalidate.call(this);
};
p.addCallback = function(callback, position, params, scope) {
return this.add( TweenLite.delayedCall(0, callback, params, scope), position);
};
p.removeCallback = function(callback, position) {
if (callback) {
if (position == null) {
this._kill(null, callback);
} else {
var a = this.getTweensOf(callback, false),
i = a.length,
time = this._parseTimeOrLabel(position);
while (--i > -1) {
if (a[i]._startTime === time) {
a[i]._enabled(false, false);
}
}
}
}
return this;
};
p.removePause = function(position) {
return this.removeCallback(TimelineLite._internals.pauseCallback, position);
};
p.tweenTo = function(position, vars) {
vars = vars || {};
var copy = {ease:_easeNone, useFrames:this.usesFrames(), immediateRender:false, lazy:false},
Engine = (vars.repeat && _globals.TweenMax) || TweenLite,
duration, p, t;
for (p in vars) {
copy[p] = vars[p];
}
copy.time = this._parseTimeOrLabel(position);
duration = (Math.abs(Number(copy.time) - this._time) / this._timeScale) || 0.001;
t = new Engine(this, duration, copy);
copy.onStart = function() {
t.target.paused(true);
if (t.vars.time !== t.target.time() && duration === t.duration() && !t.isFromTo) { //don't make the duration zero - if it's supposed to be zero, don't worry because it's already initting the tween and will complete immediately, effectively making the duration zero anyway. If we make duration zero, the tween won't run at all.
t.duration( Math.abs( t.vars.time - t.target.time()) / t.target._timeScale ).render(t.time(), true, true); //render() right away to ensure that things look right, especially in the case of .tweenTo(0).
}
if (vars.onStart) { //in case the user had an onStart in the vars - we don't want to overwrite it.
vars.onStart.apply(vars.onStartScope || vars.callbackScope || t, vars.onStartParams || []); //don't use t._callback("onStart") or it'll point to the copy.onStart and we'll get a recursion error.
}
};
return t;
};
p.tweenFromTo = function(fromPosition, toPosition, vars) {
vars = vars || {};
fromPosition = this._parseTimeOrLabel(fromPosition);
vars.startAt = {onComplete:this.seek, onCompleteParams:[fromPosition], callbackScope:this};
vars.immediateRender = (vars.immediateRender !== false);
var t = this.tweenTo(toPosition, vars);
t.isFromTo = 1; //to ensure we don't mess with the duration in the onStart (we've got the start and end values here, so lock it in)
return t.duration((Math.abs( t.vars.time - fromPosition) / this._timeScale) || 0.001);
};
p.render = function(time, suppressEvents, force) {
if (this._gc) {
this._enabled(true, false);
}
var self = this,
prevTime = self._time,
totalDur = (!self._dirty) ? self._totalDuration : self.totalDuration(),
dur = self._duration,
prevTotalTime = self._totalTime,
prevStart = self._startTime,
prevTimeScale = self._timeScale,
prevRawPrevTime = self._rawPrevTime,
prevPaused = self._paused,
prevCycle = self._cycle,
tween, isComplete, next, callback, internalForce, cycleDuration, pauseTween, curTime, pauseTime;
if (prevTime !== self._time) { //if totalDuration() finds a child with a negative startTime and smoothChildTiming is true, things get shifted around internally so we need to adjust the time accordingly. For example, if a tween starts at -30 we must shift EVERYTHING forward 30 seconds and move this timeline's startTime backward by 30 seconds so that things align with the playhead (no jump).
time += self._time - prevTime;
}
if (time >= totalDur - _tinyNum && time >= 0) { //to work around occasional floating point math artifacts.
if (!self._locked) {
self._totalTime = totalDur;
self._cycle = self._repeat;
}
if (!self._reversed) if (!self._hasPausedChild()) {
isComplete = true;
callback = "onComplete";
internalForce = !!self._timeline.autoRemoveChildren; //otherwise, if the animation is unpaused/activated after it's already finished, it doesn't get removed from the parent timeline.
if (self._duration === 0) if ((time <= 0 && time >= -_tinyNum) || prevRawPrevTime < 0 || prevRawPrevTime === _tinyNum) if (prevRawPrevTime !== time && self._first) {
internalForce = true;
if (prevRawPrevTime > _tinyNum) {
callback = "onReverseComplete";
}
}
}
self._rawPrevTime = (self._duration || !suppressEvents || time || self._rawPrevTime === time) ? time : _tinyNum; //when the playhead arrives at EXACTLY time 0 (right on top) of a zero-duration timeline or tween, we need to discern if events are suppressed so that when the playhead moves again (next time), it'll trigger the callback. If events are NOT suppressed, obviously the callback would be triggered in this render. Basically, the callback should fire either when the playhead ARRIVES or LEAVES this exact spot, not both. Imagine doing a timeline.seek(0) and there's a callback that sits at 0. Since events are suppressed on that seek() by default, nothing will fire, but when the playhead moves off of that position, the callback should fire. This behavior is what people intuitively expect. We set the _rawPrevTime to be a precise tiny number to indicate this scenario rather than using another property/variable which would increase memory usage. This technique is less readable, but more efficient.
if (self._yoyo && (self._cycle & 1)) {
self._time = time = 0;
} else {
self._time = dur;
time = dur + 0.0001; //to avoid occasional floating point rounding errors - sometimes child tweens/timelines were not being fully completed (their progress might be 0.999999999999998 instead of 1 because when _time - tween._startTime is performed, floating point errors would return a value that was SLIGHTLY off). Try (999999999999.7 - 999999999999) * 1 = 0.699951171875 instead of 0.7. We cannot do less then 0.0001 because the same issue can occur when the duration is extremely large like 999999999999 in which case adding 0.00000001, for example, causes it to act like nothing was added.
}
} else if (time < _tinyNum) { //to work around occasional floating point math artifacts, round super small values to 0.
if (!self._locked) {
self._totalTime = self._cycle = 0;
}
self._time = 0;
if (time > -_tinyNum) {
time = 0;
}
if (prevTime !== 0 || (dur === 0 && prevRawPrevTime !== _tinyNum && (prevRawPrevTime > 0 || (time < 0 && prevRawPrevTime >= 0)) && !self._locked)) { //edge case for checking time < 0 && prevRawPrevTime >= 0: a zero-duration fromTo() tween inside a zero-duration timeline (yeah, very rare)
callback = "onReverseComplete";
isComplete = self._reversed;
}
if (time < 0) {
self._active = false;
if (self._timeline.autoRemoveChildren && self._reversed) {
internalForce = isComplete = true;
callback = "onReverseComplete";
} else if (prevRawPrevTime >= 0 && self._first) { //when going back beyond the start, force a render so that zero-duration tweens that sit at the very beginning render their start values properly. Otherwise, if the parent timeline's playhead lands exactly at this timeline's startTime, and then moves backwards, the zero-duration tweens at the beginning would still be at their end state.
internalForce = true;
}
self._rawPrevTime = time;
} else {
self._rawPrevTime = (dur || !suppressEvents || time || self._rawPrevTime === time) ? time : _tinyNum; //when the playhead arrives at EXACTLY time 0 (right on top) of a zero-duration timeline or tween, we need to discern if events are suppressed so that when the playhead moves again (next time), it'll trigger the callback. If events are NOT suppressed, obviously the callback would be triggered in this render. Basically, the callback should fire either when the playhead ARRIVES or LEAVES this exact spot, not both. Imagine doing a timeline.seek(0) and there's a callback that sits at 0. Since events are suppressed on that seek() by default, nothing will fire, but when the playhead moves off of that position, the callback should fire. This behavior is what people intuitively expect. We set the _rawPrevTime to be a precise tiny number to indicate this scenario rather than using another property/variable which would increase memory usage. This technique is less readable, but more efficient.
if (time === 0 && isComplete) { //if there's a zero-duration tween at the very beginning of a timeline and the playhead lands EXACTLY at time 0, that tween will correctly render its end values, but we need to keep the timeline alive for one more render so that the beginning values render properly as the parent's playhead keeps moving beyond the begining. Imagine obj.x starts at 0 and then we do tl.set(obj, {x:100}).to(obj, 1, {x:200}) and then later we tl.reverse()...the goal is to have obj.x revert to 0. If the playhead happens to land on exactly 0, without this chunk of code, it'd complete the timeline and remove it from the rendering queue (not good).
tween = self._first;
while (tween && tween._startTime === 0) {
if (!tween._duration) {
isComplete = false;
}
tween = tween._next;
}
}
time = 0; //to avoid occasional floating point rounding errors (could cause problems especially with zero-duration tweens at the very beginning of the timeline)
if (!self._initted) {
internalForce = true;
}
}
} else {
if (dur === 0 && prevRawPrevTime < 0) { //without this, zero-duration repeating timelines (like with a simple callback nested at the very beginning and a repeatDelay) wouldn't render the first time through.
internalForce = true;
}
self._time = self._rawPrevTime = time;
if (!self._locked) {
self._totalTime = time;
if (self._repeat !== 0) {
cycleDuration = dur + self._repeatDelay;
self._cycle = (self._totalTime / cycleDuration) >> 0; //originally _totalTime % cycleDuration but floating point errors caused problems, so I normalized it. (4 % 0.8 should be 0 but it gets reported as 0.79999999!)
if (self._cycle) if (self._cycle === self._totalTime / cycleDuration && prevTotalTime <= time) {
self._cycle--; //otherwise when rendered exactly at the end time, it will act as though it is repeating (at the beginning)
}
self._time = self._totalTime - (self._cycle * cycleDuration);
if (self._yoyo) if (self._cycle & 1) {
self._time = dur - self._time;
}
if (self._time > dur) {
self._time = dur;
time = dur + 0.0001; //to avoid occasional floating point rounding error
} else if (self._time < 0) {
self._time = time = 0;
} else {
time = self._time;
}
}
}
if (self._hasPause && !self._forcingPlayhead && !suppressEvents) {
time = self._time;
if (time >= prevTime || (self._repeat && prevCycle !== self._cycle)) {
tween = self._first;
while (tween && tween._startTime <= time && !pauseTween) {
if (!tween._duration) if (tween.data === "isPause" && !tween.ratio && !(tween._startTime === 0 && self._rawPrevTime === 0)) {
pauseTween = tween;
}
tween = tween._next;
}
} else {
tween = self._last;
while (tween && tween._startTime >= time && !pauseTween) {
if (!tween._duration) if (tween.data === "isPause" && tween._rawPrevTime > 0) {
pauseTween = tween;
}
tween = tween._prev;
}
}
if (pauseTween) {
pauseTime = self._startTime + (pauseTween._startTime / self._timeScale);
if (pauseTween._startTime < dur) {
self._time = self._rawPrevTime = time = pauseTween._startTime;
self._totalTime = time + (self._cycle * (self._totalDuration + self._repeatDelay));
}
}
}
}
if (self._cycle !== prevCycle) if (!self._locked) {
/*
make sure children at the end/beginning of the timeline are rendered properly. If, for example,
a 3-second long timeline rendered at 2.9 seconds previously, and now renders at 3.2 seconds (which
would get translated to 2.8 seconds if the timeline yoyos or 0.2 seconds if it just repeats), there
could be a callback or a short tween that's at 2.95 or 3 seconds in which wouldn't render. So
we need to push the timeline to the end (and/or beginning depending on its yoyo value). Also we must
ensure that zero-duration tweens at the very beginning or end of the TimelineMax work.
*/
var backwards = (self._yoyo && (prevCycle & 1) !== 0),
wrap = (backwards === (self._yoyo && (self._cycle & 1) !== 0)),
recTotalTime = self._totalTime,
recCycle = self._cycle,
recRawPrevTime = self._rawPrevTime,
recTime = self._time;
self._totalTime = prevCycle * dur;
if (self._cycle < prevCycle) {
backwards = !backwards;
} else {
self._totalTime += dur;
}
self._time = prevTime; //temporarily revert _time so that render() renders the children in the correct order. Without this, tweens won't rewind correctly. We could arhictect things in a "cleaner" way by splitting out the rendering queue into a separate method but for performance reasons, we kept it all inside this method.
self._rawPrevTime = (dur === 0) ? prevRawPrevTime - 0.0001 : prevRawPrevTime;
self._cycle = prevCycle;
self._locked = true; //prevents changes to totalTime and skips repeat/yoyo behavior when we recursively call render()
prevTime = (backwards) ? 0 : dur;
self.render(prevTime, suppressEvents, (dur === 0));
if (!suppressEvents) if (!self._gc) {
if (self.vars.onRepeat) {
self._cycle = recCycle; //in case the onRepeat alters the playhead or invalidates(), we shouldn't stay locked or use the previous cycle.
self._locked = false;
self._callback("onRepeat");
}
}
if (prevTime !== self._time) { //in case there's a callback like onComplete in a nested tween/timeline that changes the playhead position, like via seek(), we should just abort.
return;
}
if (wrap) {
self._cycle = prevCycle; //if there's an onRepeat, we reverted this above, so make sure it's set properly again. We also unlocked in that scenario, so reset that too.
self._locked = true;
prevTime = (backwards) ? dur + 0.0001 : -0.0001;
self.render(prevTime, true, false);
}
self._locked = false;
if (self._paused && !prevPaused) { //if the render() triggered callback that paused this timeline, we should abort (very rare, but possible)
return;
}
self._time = recTime;
self._totalTime = recTotalTime;
self._cycle = recCycle;
self._rawPrevTime = recRawPrevTime;
}
if ((self._time === prevTime || !self._first) && !force && !internalForce && !pauseTween) {
if (prevTotalTime !== self._totalTime) if (self._onUpdate) if (!suppressEvents) { //so that onUpdate fires even during the repeatDelay - as long as the totalTime changed, we should trigger onUpdate.
self._callback("onUpdate");
}
return;
} else if (!self._initted) {
self._initted = true;
}
if (!self._active) if (!self._paused && self._totalTime !== prevTotalTime && time > 0) {
self._active = true; //so that if the user renders the timeline (as opposed to the parent timeline rendering it), it is forced to re-render and align it with the proper time/frame on the next rendering cycle. Maybe the timeline already finished but the user manually re-renders it as halfway done, for example.
}
if (prevTotalTime === 0) if (self.vars.onStart) if (self._totalTime !== 0 || !self._totalDuration) if (!suppressEvents) {
self._callback("onStart");
}
curTime = self._time;
if (curTime >= prevTime) {
tween = self._first;
while (tween) {
next = tween._next; //record it here because the value could change after rendering...
if (curTime !== self._time || (self._paused && !prevPaused)) { //in case a tween pauses or seeks the timeline when rendering, like inside of an onUpdate/onComplete
break;
} else if (tween._active || (tween._startTime <= self._time && !tween._paused && !tween._gc)) {
if (pauseTween === tween) {
self.pause();
self._pauseTime = pauseTime; //so that when we resume(), it's starting from exactly the right spot (the pause() method uses the rawTime for the parent, but that may be a bit too far ahead)
}
if (!tween._reversed) {
tween.render((time - tween._startTime) * tween._timeScale, suppressEvents, force);
} else {
tween.render(((!tween._dirty) ? tween._totalDuration : tween.totalDuration()) - ((time - tween._startTime) * tween._timeScale), suppressEvents, force);
}
}
tween = next;
}
} else {
tween = self._last;
while (tween) {
next = tween._prev; //record it here because the value could change after rendering...
if (curTime !== self._time || (self._paused && !prevPaused)) { //in case a tween pauses or seeks the timeline when rendering, like inside of an onUpdate/onComplete
break;
} else if (tween._active || (tween._startTime <= prevTime && !tween._paused && !tween._gc)) {
if (pauseTween === tween) {
pauseTween = tween._prev; //the linked list is organized by _startTime, thus it's possible that a tween could start BEFORE the pause and end after it, in which case it would be positioned before the pause tween in the linked list, but we should render it before we pause() the timeline and cease rendering. This is only a concern when going in reverse.
while (pauseTween && pauseTween.endTime() > self._time) {
pauseTween.render( (pauseTween._reversed ? pauseTween.totalDuration() - ((time - pauseTween._startTime) * pauseTween._timeScale) : (time - pauseTween._startTime) * pauseTween._timeScale), suppressEvents, force);
pauseTween = pauseTween._prev;
}
pauseTween = null;
self.pause();
self._pauseTime = pauseTime; //so that when we resume(), it's starting from exactly the right spot (the pause() method uses the rawTime for the parent, but that may be a bit too far ahead)
}
if (!tween._reversed) {
tween.render((time - tween._startTime) * tween._timeScale, suppressEvents, force);
} else {
tween.render(((!tween._dirty) ? tween._totalDuration : tween.totalDuration()) - ((time - tween._startTime) * tween._timeScale), suppressEvents, force);
}
}
tween = next;
}
}
if (self._onUpdate) if (!suppressEvents) {
if (_lazyTweens.length) { //in case rendering caused any tweens to lazy-init, we should render them because typically when a timeline finishes, users expect things to have rendered fully. Imagine an onUpdate on a timeline that reports/checks tweened values.
_lazyRender();
}
self._callback("onUpdate");
}
if (callback) if (!self._locked) if (!self._gc) if (prevStart === self._startTime || prevTimeScale !== self._timeScale) if (self._time === 0 || totalDur >= self.totalDuration()) { //if one of the tweens that was rendered altered this timeline's startTime (like if an onComplete reversed the timeline), it probably isn't complete. If it is, don't worry, because whatever call altered the startTime would complete if it was necessary at the new time. The only exception is the timeScale property. Also check _gc because there's a chance that kill() could be called in an onUpdate
if (isComplete) {
if (_lazyTweens.length) { //in case rendering caused any tweens to lazy-init, we should render them because typically when a timeline finishes, users expect things to have rendered fully. Imagine an onComplete on a timeline that reports/checks tweened values.
_lazyRender();
}
if (self._timeline.autoRemoveChildren) {
self._enabled(false, false);
}
self._active = false;
}
if (!suppressEvents && self.vars[callback]) {
self._callback(callback);
}
}
};
p.getActive = function(nested, tweens, timelines) {
var a = [],
all = this.getChildren(nested || (nested == null), tweens || (nested == null), !!timelines),
cnt = 0,
l = all.length,
i, tween;
for (i = 0; i < l; i++) {
tween = all[i];
if (tween.isActive()) {
a[cnt++] = tween;
}
}
return a;
};
p.getLabelAfter = function(time) {
if (!time) if (time !== 0) { //faster than isNan()
time = this._time;
}
var labels = this.getLabelsArray(),
l = labels.length,
i;
for (i = 0; i < l; i++) {
if (labels[i].time > time) {
return labels[i].name;
}
}
return null;
};
p.getLabelBefore = function(time) {
if (time == null) {
time = this._time;
}
var labels = this.getLabelsArray(),
i = labels.length;
while (--i > -1) {
if (labels[i].time < time) {
return labels[i].name;
}
}
return null;
};
p.getLabelsArray = function() {
var a = [],
cnt = 0,
p;
for (p in this._labels) {
a[cnt++] = {time:this._labels[p], name:p};
}
a.sort(function(a,b) {
return a.time - b.time;
});
return a;
};
p.invalidate = function() {
this._locked = false; //unlock and set cycle in case invalidate() is called from inside an onRepeat
return TimelineLite.prototype.invalidate.call(this);
};
//---- GETTERS / SETTERS -------------------------------------------------------------------------------------------------------
p.progress = function(value, suppressEvents) {
return (!arguments.length) ? (this._time / this.duration()) || 0 : this.totalTime( this.duration() * ((this._yoyo && (this._cycle & 1) !== 0) ? 1 - value : value) + (this._cycle * (this._duration + this._repeatDelay)), suppressEvents);
};
p.totalProgress = function(value, suppressEvents) {
return (!arguments.length) ? (this._totalTime / this.totalDuration()) || 0 : this.totalTime( this.totalDuration() * value, suppressEvents);
};
p.totalDuration = function(value) {
if (!arguments.length) {
if (this._dirty) {
TimelineLite.prototype.totalDuration.call(this); //just forces refresh
//Instead of Infinity, we use 999999999999 so that we can accommodate reverses.
this._totalDuration = (this._repeat === -1) ? 999999999999 : this._duration * (this._repeat + 1) + (this._repeatDelay * this._repeat);
}
return this._totalDuration;
}
return (this._repeat === -1 || !value) ? this : this.timeScale( this.totalDuration() / value );
};
p.time = function(value, suppressEvents) {
if (!arguments.length) {
return this._time;
}
if (this._dirty) {
this.totalDuration();
}
var duration = this._duration,
cycle = this._cycle,
cycleDur = cycle * (duration * this._repeatDelay);
if (value > duration) {
value = duration;
}
return this.totalTime((this._yoyo && (cycle & 1)) ? duration - value + cycleDur : this._repeat ? value + cycleDur : value, suppressEvents);
};
p.repeat = function(value) {
if (!arguments.length) {
return this._repeat;
}
this._repeat = value;
return this._uncache(true);
};
p.repeatDelay = function(value) {
if (!arguments.length) {
return this._repeatDelay;
}
this._repeatDelay = value;
return this._uncache(true);
};
p.yoyo = function(value) {
if (!arguments.length) {
return this._yoyo;
}
this._yoyo = value;
return this;
};
p.currentLabel = function(value) {
if (!arguments.length) {
return this.getLabelBefore(this._time + _tinyNum);
}
return this.seek(value, true);
};
return TimelineMax;
}, true);
export var TimelineMax = globals.TimelineMax;
export { TimelineLite, TimelineMax as default };

1975
lib/3rdparty/gsap/src/esm/TweenLite.js vendored Normal file

File diff suppressed because it is too large Load Diff

30
lib/3rdparty/gsap/src/esm/TweenMax.js vendored Normal file
View File

@ -0,0 +1,30 @@
/*!
* VERSION: 2.1.0
* DATE: 2019-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
/* eslint-disable */
import TweenLite, { TweenPlugin, Ease, Power0, Power1, Power2, Power3, Power4, Linear } from "./TweenLite.js";
import TweenMaxBase from "./TweenMaxBase.js";
import CSSPlugin from "./CSSPlugin.js";
import AttrPlugin from "./AttrPlugin.js";
import RoundPropsPlugin from "./RoundPropsPlugin.js";
import DirectionalRotationPlugin from "./DirectionalRotationPlugin.js";
import TimelineLite from "./TimelineLite.js";
import TimelineMax from "./TimelineMax.js";
import BezierPlugin from "./BezierPlugin.js";
import { Back, Elastic, Bounce, RoughEase, SlowMo, SteppedEase, Circ, Expo, Sine, ExpoScaleEase } from "./EasePack.js";
//the following two lines are designed to prevent tree shaking of the classes that were historically included with TweenMax (otherwise, folks would have to reference CSSPlugin, for example, to ensure their CSS-related animations worked)
export var TweenMax = TweenMaxBase;
TweenMax._autoActivated = [TimelineLite, TimelineMax, CSSPlugin, AttrPlugin, BezierPlugin, RoundPropsPlugin, DirectionalRotationPlugin, Back, Elastic, Bounce, RoughEase, SlowMo, SteppedEase, Circ, Expo, Sine, ExpoScaleEase];
export { TweenMax as default };
export { TweenLite, TimelineLite, TimelineMax, CSSPlugin, AttrPlugin, BezierPlugin, DirectionalRotationPlugin, RoundPropsPlugin, TweenPlugin, Ease, Power0, Power1, Power2, Power3, Power4, Linear, Back, Elastic, Bounce, RoughEase, SlowMo, SteppedEase, Circ, Expo, Sine, ExpoScaleEase };

View File

@ -0,0 +1,671 @@
/*!
* VERSION: 2.1.0
* DATE: 2019-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
/* eslint-disable */
import TweenLite, { _gsScope, globals, Animation, SimpleTimeline, Ease, Power0, Power1, Power2, Power3, Power4, Linear } from "./TweenLite.js";
_gsScope._gsDefine("TweenMax", ["core.Animation","core.SimpleTimeline","TweenLite"], function() {
var _slice = function(a) { //don't use [].slice because that doesn't work in IE8 with a NodeList that's returned by querySelectorAll()
var b = [],
l = a.length,
i;
for (i = 0; i !== l; b.push(a[i++]));
return b;
},
_applyCycle = function(vars, targets, i) {
var alt = vars.cycle,
p, val;
for (p in alt) {
val = alt[p];
vars[p] = (typeof(val) === "function") ? val(i, targets[i], targets) : val[i % val.length];
}
delete vars.cycle;
},
//for distributing values across an array. Can accept a number, a function or (most commonly) a function which can contain the following properties: {base, amount, from, ease, grid, axis, length}. Returns a function that expects the following parameters: index, target, array. Recognizes the following
_distribute = function(v) {
if (typeof(v) === "function") {
return v;
}
var vars = isNaN(v) ? v : {n:1, from:(v < 0) ? ((v = -v) && "end") : 0}, //n:1 is just to indicate v was a number; we leverage that later to set v according to the length we get. If a number is passed in, we treat it like the old stagger value where 0.1, for example, would mean that things would be distributed with 0.1 between each element in the array rather than a total "amount" that's chunked out among them all.
ease = vars.ease,
from = vars.from || 0,
base = vars.base || 0,
cache = {},
isFromKeyword = isNaN(from),
axis = vars.axis,
ratio = {center:0.5, end:1}[from] || 0;
return function(i, target, a) {
var l = (a || vars).length,
distances = cache[l],
originX, originY, x, y, d, j, max, min, wrap;
if (!distances) {
wrap = (vars.grid === "auto") ? 0 : (vars.grid || [Infinity])[0];
if (!wrap) {
max = -Infinity;
while (max < (max = a[wrap++].getBoundingClientRect().left) && wrap < l) { }
wrap--;
}
distances = cache[l] = [];
originX = isFromKeyword ? (Math.min(wrap, l) * ratio) - 0.5 : from % wrap;
originY = isFromKeyword ? l * ratio / wrap - 0.5 : (from / wrap) | 0;
max = 0;
min = Infinity;
for (j = 0; j < l; j++) {
x = (j % wrap) - originX;
y = originY - ((j / wrap) | 0);
distances[j] = d = !axis ? Math.sqrt(x * x + y * y) : Math.abs((axis === "y") ? y : x);
if (d > max) {
max = d;
}
if (d < min) {
min = d;
}
}
distances.max = max - min;
distances.min = min;
distances.v = vars.n ? l * (v || 0) : vars.amount;
}
l = (distances[i] - distances.min) / distances.max;
return base + (ease ? ease.getRatio(l) : l) * distances.v;
};
},
TweenMax = function(target, duration, vars) {
TweenLite.call(this, target, duration, vars);
this._cycle = 0;
this._yoyo = (this.vars.yoyo === true || !!this.vars.yoyoEase);
this._repeat = this.vars.repeat || 0;
this._repeatDelay = this.vars.repeatDelay || 0;
if (this._repeat) {
this._uncache(true); //ensures that if there is any repeat, the totalDuration will get recalculated to accurately report it.
}
this.render = TweenMax.prototype.render; //speed optimization (avoid prototype lookup on this "hot" method)
},
_tinyNum = 0.00000001,
TweenLiteInternals = TweenLite._internals,
_isSelector = TweenLiteInternals.isSelector,
_isArray = TweenLiteInternals.isArray,
p = TweenMax.prototype = TweenLite.to({}, 0.1, {}),
_blankArray = [];
TweenMax.version = "2.1.0";
p.constructor = TweenMax;
p.kill()._gc = false;
TweenMax.killTweensOf = TweenMax.killDelayedCallsTo = TweenLite.killTweensOf;
TweenMax.getTweensOf = TweenLite.getTweensOf;
TweenMax.lagSmoothing = TweenLite.lagSmoothing;
TweenMax.ticker = TweenLite.ticker;
TweenMax.render = TweenLite.render;
TweenMax.distribute = _distribute;
p.invalidate = function() {
this._yoyo = (this.vars.yoyo === true || !!this.vars.yoyoEase);
this._repeat = this.vars.repeat || 0;
this._repeatDelay = this.vars.repeatDelay || 0;
this._yoyoEase = null;
this._uncache(true);
return TweenLite.prototype.invalidate.call(this);
};
p.updateTo = function(vars, resetDuration) {
var self = this,
curRatio = self.ratio,
immediate = self.vars.immediateRender || vars.immediateRender,
p;
if (resetDuration && self._startTime < self._timeline._time) {
self._startTime = self._timeline._time;
self._uncache(false);
if (self._gc) {
self._enabled(true, false);
} else {
self._timeline.insert(self, self._startTime - self._delay); //ensures that any necessary re-sequencing of Animations in the timeline occurs to make sure the rendering order is correct.
}
}
for (p in vars) {
self.vars[p] = vars[p];
}
if (self._initted || immediate) {
if (resetDuration) {
self._initted = false;
if (immediate) {
self.render(0, true, true);
}
} else {
if (self._gc) {
self._enabled(true, false);
}
if (self._notifyPluginsOfEnabled && self._firstPT) {
TweenLite._onPluginEvent("_onDisable", self); //in case a plugin like MotionBlur must perform some cleanup tasks
}
if (self._time / self._duration > 0.998) { //if the tween has finished (or come extremely close to finishing), we just need to rewind it to 0 and then render it again at the end which forces it to re-initialize (parsing the new vars). We allow tweens that are close to finishing (but haven't quite finished) to work this way too because otherwise, the values are so small when determining where to project the starting values that binary math issues creep in and can make the tween appear to render incorrectly when run backwards.
var prevTime = self._totalTime;
self.render(0, true, false);
self._initted = false;
self.render(prevTime, true, false);
} else {
self._initted = false;
self._init();
if (self._time > 0 || immediate) {
var inv = 1 / (1 - curRatio),
pt = self._firstPT, endValue;
while (pt) {
endValue = pt.s + pt.c;
pt.c *= inv;
pt.s = endValue - pt.c;
pt = pt._next;
}
}
}
}
}
return self;
};
p.render = function(time, suppressEvents, force) {
if (!this._initted) if (this._duration === 0 && this.vars.repeat) { //zero duration tweens that render immediately have render() called from TweenLite's constructor, before TweenMax's constructor has finished setting _repeat, _repeatDelay, and _yoyo which are critical in determining totalDuration() so we need to call invalidate() which is a low-kb way to get those set properly.
this.invalidate();
}
var self = this,
totalDur = (!self._dirty) ? self._totalDuration : self.totalDuration(),
prevTime = self._time,
prevTotalTime = self._totalTime,
prevCycle = self._cycle,
duration = self._duration,
prevRawPrevTime = self._rawPrevTime,
isComplete, callback, pt, cycleDuration, r, type, pow, rawPrevTime, yoyoEase;
if (time >= totalDur - _tinyNum && time >= 0) { //to work around occasional floating point math artifacts.
self._totalTime = totalDur;
self._cycle = self._repeat;
if (self._yoyo && (self._cycle & 1) !== 0) {
self._time = 0;
self.ratio = self._ease._calcEnd ? self._ease.getRatio(0) : 0;
} else {
self._time = duration;
self.ratio = self._ease._calcEnd ? self._ease.getRatio(1) : 1;
}
if (!self._reversed) {
isComplete = true;
callback = "onComplete";
force = (force || self._timeline.autoRemoveChildren); //otherwise, if the animation is unpaused/activated after it's already finished, it doesn't get removed from the parent timeline.
}
if (duration === 0) if (self._initted || !self.vars.lazy || force) { //zero-duration tweens are tricky because we must discern the momentum/direction of time in order to determine whether the starting values should be rendered or the ending values. If the "playhead" of its timeline goes past the zero-duration tween in the forward direction or lands directly on it, the end values should be rendered, but if the timeline's "playhead" moves past it in the backward direction (from a postitive time to a negative time), the starting values must be rendered.
if (self._startTime === self._timeline._duration) { //if a zero-duration tween is at the VERY end of a timeline and that timeline renders at its end, it will typically add a tiny bit of cushion to the render time to prevent rounding errors from getting in the way of tweens rendering their VERY end. If we then reverse() that timeline, the zero-duration tween will trigger its onReverseComplete even though technically the playhead didn't pass over it again. It's a very specific edge case we must accommodate.
time = 0;
}
if (prevRawPrevTime < 0 || (time <= 0 && time >= -_tinyNum) || (prevRawPrevTime === _tinyNum && self.data !== "isPause")) if (prevRawPrevTime !== time) { //note: when this.data is "isPause", it's a callback added by addPause() on a timeline that we should not be triggered when LEAVING its exact start time. In other words, tl.addPause(1).play(1) shouldn't pause.
force = true;
if (prevRawPrevTime > _tinyNum) {
callback = "onReverseComplete";
}
}
self._rawPrevTime = rawPrevTime = (!suppressEvents || time || prevRawPrevTime === time) ? time : _tinyNum; //when the playhead arrives at EXACTLY time 0 (right on top) of a zero-duration tween, we need to discern if events are suppressed so that when the playhead moves again (next time), it'll trigger the callback. If events are NOT suppressed, obviously the callback would be triggered in this render. Basically, the callback should fire either when the playhead ARRIVES or LEAVES this exact spot, not both. Imagine doing a timeline.seek(0) and there's a callback that sits at 0. Since events are suppressed on that seek() by default, nothing will fire, but when the playhead moves off of that position, the callback should fire. This behavior is what people intuitively expect. We set the _rawPrevTime to be a precise tiny number to indicate this scenario rather than using another property/variable which would increase memory usage. This technique is less readable, but more efficient.
}
} else if (time < _tinyNum) { //to work around occasional floating point math artifacts, round super small values to 0.
self._totalTime = self._time = self._cycle = 0;
self.ratio = self._ease._calcEnd ? self._ease.getRatio(0) : 0;
if (prevTotalTime !== 0 || (duration === 0 && prevRawPrevTime > 0)) {
callback = "onReverseComplete";
isComplete = self._reversed;
}
if (time > -_tinyNum) {
time = 0;
} else if (time < 0) {
self._active = false;
if (duration === 0) if (self._initted || !self.vars.lazy || force) { //zero-duration tweens are tricky because we must discern the momentum/direction of time in order to determine whether the starting values should be rendered or the ending values. If the "playhead" of its timeline goes past the zero-duration tween in the forward direction or lands directly on it, the end values should be rendered, but if the timeline's "playhead" moves past it in the backward direction (from a postitive time to a negative time), the starting values must be rendered.
if (prevRawPrevTime >= 0) {
force = true;
}
self._rawPrevTime = rawPrevTime = (!suppressEvents || time || prevRawPrevTime === time) ? time : _tinyNum; //when the playhead arrives at EXACTLY time 0 (right on top) of a zero-duration tween, we need to discern if events are suppressed so that when the playhead moves again (next time), it'll trigger the callback. If events are NOT suppressed, obviously the callback would be triggered in this render. Basically, the callback should fire either when the playhead ARRIVES or LEAVES this exact spot, not both. Imagine doing a timeline.seek(0) and there's a callback that sits at 0. Since events are suppressed on that seek() by default, nothing will fire, but when the playhead moves off of that position, the callback should fire. This behavior is what people intuitively expect. We set the _rawPrevTime to be a precise tiny number to indicate this scenario rather than using another property/variable which would increase memory usage. This technique is less readable, but more efficient.
}
}
if (!self._initted) { //if we render the very beginning (time == 0) of a fromTo(), we must force the render (normal tweens wouldn't need to render at a time of 0 when the prevTime was also 0). This is also mandatory to make sure overwriting kicks in immediately.
force = true;
}
} else {
self._totalTime = self._time = time;
if (self._repeat !== 0) {
cycleDuration = duration + self._repeatDelay;
self._cycle = (self._totalTime / cycleDuration) >> 0; //originally _totalTime % cycleDuration but floating point errors caused problems, so I normalized it. (4 % 0.8 should be 0 but some browsers report it as 0.79999999!)
if (self._cycle !== 0) if (self._cycle === self._totalTime / cycleDuration && prevTotalTime <= time) {
self._cycle--; //otherwise when rendered exactly at the end time, it will act as though it is repeating (at the beginning)
}
self._time = self._totalTime - (self._cycle * cycleDuration);
if (self._yoyo) if ((self._cycle & 1) !== 0) {
self._time = duration - self._time;
yoyoEase = self._yoyoEase || self.vars.yoyoEase; //note: we don't set this._yoyoEase in _init() like we do other properties because it's TweenMax-specific and doing it here allows us to optimize performance (most tweens don't have a yoyoEase). Note that we also must skip the this.ratio calculation further down right after we _init() in this function, because we're doing it here.
if (yoyoEase) {
if (!self._yoyoEase) {
if (yoyoEase === true && !self._initted) { //if it's not initted and yoyoEase is true, this._ease won't have been populated yet so we must discern it here.
yoyoEase = self.vars.ease;
self._yoyoEase = yoyoEase = !yoyoEase ? TweenLite.defaultEase : (yoyoEase instanceof Ease) ? yoyoEase : (typeof(yoyoEase) === "function") ? new Ease(yoyoEase, self.vars.easeParams) : Ease.map[yoyoEase] || TweenLite.defaultEase;
} else {
self._yoyoEase = yoyoEase = (yoyoEase === true) ? self._ease : (yoyoEase instanceof Ease) ? yoyoEase : Ease.map[yoyoEase];
}
}
self.ratio = yoyoEase ? 1 - yoyoEase.getRatio((duration - self._time) / duration) : 0;
}
}
if (self._time > duration) {
self._time = duration;
} else if (self._time < 0) {
self._time = 0;
}
}
if (self._easeType && !yoyoEase) {
r = self._time / duration;
type = self._easeType;
pow = self._easePower;
if (type === 1 || (type === 3 && r >= 0.5)) {
r = 1 - r;
}
if (type === 3) {
r *= 2;
}
if (pow === 1) {
r *= r;
} else if (pow === 2) {
r *= r * r;
} else if (pow === 3) {
r *= r * r * r;
} else if (pow === 4) {
r *= r * r * r * r;
}
self.ratio = (type === 1) ? 1 - r : (type === 2) ? r : (self._time / duration < 0.5) ? r / 2 : 1 - (r / 2);
} else if (!yoyoEase) {
self.ratio = self._ease.getRatio(self._time / duration);
}
}
if (prevTime === self._time && !force && prevCycle === self._cycle) {
if (prevTotalTime !== self._totalTime) if (self._onUpdate) if (!suppressEvents) { //so that onUpdate fires even during the repeatDelay - as long as the totalTime changed, we should trigger onUpdate.
self._callback("onUpdate");
}
return;
} else if (!self._initted) {
self._init();
if (!self._initted || self._gc) { //immediateRender tweens typically won't initialize until the playhead advances (_time is greater than 0) in order to ensure that overwriting occurs properly. Also, if all of the tweening properties have been overwritten (which would cause _gc to be true, as set in _init()), we shouldn't continue otherwise an onStart callback could be called for example.
return;
} else if (!force && self._firstPT && ((self.vars.lazy !== false && self._duration) || (self.vars.lazy && !self._duration))) { //we stick it in the queue for rendering at the very end of the tick - this is a performance optimization because browsers invalidate styles and force a recalculation if you read, write, and then read style data (so it's better to read/read/read/write/write/write than read/write/read/write/read/write). The down side, of course, is that usually you WANT things to render immediately because you may have code running right after that which depends on the change. Like imagine running TweenLite.set(...) and then immediately after that, creating a nother tween that animates the same property to another value; the starting values of that 2nd tween wouldn't be accurate if lazy is true.
self._time = prevTime;
self._totalTime = prevTotalTime;
self._rawPrevTime = prevRawPrevTime;
self._cycle = prevCycle;
TweenLiteInternals.lazyTweens.push(self);
self._lazy = [time, suppressEvents];
return;
}
//_ease is initially set to defaultEase, so now that init() has run, _ease is set properly and we need to recalculate the ratio. Overall this is faster than using conditional logic earlier in the method to avoid having to set ratio twice because we only init() once but renderTime() gets called VERY frequently.
if (self._time && !isComplete && !yoyoEase) {
self.ratio = self._ease.getRatio(self._time / duration);
} else if (isComplete && this._ease._calcEnd && !yoyoEase) {
self.ratio = self._ease.getRatio((self._time === 0) ? 0 : 1);
}
}
if (self._lazy !== false) {
self._lazy = false;
}
if (!self._active) if (!self._paused && self._time !== prevTime && time >= 0) {
self._active = true; //so that if the user renders a tween (as opposed to the timeline rendering it), the timeline is forced to re-render and align it with the proper time/frame on the next rendering cycle. Maybe the tween already finished but the user manually re-renders it as halfway done.
}
if (prevTotalTime === 0) {
if (self._initted === 2 && time > 0) {
self._init(); //will just apply overwriting since _initted of (2) means it was a from() tween that had immediateRender:true
}
if (self._startAt) {
if (time >= 0) {
self._startAt.render(time, true, force);
} else if (!callback) {
callback = "_dummyGS"; //if no callback is defined, use a dummy value just so that the condition at the end evaluates as true because _startAt should render AFTER the normal render loop when the time is negative. We could handle this in a more intuitive way, of course, but the render loop is the MOST important thing to optimize, so this technique allows us to avoid adding extra conditional logic in a high-frequency area.
}
}
if (self.vars.onStart) if (self._totalTime !== 0 || duration === 0) if (!suppressEvents) {
self._callback("onStart");
}
}
pt = self._firstPT;
while (pt) {
if (pt.f) {
pt.t[pt.p](pt.c * self.ratio + pt.s);
} else {
pt.t[pt.p] = pt.c * self.ratio + pt.s;
}
pt = pt._next;
}
if (self._onUpdate) {
if (time < 0) if (self._startAt && self._startTime) { //if the tween is positioned at the VERY beginning (_startTime 0) of its parent timeline, it's illegal for the playhead to go back further, so we should not render the recorded startAt values.
self._startAt.render(time, true, force); //note: for performance reasons, we tuck this conditional logic inside less traveled areas (most tweens don't have an onUpdate). We'd just have it at the end before the onComplete, but the values should be updated before any onUpdate is called, so we ALSO put it here and then if it's not called, we do so later near the onComplete.
}
if (!suppressEvents) if (self._totalTime !== prevTotalTime || callback) {
self._callback("onUpdate");
}
}
if (self._cycle !== prevCycle) if (!suppressEvents) if (!self._gc) if (self.vars.onRepeat) {
self._callback("onRepeat");
}
if (callback) if (!self._gc || force) { //check gc because there's a chance that kill() could be called in an onUpdate
if (time < 0 && self._startAt && !self._onUpdate && self._startTime) { //if the tween is positioned at the VERY beginning (_startTime 0) of its parent timeline, it's illegal for the playhead to go back further, so we should not render the recorded startAt values.
self._startAt.render(time, true, force);
}
if (isComplete) {
if (self._timeline.autoRemoveChildren) {
self._enabled(false, false);
}
self._active = false;
}
if (!suppressEvents && self.vars[callback]) {
self._callback(callback);
}
if (duration === 0 && self._rawPrevTime === _tinyNum && rawPrevTime !== _tinyNum) { //the onComplete or onReverseComplete could trigger movement of the playhead and for zero-duration tweens (which must discern direction) that land directly back on their start time, we don't want to fire again on the next render. Think of several addPause()'s in a timeline that forces the playhead to a certain spot, but what if it's already paused and another tween is tweening the "time" of the timeline? Each time it moves [forward] past that spot, it would move back, and since suppressEvents is true, it'd reset _rawPrevTime to _tinyNum so that when it begins again, the callback would fire (so ultimately it could bounce back and forth during that tween). Again, this is a very uncommon scenario, but possible nonetheless.
self._rawPrevTime = 0;
}
}
};
//---- STATIC FUNCTIONS -----------------------------------------------------------------------------------------------------------
TweenMax.to = function(target, duration, vars) {
return new TweenMax(target, duration, vars);
};
TweenMax.from = function(target, duration, vars) {
vars.runBackwards = true;
vars.immediateRender = (vars.immediateRender != false);
return new TweenMax(target, duration, vars);
};
TweenMax.fromTo = function(target, duration, fromVars, toVars) {
toVars.startAt = fromVars;
toVars.immediateRender = (toVars.immediateRender != false && fromVars.immediateRender != false);
return new TweenMax(target, duration, toVars);
};
TweenMax.staggerTo = TweenMax.allTo = function(targets, duration, vars, stagger, onCompleteAll, onCompleteAllParams, onCompleteAllScope) {
var a = [],
staggerFunc = _distribute(vars.stagger || stagger),
cycle = vars.cycle,
fromCycle = (vars.startAt || _blankArray).cycle,
l, copy, i, p;
if (!_isArray(targets)) {
if (typeof(targets) === "string") {
targets = TweenLite.selector(targets) || targets;
}
if (_isSelector(targets)) {
targets = _slice(targets);
}
}
targets = targets || [];
l = targets.length - 1;
for (i = 0; i <= l; i++) {
copy = {};
for (p in vars) {
copy[p] = vars[p];
}
if (cycle) {
_applyCycle(copy, targets, i);
if (copy.duration != null) {
duration = copy.duration;
delete copy.duration;
}
}
if (fromCycle) {
fromCycle = copy.startAt = {};
for (p in vars.startAt) {
fromCycle[p] = vars.startAt[p];
}
_applyCycle(copy.startAt, targets, i);
}
copy.delay = staggerFunc(i, targets[i], targets) + (copy.delay || 0);
if (i === l && onCompleteAll) {
copy.onComplete = function() {
if (vars.onComplete) {
vars.onComplete.apply(vars.onCompleteScope || this, arguments);
}
onCompleteAll.apply(onCompleteAllScope || vars.callbackScope || this, onCompleteAllParams || _blankArray);
};
}
a[i] = new TweenMax(targets[i], duration, copy);
}
return a;
};
TweenMax.staggerFrom = TweenMax.allFrom = function(targets, duration, vars, stagger, onCompleteAll, onCompleteAllParams, onCompleteAllScope) {
vars.runBackwards = true;
vars.immediateRender = (vars.immediateRender != false);
return TweenMax.staggerTo(targets, duration, vars, stagger, onCompleteAll, onCompleteAllParams, onCompleteAllScope);
};
TweenMax.staggerFromTo = TweenMax.allFromTo = function(targets, duration, fromVars, toVars, stagger, onCompleteAll, onCompleteAllParams, onCompleteAllScope) {
toVars.startAt = fromVars;
toVars.immediateRender = (toVars.immediateRender != false && fromVars.immediateRender != false);
return TweenMax.staggerTo(targets, duration, toVars, stagger, onCompleteAll, onCompleteAllParams, onCompleteAllScope);
};
TweenMax.delayedCall = function(delay, callback, params, scope, useFrames) {
return new TweenMax(callback, 0, {delay:delay, onComplete:callback, onCompleteParams:params, callbackScope:scope, onReverseComplete:callback, onReverseCompleteParams:params, immediateRender:false, useFrames:useFrames, overwrite:0});
};
TweenMax.set = function(target, vars) {
return new TweenMax(target, 0, vars);
};
TweenMax.isTweening = function(target) {
return (TweenLite.getTweensOf(target, true).length > 0);
};
var _getChildrenOf = function(timeline, includeTimelines) {
var a = [],
cnt = 0,
tween = timeline._first;
while (tween) {
if (tween instanceof TweenLite) {
a[cnt++] = tween;
} else {
if (includeTimelines) {
a[cnt++] = tween;
}
a = a.concat(_getChildrenOf(tween, includeTimelines));
cnt = a.length;
}
tween = tween._next;
}
return a;
},
getAllTweens = TweenMax.getAllTweens = function(includeTimelines) {
return _getChildrenOf(Animation._rootTimeline, includeTimelines).concat( _getChildrenOf(Animation._rootFramesTimeline, includeTimelines) );
};
TweenMax.killAll = function(complete, tweens, delayedCalls, timelines) {
if (tweens == null) {
tweens = true;
}
if (delayedCalls == null) {
delayedCalls = true;
}
var a = getAllTweens((timelines != false)),
l = a.length,
allTrue = (tweens && delayedCalls && timelines),
isDC, tween, i;
for (i = 0; i < l; i++) {
tween = a[i];
if (allTrue || (tween instanceof SimpleTimeline) || ((isDC = (tween.target === tween.vars.onComplete)) && delayedCalls) || (tweens && !isDC)) {
if (complete) {
tween.totalTime(tween._reversed ? 0 : tween.totalDuration());
} else {
tween._enabled(false, false);
}
}
}
};
TweenMax.killChildTweensOf = function(parent, complete) {
if (parent == null) {
return;
}
var tl = TweenLiteInternals.tweenLookup,
a, curParent, p, i, l;
if (typeof(parent) === "string") {
parent = TweenLite.selector(parent) || parent;
}
if (_isSelector(parent)) {
parent = _slice(parent);
}
if (_isArray(parent)) {
i = parent.length;
while (--i > -1) {
TweenMax.killChildTweensOf(parent[i], complete);
}
return;
}
a = [];
for (p in tl) {
curParent = tl[p].target.parentNode;
while (curParent) {
if (curParent === parent) {
a = a.concat(tl[p].tweens);
}
curParent = curParent.parentNode;
}
}
l = a.length;
for (i = 0; i < l; i++) {
if (complete) {
a[i].totalTime(a[i].totalDuration());
}
a[i]._enabled(false, false);
}
};
var _changePause = function(pause, tweens, delayedCalls, timelines) {
tweens = (tweens !== false);
delayedCalls = (delayedCalls !== false);
timelines = (timelines !== false);
var a = getAllTweens(timelines),
allTrue = (tweens && delayedCalls && timelines),
i = a.length,
isDC, tween;
while (--i > -1) {
tween = a[i];
if (allTrue || (tween instanceof SimpleTimeline) || ((isDC = (tween.target === tween.vars.onComplete)) && delayedCalls) || (tweens && !isDC)) {
tween.paused(pause);
}
}
};
TweenMax.pauseAll = function(tweens, delayedCalls, timelines) {
_changePause(true, tweens, delayedCalls, timelines);
};
TweenMax.resumeAll = function(tweens, delayedCalls, timelines) {
_changePause(false, tweens, delayedCalls, timelines);
};
TweenMax.globalTimeScale = function(value) {
var tl = Animation._rootTimeline,
t = TweenLite.ticker.time;
if (!arguments.length) {
return tl._timeScale;
}
value = value || _tinyNum; //can't allow zero because it'll throw the math off
tl._startTime = t - ((t - tl._startTime) * tl._timeScale / value);
tl = Animation._rootFramesTimeline;
t = TweenLite.ticker.frame;
tl._startTime = t - ((t - tl._startTime) * tl._timeScale / value);
tl._timeScale = Animation._rootTimeline._timeScale = value;
return value;
};
//---- GETTERS / SETTERS ----------------------------------------------------------------------------------------------------------
p.progress = function(value, suppressEvents) {
return (!arguments.length) ? this._time / this.duration() : this.totalTime( this.duration() * ((this._yoyo && (this._cycle & 1) !== 0) ? 1 - value : value) + (this._cycle * (this._duration + this._repeatDelay)), suppressEvents);
};
p.totalProgress = function(value, suppressEvents) {
return (!arguments.length) ? this._totalTime / this.totalDuration() : this.totalTime( this.totalDuration() * value, suppressEvents);
};
p.time = function(value, suppressEvents) {
if (!arguments.length) {
return this._time;
}
if (this._dirty) {
this.totalDuration();
}
var duration = this._duration,
cycle = this._cycle,
cycleDur = cycle * (duration * this._repeatDelay);
if (value > duration) {
value = duration;
}
return this.totalTime((this._yoyo && (cycle & 1)) ? duration - value + cycleDur : this._repeat ? value + cycleDur : value, suppressEvents);
};
p.duration = function(value) {
if (!arguments.length) {
return this._duration; //don't set _dirty = false because there could be repeats that haven't been factored into the _totalDuration yet. Otherwise, if you create a repeated TweenMax and then immediately check its duration(), it would cache the value and the totalDuration would not be correct, thus repeats wouldn't take effect.
}
return Animation.prototype.duration.call(this, value);
};
p.totalDuration = function(value) {
if (!arguments.length) {
if (this._dirty) {
//instead of Infinity, we use 999999999999 so that we can accommodate reverses
this._totalDuration = (this._repeat === -1) ? 999999999999 : this._duration * (this._repeat + 1) + (this._repeatDelay * this._repeat);
this._dirty = false;
}
return this._totalDuration;
}
return (this._repeat === -1) ? this : this.duration( (value - (this._repeat * this._repeatDelay)) / (this._repeat + 1) );
};
p.repeat = function(value) {
if (!arguments.length) {
return this._repeat;
}
this._repeat = value;
return this._uncache(true);
};
p.repeatDelay = function(value) {
if (!arguments.length) {
return this._repeatDelay;
}
this._repeatDelay = value;
return this._uncache(true);
};
p.yoyo = function(value) {
if (!arguments.length) {
return this._yoyo;
}
this._yoyo = value;
return this;
};
return TweenMax;
}, true);
export var TweenMax = globals.TweenMax;
export var TweenMaxBase = TweenMax;
export { TweenMax as default };
export { TweenLite, Ease, Power0, Power1, Power2, Power3, Power4, Linear };

126
lib/3rdparty/gsap/src/esm/all.js vendored Normal file
View File

@ -0,0 +1,126 @@
/*!
* VERSION: 2.1.0
* DATE: 2019-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
import TweenLite, {Ease, Power0, Power1, Power2, Power3, Power4, Linear, _gsScope} from "./TweenLite.js";
import TweenMax from "./TweenMaxBase.js";
import TimelineLite from "./TimelineLite.js";
import TimelineMax from "./TimelineMax.js";
// plugins
import AttrPlugin from "./AttrPlugin.js";
import BezierPlugin from "./BezierPlugin.js";
import ColorPropsPlugin from "./ColorPropsPlugin.js";
import CSSPlugin from "./CSSPlugin.js";
import CSSRulePlugin from "./CSSRulePlugin.js";
import DirectionalRotationPlugin from "./DirectionalRotationPlugin.js";
import EaselPlugin from "./EaselPlugin.js";
import EndArrayPlugin from "./EndArrayPlugin.js";
import ModifiersPlugin from "./ModifiersPlugin.js";
import PixiPlugin from "./PixiPlugin.js";
import RoundPropsPlugin from "./RoundPropsPlugin.js";
import ScrollToPlugin from "./ScrollToPlugin.js";
import TextPlugin from "./TextPlugin.js";
// utils
import Draggable from "./Draggable.js";
// easing
import {
Back,
Elastic,
Bounce,
RoughEase,
SlowMo,
SteppedEase,
Circ,
Expo,
Sine,
ExpoScaleEase
} from "./EasePack.js";
// bonus tools
/*
import DrawSVGPlugin from "./DrawSVGPlugin.js";
import MorphSVGPlugin from "./MorphSVGPlugin.js";
import Physics2DPlugin from "./Physics2DPlugin.js";
import PhysicsPropsPlugin from "./PhysicsPropsPlugin.js";
import ScrambleTextPlugin from "./ScrambleTextPlugin.js";
import ThrowPropsPlugin from "./ThrowPropsPlugin.js";
import GSDevTools from "./GSDevTools.js";
import SplitText from "./SplitText.js";
import CustomBounce from "./CustomBounce.js";
import CustomEase from "./CustomEase.js";
import CustomWiggle from "./CustomWiggle.js";
export {
DrawSVGPlugin,
MorphSVGPlugin,
Physics2DPlugin,
PhysicsPropsPlugin,
ScrambleTextPlugin,
ThrowPropsPlugin,
GSDevTools,
SplitText,
CustomBounce,
CustomEase,
CustomWiggle
}
*/
export {
TweenLite,
TweenMax,
TimelineLite,
TimelineMax,
_gsScope,
// plugins
AttrPlugin,
BezierPlugin,
ColorPropsPlugin,
CSSPlugin,
CSSRulePlugin,
DirectionalRotationPlugin,
EaselPlugin,
EndArrayPlugin,
ModifiersPlugin,
PixiPlugin,
RoundPropsPlugin,
ScrollToPlugin,
TextPlugin,
// utils
Draggable,
// easing
Ease,
Power0,
Power1,
Power2,
Power3,
Power4,
Linear,
Back,
Elastic,
Bounce,
RoughEase,
SlowMo,
SteppedEase,
Circ,
Expo,
Sine,
ExpoScaleEase
};

25
lib/3rdparty/gsap/src/esm/index.js vendored Normal file
View File

@ -0,0 +1,25 @@
/*!
* VERSION: 2.1.0
* DATE: 2019-02-07
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
import TweenLite, { _gsScope, TweenPlugin, Ease, Power0, Power1, Power2, Power3, Power4, Linear } from "./TweenLite.js";
import TimelineLite from "./TimelineLite.js";
import TimelineMax from "./TimelineMax.js";
import TweenMax from "./TweenMax.js";
import CSSPlugin from "./CSSPlugin.js";
import AttrPlugin from "./AttrPlugin.js";
import RoundPropsPlugin from "./RoundPropsPlugin.js";
import DirectionalRotationPlugin from "./DirectionalRotationPlugin.js";
import BezierPlugin from "./BezierPlugin.js";
import { Back, Elastic, Bounce, RoughEase, SlowMo, SteppedEase, Circ, Expo, Sine, ExpoScaleEase } from "./EasePack.js";
export { TweenMax as default };
export { TweenLite, TweenMax, TimelineLite, TimelineMax, CSSPlugin, AttrPlugin, BezierPlugin, RoundPropsPlugin, DirectionalRotationPlugin, TweenPlugin, Ease, Power0, Power1, Power2, Power3, Power4, Linear, Back, Elastic, Bounce, RoughEase, SlowMo, SteppedEase, Circ, Expo, Sine, ExpoScaleEase, _gsScope };

57
lib/3rdparty/gsap/src/esm/package.json vendored Normal file
View File

@ -0,0 +1,57 @@
{
"name": "gsap",
"version": "2.1.0",
"description": "GSAP is a JavaScript library for creating high-performance animations that work in **every** major browser (or beyond the browser). No other library delivers such advanced sequencing, reliability, API efficiency, and tight control while solving real-world problems on over 4 million sites. GSAP works around countless browser inconsistencies; your animations 'just work'. Animate CSS properties, SVG, canvas libraries, custom properties of generic objects, colors, strings...pretty much anything! At its core, GSAP is a property manipulator, updating values over time very quickly with extreme accuracy. And it's up to 20x faster than jQuery! See http://greensock.com/why-gsap/ for details about what makes GSAP so special.",
"homepage": "https://greensock.com/gsap/",
"filename": "index.js",
"module": "index.js",
"main": "index.js",
"sideEffects": [
"./TweenLite.js",
"./TweenMax.js",
"./index.js"
],
"keywords": [
"animation",
"TweenLite",
"TweenMax",
"TimelineLite",
"TimelineMax",
"GSAP",
"GreenSock",
"easing",
"EasePack",
"PixiPlugin",
"CustomEase",
"jQuery",
"jquery.gsap.js",
"Bezier",
"SVG",
"3D",
"2D",
"transform",
"morph",
"morphing",
"svg",
"tweening"
],
"browserify": {
"transform": [["babelify", { "presets": ["@babel/preset-env"] }]]
},
"maintainers": [
{
"name": "Jack Doyle",
"email": "jack@greensock.com",
"web": "https://greensock.com"
}
],
"license": "Standard 'no charge' license: https://greensock.com/standard-license. Club GreenSock members get more: https://greensock.com/licensing/. Why GreenSock doesn't employ an MIT license: https://greensock.com/why-license/",
"bugs": {
"url": "https://greensock.com/forums/"
},
"repository": {
"type": "git",
"url": "https://github.com/greensock/GreenSock-JS"
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,12 @@
/*!
* VERSION: 0.2.1
* DATE: 2018-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
var _gsScope="undefined"!=typeof module&&module.exports&&"undefined"!=typeof global?global:this||window;(_gsScope._gsQueue||(_gsScope._gsQueue=[])).push(function(){"use strict";_gsScope._gsDefine("easing.CustomBounce",["easing.CustomEase"],function(a){var b,c=function(a){var b,c=a.length,d=1/a[c-2],e=1e3;for(b=2;c>b;b+=2)a[b]=(a[b]*d*e|0)/e;a[c-2]=1},d=function(b,c){this.vars=c=c||{},c.squash&&(this.squash=new a(c.squashID||b+"-squash")),a.call(this,b),this.bounce=this,this.update(c)};return d.prototype=b=new a,b.constructor=d,b.update=function(b){b=b||this.vars;var d,e,f,g,h,i,j,k=.999,l=Math.min(k,b.strength||.7),m=l,n=(b.squash||0)/100,o=n,p=1/.03,q=.2,r=1,s=.1,t=[0,0,.07,0,.1,1,.1,1],u=[0,0,0,0,.1,0,.1,0];for(h=0;200>h&&(q*=m*((m+1)/2),r*=l*l,i=s+q,f=s+.49*q,g=1-r,d=s+r/p,e=f+.8*(f-d),n&&(s+=n,d+=n,f+=n,e+=n,i+=n,j=n/o,u.push(s-n,0,s-n,j,s-n/2,j,s,j,s,0,s,0,s,j*-.6,s+(i-s)/6,0,i,0),t.push(s-n,1,s,1,s,1),n*=l*l),t.push(s,1,d,g,f,g,e,g,i,1,i,1),l*=.95,p=r/(i-e),s=i,!(g>k));h++);if(b.endAtStart){if(f=-.1,t.unshift(f,1,f,1,-.07,0),o)for(n=2.5*o,f-=n,t.unshift(f,1,f,1,f,1),u.splice(0,6),u.unshift(f,0,f,0,f,1,f+n/2,1,f+n,1,f+n,0,f+n,0,f+n,-.6,f+n+.033,0),h=0;h<u.length;h+=2)u[h]-=f;for(h=0;h<t.length;h+=2)t[h]-=f,t[h+1]=1-t[h+1]}return n&&(c(u),u[2]="C"+u[2],this.squash||(this.squash=new a(b.squashID||this.id+"-squash")),this.squash.setData("M"+u.join(","))),c(t),t[2]="C"+t[2],this.setData("M"+t.join(","))},d.create=function(a,b){return new d(a,b)},d.version="0.2.1",d},!0)}),_gsScope._gsDefine&&_gsScope._gsQueue.pop()(),function(a){"use strict";var b=function(){return(_gsScope.GreenSockGlobals||_gsScope)[a]};"undefined"!=typeof module&&module.exports?(require("./CustomEase.min.js"),require("../TweenLite.min.js"),module.exports=b()):"function"==typeof define&&define.amd&&define(["TweenLite","CustomEase"],b)}("CustomBounce");

View File

@ -0,0 +1,12 @@
/*!
* VERSION: 0.2.2
* DATE: 2018-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
var _gsScope="undefined"!=typeof module&&module.exports&&"undefined"!=typeof global?global:this||window;(_gsScope._gsQueue||(_gsScope._gsQueue=[])).push(function(){"use strict";_gsScope._gsDefine("easing.CustomEase",["easing.Ease"],function(a){var b=/(?:(-|-=|\+=)?\d*\.?\d*(?:e[\-+]?\d+)?)[0-9]/gi,c=/[achlmqstvz]|(-?\d*\.?\d*(?:e[\-+]?\d+)?)[0-9]/gi,d=/[\+\-]?\d*\.?\d+e[\+\-]?\d+/gi,e=/[cLlsS]/g,f="CustomEase only accepts Cubic Bezier data.",g=function(a,b,c,d,e,f,h,i,j,k,l){var m,n=(a+c)/2,o=(b+d)/2,p=(c+e)/2,q=(d+f)/2,r=(e+h)/2,s=(f+i)/2,t=(n+p)/2,u=(o+q)/2,v=(p+r)/2,w=(q+s)/2,x=(t+v)/2,y=(u+w)/2,z=h-a,A=i-b,B=Math.abs((c-h)*A-(d-i)*z),C=Math.abs((e-h)*A-(f-i)*z);return k||(k=[{x:a,y:b},{x:h,y:i}],l=1),k.splice(l||k.length-1,0,{x:x,y:y}),(B+C)*(B+C)>j*(z*z+A*A)&&(m=k.length,g(a,b,n,o,t,u,x,y,j,k,l),g(x,y,v,w,r,s,h,i,j,k,l+1+(k.length-m))),k},h=function(a){var b,e,g,h,i,j,k,l,m,n,o,p=(a+"").replace(d,function(a){var b=+a;return 1e-4>b&&b>-1e-4?0:b}).match(c)||[],q=[],r=0,s=0,t=p.length,u=2;for(b=0;t>b;b++)if(m=h,isNaN(p[b])?(h=p[b].toUpperCase(),i=h!==p[b]):b--,e=+p[b+1],g=+p[b+2],i&&(e+=r,g+=s),b||(k=e,l=g),"M"===h)j&&j.length<8&&(q.length-=1,u=0),r=k=e,s=l=g,j=[e,g],u=2,q.push(j),b+=2,h="L";else if("C"===h)j||(j=[0,0]),j[u++]=e,j[u++]=g,i||(r=s=0),j[u++]=r+1*p[b+3],j[u++]=s+1*p[b+4],j[u++]=r+=1*p[b+5],j[u++]=s+=1*p[b+6],b+=6;else if("S"===h)"C"===m||"S"===m?(n=r-j[u-4],o=s-j[u-3],j[u++]=r+n,j[u++]=s+o):(j[u++]=r,j[u++]=s),j[u++]=e,j[u++]=g,i||(r=s=0),j[u++]=r+=1*p[b+3],j[u++]=s+=1*p[b+4],b+=4;else{if("L"!==h&&"Z"!==h)throw f;"Z"===h&&(e=k,g=l,j.closed=!0),("L"===h||Math.abs(r-e)>.5||Math.abs(s-g)>.5)&&(j[u++]=r+(e-r)/3,j[u++]=s+(g-s)/3,j[u++]=r+2*(e-r)/3,j[u++]=s+2*(g-s)/3,j[u++]=e,j[u++]=g,"L"===h&&(b+=2)),r=e,s=g}return q[0]},i=function(a){var b,c=a.length,d=999999999999;for(b=1;c>b;b+=6)+a[b]<d&&(d=+a[b]);return d},j=function(a,b,c){c||0===c||(c=Math.max(+a[a.length-1],+a[1]));var d,e=-1*+a[0],f=-c,g=a.length,h=1/(+a[g-2]+e),j=-b||(Math.abs(+a[g-1]-+a[1])<.01*(+a[g-2]-+a[0])?i(a)+f:+a[g-1]+f);for(j=j?1/j:-h,d=0;g>d;d+=2)a[d]=(+a[d]+e)*h,a[d+1]=(+a[d+1]+f)*j},k=function(a){var b=this.lookup[a*this.l|0]||this.lookup[this.l-1];return b.nx<a&&(b=b.n),b.y+(a-b.x)/b.cx*b.cy},l=function(b,c,d){this._calcEnd=!0,this.id=b,b&&(a.map[b]=this),this.getRatio=k,this.setData(c,d)},m=l.prototype=new a;return m.constructor=l,m.setData=function(a,c){a=a||"0,0,1,1";var d,i,k,l,m,n,o,p,q,r,s=a.match(b),t=1,u=[];if(c=c||{},r=c.precision||1,this.data=a,this.lookup=[],this.points=u,this.fast=1>=r,(e.test(a)||-1!==a.indexOf("M")&&-1===a.indexOf("C"))&&(s=h(a)),d=s.length,4===d)s.unshift(0,0),s.push(1,1),d=8;else if((d-2)%6)throw f;for((0!==+s[0]||1!==+s[d-2])&&j(s,c.height,c.originY),this.rawBezier=s,l=2;d>l;l+=6)i={x:+s[l-2],y:+s[l-1]},k={x:+s[l+4],y:+s[l+5]},u.push(i,k),g(i.x,i.y,+s[l],+s[l+1],+s[l+2],+s[l+3],k.x,k.y,1/(2e5*r),u,u.length-1);for(d=u.length,l=0;d>l;l++)o=u[l],p=u[l-1]||o,o.x>p.x||p.y!==o.y&&p.x===o.x||o===p?(p.cx=o.x-p.x,p.cy=o.y-p.y,p.n=o,p.nx=o.x,this.fast&&l>1&&Math.abs(p.cy/p.cx-u[l-2].cy/u[l-2].cx)>2&&(this.fast=!1),p.cx<t&&(p.cx?t=p.cx:(p.cx=.001,l===d-1&&(p.x-=.001,t=Math.min(t,.001),this.fast=!1)))):(u.splice(l--,1),d--);if(d=1/t+1|0,this.l=d,m=1/d,n=0,o=u[0],this.fast){for(l=0;d>l;l++)q=l*m,o.nx<q&&(o=u[++n]),i=o.y+(q-o.x)/o.cx*o.cy,this.lookup[l]={x:q,cx:m,y:i,cy:0,nx:9},l&&(this.lookup[l-1].cy=i-this.lookup[l-1].y);this.lookup[d-1].cy=u[u.length-1].y-i}else{for(l=0;d>l;l++)o.nx<l*m&&(o=u[++n]),this.lookup[l]=o;n<u.length-1&&(this.lookup[l-1]=u[u.length-2])}return this._calcEnd=1!==u[u.length-1].y||0!==u[0].y,this},m.getRatio=k,m.getSVGData=function(a){return l.getSVGData(this,a)},l.create=function(a,b,c){return new l(a,b,c)},l.version="0.2.2",l.bezierToPoints=g,l.get=function(b){return a.map[b]},l.getSVGData=function(b,c){c=c||{};var d,e,f,g,h,i,j,k,l,m,n=1e3,o=c.width||100,p=c.height||100,q=c.x||0,r=(c.y||0)+p,s=c.path;if(c.invert&&(p=-p,r=0),b=b.getRatio?b:a.map[b]||console.log("No ease found: ",b),b.rawBezier){for(d=[],j=b.rawBezier.length,f=0;j>f;f+=2)d.push(((q+b.rawBezier[f]*o)*n|0)/n+","+((r+b.rawBezier[f+1]*-p)*n|0)/n);d[0]="M"+d[0],d[1]="C"+d[1]}else for(d=["M"+q+","+r],j=Math.max(5,200*(c.precision||1)),g=1/j,j+=2,k=5/j,l=((q+g*o)*n|0)/n,m=((r+b.getRatio(g)*-p)*n|0)/n,e=(m-r)/(l-q),f=2;j>f;f++)h=((q+f*g*o)*n|0)/n,i=((r+b.getRatio(f*g)*-p)*n|0)/n,(Math.abs((i-m)/(h-l)-e)>k||f===j-1)&&(d.push(l+","+m),e=(i-m)/(h-l)),l=h,m=i;return s&&("string"==typeof s?document.querySelector(s):s).setAttribute("d",d.join(" ")),d.join(" ")},l},!0)}),_gsScope._gsDefine&&_gsScope._gsQueue.pop()(),function(a){"use strict";var b=function(){return(_gsScope.GreenSockGlobals||_gsScope)[a]};"undefined"!=typeof module&&module.exports?(require("../TweenLite.min.js"),module.exports=b()):"function"==typeof define&&define.amd&&define(["TweenLite"],b)}("CustomEase");

View File

@ -0,0 +1,12 @@
/*!
* VERSION: 0.2.1
* DATE: 2018-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
var _gsScope="undefined"!=typeof module&&module.exports&&"undefined"!=typeof global?global:this||window;(_gsScope._gsQueue||(_gsScope._gsQueue=[])).push(function(){"use strict";_gsScope._gsDefine("easing.CustomWiggle",["easing.CustomEase","easing.Ease"],function(a,b){var c,d={easeOut:new a("","M0,1,C0.7,1,0.6,0,1,0"),easeInOut:new a("","M0,0,C0.104,0,0.242,1,0.444,1,0.644,1,0.608,0,1,0"),anticipate:new a("","M0,0,C0,0.222,0.024,0.386,0.06,0.402,0.181,0.455,0.647,0.646,0.7,0.67,0.9,0.76,1,0.846,1,1"),uniform:new a("","M0,0,C0,0.95,0.01,1,0.01,1,0.01,1,1,1,1,1,1,1,1,0.01,1,0")},e=new a,f=function(c,d){return c=c.getRatio?c:b.map[c]||new a("",c),c.rawBezier||!d?c:{getRatio:function(a){return 1-c.getRatio(a)}}},g=function(b,c){this.vars=c||{},a.call(this,b),this.update(this.vars)};return g.prototype=c=new a,c.constructor=g,c.update=function(a){a=a||this.vars;var b,c,g,h,i,j,k,l,m,n=0|(a.wiggles||10),o=1/n,p=o/2,q="anticipate"===a.type,r=d[a.type]||d.easeOut,s=e,t=1e3;if(q&&(s=r,r=d.easeOut),a.timingEase&&(s=f(a.timingEase)),a.amplitudeEase&&(r=f(a.amplitudeEase,!0)),j=s.getRatio(p),k=q?-r.getRatio(p):r.getRatio(p),l=[0,0,j/4,0,j/2,k,j,k],"random"===a.type){for(l.length=4,b=s.getRatio(o),c=2*Math.random()-1,m=2;n>m;m++)p=b,k=c,b=s.getRatio(o*m),c=2*Math.random()-1,g=Math.atan2(c-l[l.length-3],b-l[l.length-4]),h=Math.cos(g)*o,i=Math.sin(g)*o,l.push(p-h,k-i,p,k,p+h,k+i);l.push(b,0,1,0)}else{for(m=1;n>m;m++)l.push(s.getRatio(p+o/2),k),p+=o,k=(k>0?-1:1)*r.getRatio(m*o),j=s.getRatio(p),l.push(s.getRatio(p-o/2),k,j,k);l.push(s.getRatio(p+o/4),k,s.getRatio(p+o/4),0,1,0)}for(m=l.length;--m>-1;)l[m]=(l[m]*t|0)/t;l[2]="C"+l[2],this.setData("M"+l.join(","))},g.create=function(a,b){return new g(a,b)},g.version="0.2.1",g.eases=d,g},!0)}),_gsScope._gsDefine&&_gsScope._gsQueue.pop()(),function(a){"use strict";var b=function(){return(_gsScope.GreenSockGlobals||_gsScope)[a]};"undefined"!=typeof module&&module.exports?(require("./CustomEase.min.js"),require("../TweenLite.min.js"),module.exports=b()):"function"==typeof define&&define.amd&&define(["TweenLite","CustomEase"],b)}("CustomWiggle");

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,14 @@
/*!
* VERSION: 0.1.13
* DATE: 2018-08-27
* UPDATES AND DOCS AT: http://greensock.com/jquery-gsap-plugin/
*
* Requires TweenLite version 1.8.0 or higher and CSSPlugin.
*
* @license Copyright (c) 2013-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
!function(a){"use strict";var b,c,d,e=a.fn.animate,f=a.fn.stop,g=!0,h=function(a){var b,c={};for(b in a)c[b]=a[b];return c},i={overwrite:1,delay:1,useFrames:1,runBackwards:1,easeParams:1,yoyo:1,immediateRender:1,repeat:1,repeatDelay:1,autoCSS:1},j=",scrollTop,scrollLeft,show,hide,toggle,",k=j,l=function(a,b){for(var c in i)i[c]&&void 0!==a[c]&&(b[c]=a[c])},m=function(a){return function(b){return a.getRatio(b)}},n={},o=function(){var e,f=window.GreenSockGlobals||window;if(b=f.TweenMax||f.TweenLite,b&&(f=f.com.greensock,c=f.plugins.CSSPlugin,n=f.easing.Ease.map||{}),!b||!c)return b=null,void(!d&&window.console&&(window.console.log("The jquery.gsap.js plugin requires the TweenMax (or at least TweenLite and CSSPlugin) JavaScript file(s)."),d=!0));if(a.easing){for(e in n)a.easing[e]=m(n[e]);o=!1}};a.fn.animate=function(d,f,i,j){if(d=d||{},o&&(o(),!b||!c))return e.call(this,d,f,i,j);if(!g||d.skipGSAP===!0||"object"==typeof f&&"function"==typeof f.step)return e.call(this,d,f,i,j);var m,p,q,r,s=a.speed(f,i,j),t={ease:n[s.easing]||(s.easing===!1?n.linear:n.swing)},u=this,v="object"==typeof f?f.specialEasing:null;for(p in d){if(m=d[p],m instanceof Array&&n[m[1]]&&(v=v||{},v[p]=m[1],m=m[0]),"show"===m||"hide"===m||"toggle"===m||-1!==k.indexOf(p)&&-1!==k.indexOf(","+p+","))return e.call(this,d,f,i,j);t[-1===p.indexOf("-")?p:a.camelCase(p)]=m}if(v){t=h(t),r=[];for(p in v)m=r[r.length]={},l(t,m),m.ease=n[v[p]]||t.ease,-1!==p.indexOf("-")&&(p=a.camelCase(p)),m[p]=t[p],delete t[p];0===r.length&&(r=null)}return q=function(c){var d,e=h(t);if(r)for(d=r.length;--d>-1;)b.to(this,a.fx.off?0:s.duration/1e3,r[d]);e.onComplete=function(){c?c():s.old&&a(this).each(s.old)},b.to(this,a.fx.off?0:s.duration/1e3,e)},s.queue!==!1?(u.queue(s.queue,q),"function"==typeof s.old&&a(u[u.length-1]).queue(s.queue,function(a){s.old.call(u),a()})):q.call(u),u},a.fn.stop=function(a,c){if(f.call(this,a,c),b){if(c)for(var d,e=b.getTweensOf(this),g=e.length;--g>-1;)d=e[g].totalTime()/e[g].totalDuration(),d>0&&1>d&&e[g].seek(e[g].totalDuration());b.killTweensOf(this)}return this},a.gsap={enabled:function(a){g=a},version:"0.1.13",legacyProps:function(a){k=j+a+","}}}(jQuery);

View File

@ -0,0 +1,12 @@
/*!
* VERSION: 0.6.1
* DATE: 2018-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
var _gsScope="undefined"!=typeof module&&module.exports&&"undefined"!=typeof global?global:this||window;(_gsScope._gsQueue||(_gsScope._gsQueue=[])).push(function(){"use strict";_gsScope._gsDefine.plugin({propName:"attr",API:2,version:"0.6.1",init:function(a,b,c,d){var e,f;if("function"!=typeof a.setAttribute)return!1;for(e in b)f=b[e],"function"==typeof f&&(f=f(d,a)),this._addTween(a,"setAttribute",a.getAttribute(e)+"",f+"",e,!1,e),this._overwriteProps.push(e);return!0}})}),_gsScope._gsDefine&&_gsScope._gsQueue.pop()(),function(a){"use strict";var b=function(){return(_gsScope.GreenSockGlobals||_gsScope)[a]};"undefined"!=typeof module&&module.exports?(require("../TweenLite.min.js"),module.exports=b()):"function"==typeof define&&define.amd&&define(["TweenLite"],b)}("AttrPlugin");

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,12 @@
/*!
* VERSION: 0.6.6
* DATE: 2018-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
var _gsScope="undefined"!=typeof module&&module.exports&&"undefined"!=typeof global?global:this||window;(_gsScope._gsQueue||(_gsScope._gsQueue=[])).push(function(){"use strict";_gsScope._gsDefine("plugins.CSSRulePlugin",["plugins.TweenPlugin","TweenLite","plugins.CSSPlugin"],function(a,b,c){var d=function(){a.call(this,"cssRule"),this._overwriteProps.length=0},e=_gsScope.document,f=c.prototype.setRatio,g=d.prototype=new c;return g._propName="cssRule",g.constructor=d,d.version="0.6.6",d.API=2,d.getRule=function(a){var b,c,d,f,g=e.all?"rules":"cssRules",h=e.styleSheets,i=h.length,j=":"===a.charAt(0);for(a=(j?"":",")+a.split("::").join(":").toLowerCase()+",",j&&(f=[]);--i>-1;){try{if(c=h[i][g],!c)continue;b=c.length}catch(k){console.log(k);continue}for(;--b>-1;)if(d=c[b],d.selectorText&&-1!==(","+d.selectorText.split("::").join(":").toLowerCase()+",").indexOf(a)){if(!j)return d.style;f.push(d.style)}}return f},g._onInitTween=function(a,b,d){if(void 0===a.cssText)return!1;var f=a._gsProxy=a._gsProxy||e.createElement("div");return this._ss=a,this._proxy=f.style,f.style.cssText=a.cssText,c.prototype._onInitTween.call(this,f,b,d),!0},g.setRatio=function(a){f.call(this,a),this._ss.cssText=this._proxy.cssText},a.activate([d]),d},!0)}),_gsScope._gsDefine&&_gsScope._gsQueue.pop()(),function(a){"use strict";var b=function(){return(_gsScope.GreenSockGlobals||_gsScope)[a]};"undefined"!=typeof module&&module.exports?(require("../TweenLite.min.js"),module.exports=b()):"function"==typeof define&&define.amd&&define(["TweenLite"],b)}("CSSRulePlugin");

View File

@ -0,0 +1,12 @@
/*!
* VERSION: 1.5.3
* DATE: 2018-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
var _gsScope="undefined"!=typeof module&&module.exports&&"undefined"!=typeof global?global:this||window;(_gsScope._gsQueue||(_gsScope._gsQueue=[])).push(function(){"use strict";var a,b,c=/(\d|\.)+/g,d=/(?:\d|\-\d|\.\d|\-\.\d|\+=\d|\-=\d|\+=.\d|\-=\.\d)+/g,e={aqua:[0,255,255],lime:[0,255,0],silver:[192,192,192],black:[0,0,0],maroon:[128,0,0],teal:[0,128,128],blue:[0,0,255],navy:[0,0,128],white:[255,255,255],fuchsia:[255,0,255],olive:[128,128,0],yellow:[255,255,0],orange:[255,165,0],gray:[128,128,128],purple:[128,0,128],green:[0,128,0],red:[255,0,0],pink:[255,192,203],cyan:[0,255,255],transparent:[255,255,255,0]},f=function(a,b,c){return a=0>a?a+1:a>1?a-1:a,255*(1>6*a?b+(c-b)*a*6:.5>a?c:2>3*a?b+(c-b)*(2/3-a)*6:b)+.5|0},g=function(a,b){var g,h,i,j,k,l,m,n,o,p,q;if(a)if("number"==typeof a)g=[a>>16,a>>8&255,255&a];else{if(","===a.charAt(a.length-1)&&(a=a.substr(0,a.length-1)),e[a])g=e[a];else if("#"===a.charAt(0))4===a.length&&(h=a.charAt(1),i=a.charAt(2),j=a.charAt(3),a="#"+h+h+i+i+j+j),a=parseInt(a.substr(1),16),g=[a>>16,a>>8&255,255&a];else if("hsl"===a.substr(0,3))if(g=q=a.match(c),b){if(-1!==a.indexOf("="))return a.match(d)}else k=Number(g[0])%360/360,l=Number(g[1])/100,m=Number(g[2])/100,i=.5>=m?m*(l+1):m+l-m*l,h=2*m-i,g.length>3&&(g[3]=Number(g[3])),g[0]=f(k+1/3,h,i),g[1]=f(k,h,i),g[2]=f(k-1/3,h,i);else g=a.match(c)||e.transparent;g[0]=Number(g[0]),g[1]=Number(g[1]),g[2]=Number(g[2]),g.length>3&&(g[3]=Number(g[3]))}else g=e.black;return b&&!q&&(h=g[0]/255,i=g[1]/255,j=g[2]/255,n=Math.max(h,i,j),o=Math.min(h,i,j),m=(n+o)/2,n===o?k=l=0:(p=n-o,l=m>.5?p/(2-n-o):p/(n+o),k=n===h?(i-j)/p+(j>i?6:0):n===i?(j-h)/p+2:(h-i)/p+4,k*=60),g[0]=k+.5|0,g[1]=100*l+.5|0,g[2]=100*m+.5|0),g},h=function(a,b){var c,d,e,f=(a+"").match(j)||[],h=0,i="";if(!f.length)return a;for(c=0;c<f.length;c++)d=f[c],e=a.substr(h,a.indexOf(d,h)-h),h+=e.length+d.length,d=g(d,b),3===d.length&&d.push(1),i+=e+(b?"hsla("+d[0]+","+d[1]+"%,"+d[2]+"%,"+d[3]:"rgba("+d.join(","))+")";return i+a.substr(h)},i=(_gsScope.GreenSockGlobals||_gsScope).TweenLite,j="(?:\\b(?:(?:rgb|rgba|hsl|hsla)\\(.+?\\))|\\B#(?:[0-9a-f]{3}){1,2}\\b",k=_gsScope._gsDefine.plugin({propName:"colorProps",version:"1.5.3",priority:-1,API:2,global:!0,init:function(a,c,d,e){var f,h,i,j;this._target=a,this._proxy=h="NUMBER"===(c.format+"").toUpperCase()?{}:0;for(f in c)"format"!==f&&(h?(this._firstNumPT=i={_next:this._firstNumPT,t:a,p:f,f:"function"==typeof a[f]},h[f]="rgb("+g(i.f?a[f.indexOf("set")||"function"!=typeof a["get"+f.substr(3)]?f:"get"+f.substr(3)]():a[f]).join(",")+")",j=c[f],"function"==typeof j&&(j=j(e,a)),this._addTween(h,f,"get","number"==typeof j?"rgb("+g(j,!1).join(",")+")":j,f,null,null,b)):this._addTween(a,f,"get",c[f],f,null,null,b,e));return!0},set:function(a){var b,c=this._firstNumPT;for(this._super.setRatio.call(this,a);c;)b=g(this._proxy[c.p],!1),b=b[0]<<16|b[1]<<8|b[2],c.f?this._target[c.p](b):this._target[c.p]=b,c=c._next}});for(a in e)j+="|"+a+"\\b";j=new RegExp(j+")","gi"),k.colorStringFilter=b=function(a){var b,c=a[0]+" "+a[1];j.lastIndex=0,j.test(c)&&(b=-1!==c.indexOf("hsl(")||-1!==c.indexOf("hsla("),a[0]=h(a[0],b),a[1]=h(a[1],b))},i.defaultStringFilter||(i.defaultStringFilter=k.colorStringFilter),k.parseColor=g,a=k.prototype,a._firstNumPT=null,a._kill=function(b){for(var c,d=this._firstNumPT;d;)d.p in b?(d===a._firstNumPT&&(this._firstNumPT=d._next),c&&(c._next=d._next)):c=d,d=d._next;return this._super._kill(b)}}),_gsScope._gsDefine&&_gsScope._gsQueue.pop()(),function(a){"use strict";var b=function(){return(_gsScope.GreenSockGlobals||_gsScope)[a]};"undefined"!=typeof module&&module.exports?(require("../TweenLite.min.js"),module.exports=b()):"function"==typeof define&&define.amd&&define(["TweenLite"],b)}("ColorPropsPlugin");

View File

@ -0,0 +1,12 @@
/*!
* VERSION: 0.3.1
* DATE: 2018-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
var _gsScope="undefined"!=typeof module&&module.exports&&"undefined"!=typeof global?global:this||window;(_gsScope._gsQueue||(_gsScope._gsQueue=[])).push(function(){"use strict";_gsScope._gsDefine.plugin({propName:"directionalRotation",version:"0.3.1",API:2,init:function(a,b,c,d){"object"!=typeof b&&(b={rotation:b}),this.finals={};var e,f,g,h,i,j,k=b.useRadians===!0?2*Math.PI:360,l=1e-6;for(e in b)"useRadians"!==e&&(h=b[e],"function"==typeof h&&(h=h(d,a)),j=(h+"").split("_"),f=j[0],g=parseFloat("function"!=typeof a[e]?a[e]:a[e.indexOf("set")||"function"!=typeof a["get"+e.substr(3)]?e:"get"+e.substr(3)]()),h=this.finals[e]="string"==typeof f&&"="===f.charAt(1)?g+parseInt(f.charAt(0)+"1",10)*Number(f.substr(2)):Number(f)||0,i=h-g,j.length&&(f=j.join("_"),-1!==f.indexOf("short")&&(i%=k,i!==i%(k/2)&&(i=0>i?i+k:i-k)),-1!==f.indexOf("_cw")&&0>i?i=(i+9999999999*k)%k-(i/k|0)*k:-1!==f.indexOf("ccw")&&i>0&&(i=(i-9999999999*k)%k-(i/k|0)*k)),(i>l||-l>i)&&(this._addTween(a,e,g,g+i,e),this._overwriteProps.push(e)));return!0},set:function(a){var b;if(1!==a)this._super.setRatio.call(this,a);else for(b=this._firstPT;b;)b.f?b.t[b.p](this.finals[b.p]):b.t[b.p]=this.finals[b.p],b=b._next}})._autoCSS=!0}),_gsScope._gsDefine&&_gsScope._gsQueue.pop()(),function(a){"use strict";var b=function(){return(_gsScope.GreenSockGlobals||_gsScope)[a]};"undefined"!=typeof module&&module.exports?(require("../TweenLite.min.js"),module.exports=b()):"function"==typeof define&&define.amd&&define(["TweenLite"],b)}("DirectionalRotationPlugin");

View File

@ -0,0 +1,13 @@
/*!
* VERSION: 0.2.1
* DATE: 2019-02-07
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* DrawSVGPlugin is a Club GreenSock membership benefit; You must have a valid membership to use
* this code without violating the terms of use. Visit http://greensock.com/club/ to sign up or get more details.
* This work is subject to the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
var _gsScope="undefined"!=typeof module&&module.exports&&"undefined"!=typeof global?global:this||window;(_gsScope._gsQueue||(_gsScope._gsQueue=[])).push(function(){"use strict";function a(a,b,c,d,e,f){return c=(parseFloat(c||0)-parseFloat(a||0))*e,d=(parseFloat(d||0)-parseFloat(b||0))*f,Math.sqrt(c*c+d*d)}function b(a){return"string"!=typeof a&&a.nodeType||(a=_gsScope.TweenLite.selector(a),a.length&&(a=a[0])),a}function c(a,b,c){var d,e,f=a.indexOf(" ");return-1===f?(d=void 0!==c?c+"":a,e=a):(d=a.substr(0,f),e=a.substr(f+1)),d=-1!==d.indexOf("%")?parseFloat(d)/100*b:parseFloat(d),e=-1!==e.indexOf("%")?parseFloat(e)/100*b:parseFloat(e),d>e?[e,d]:[d,e]}function d(c){if(!c)return 0;c=b(c);var d,e,f,g,h,i,k,m=c.tagName.toLowerCase(),n=1,o=1;"non-scaling-stroke"===c.getAttribute("vector-effect")&&(o=c.getScreenCTM(),n=Math.sqrt(o.a*o.a+o.b*o.b),o=Math.sqrt(o.d*o.d+o.c*o.c));try{e=c.getBBox()}catch(p){console.log("Error: Some browsers like Firefox won't report measurements of invisible elements (like display:none or masks inside defs).")}if(e&&(e.width||e.height)||!l[m]||(e={width:parseFloat(c.getAttribute(l[m][0])),height:parseFloat(c.getAttribute(l[m][1]))},"rect"!==m&&"line"!==m&&(e.width*=2,e.height*=2),"line"===m&&(e.x=parseFloat(c.getAttribute("x1")),e.y=parseFloat(c.getAttribute("y1")),e.width=Math.abs(e.width-e.x),e.height=Math.abs(e.height-e.y))),"path"===m)g=c.style.strokeDasharray,c.style.strokeDasharray="none",d=c.getTotalLength()||0,n!==o&&console.log("Warning: <path> length cannot be measured accurately when vector-effect is non-scaling-stroke and the element isn't proportionally scaled."),d*=(n+o)/2,c.style.strokeDasharray=g;else if("rect"===m)d=2*e.width*n+2*e.height*o;else if("line"===m)d=a(e.x,e.y,e.x+e.width,e.y+e.height,n,o);else if("polyline"===m||"polygon"===m)for(f=c.getAttribute("points").match(j)||[],"polygon"===m&&f.push(f[0],f[1]),d=0,h=2;h<f.length;h+=2)d+=a(f[h-2],f[h-1],f[h],f[h+1],n,o)||0;else("circle"===m||"ellipse"===m)&&(i=e.width/2*n,k=e.height/2*o,d=Math.PI*(3*(i+k)-Math.sqrt((3*i+k)*(i+3*k))));return d||0}function e(a,c){if(!a)return[0,0];a=b(a),c=c||d(a)+1;var e=i(a),f=e.strokeDasharray||"",g=parseFloat(e.strokeDashoffset),h=f.indexOf(",");return 0>h&&(h=f.indexOf(" ")),f=0>h?c:parseFloat(f.substr(0,h))||1e-5,f>c&&(f=c),[Math.max(0,-g),Math.max(0,f-g)]}var f,g=_gsScope.document,h="undefined"!=typeof window?window:g.defaultView||{getComputedStyle:function(){}},i=function(a){return h.getComputedStyle(a)},j=/(?:(-|-=|\+=)?\d*\.?\d*(?:e[\-+]?\d+)?)[0-9]/gi,k=-1!==((_gsScope.navigator||{}).userAgent||"").indexOf("Edge"),l={rect:["width","height"],circle:["r","r"],ellipse:["rx","ry"],line:["x2","y2"]};f=_gsScope._gsDefine.plugin({propName:"drawSVG",API:2,version:"0.2.1",global:!0,overwriteProps:["drawSVG"],init:function(a,b,f,g){if(!a.getBBox)return!1;var h,j,l,m,n=d(a)+1;return this._style=a.style,this._target=a,"function"==typeof b&&(b=b(g,a)),b===!0||"true"===b?b="0 100%":b?-1===(b+"").indexOf(" ")&&(b="0 "+b):b="0 0",h=e(a,n),j=c(b,n,h[0]),this._length=n+10,0===h[0]&&0===j[0]?(l=Math.max(1e-5,j[1]-n),this._dash=n+l,this._offset=n-h[1]+l,this._offsetPT=this._addTween(this,"_offset",this._offset,n-j[1]+l,"drawSVG")):(this._dash=h[1]-h[0]||1e-6,this._offset=-h[0],this._dashPT=this._addTween(this,"_dash",this._dash,j[1]-j[0]||1e-5,"drawSVG"),this._offsetPT=this._addTween(this,"_offset",this._offset,-j[0],"drawSVG")),k&&(m=i(a),m.strokeLinecap!==m.strokeLinejoin&&(j=parseFloat(m.strokeMiterlimit),this._addTween(a.style,"strokeMiterlimit",j,j+1e-4,"strokeMiterlimit"))),this._live="non-scaling-stroke"===a.getAttribute("vector-effect")||-1!==(b+"").indexOf("live"),!0},set:function(a){if(this._firstPT){if(this._live){var b,c=d(this._target)+11;c!==this._length&&(b=c/this._length,this._length=c,this._offsetPT.s*=b,this._offsetPT.c*=b,this._dashPT?(this._dashPT.s*=b,this._dashPT.c*=b):this._dash*=b)}this._super.setRatio.call(this,a),this._style.strokeDashoffset=this._offset,1===a||0===a?this._style.strokeDasharray=this._offset<.001&&this._length-this._dash<=10?"none":this._offset===this._dash?"0px, 999999px":this._dash+"px,"+this._length+"px":this._style.strokeDasharray=this._dash+"px,"+this._length+"px"}}}),f.getLength=d,f.getPosition=e}),_gsScope._gsDefine&&_gsScope._gsQueue.pop()(),function(a){"use strict";var b=function(){return(_gsScope.GreenSockGlobals||_gsScope)[a]};"undefined"!=typeof module&&module.exports?(require("../TweenLite.min.js"),module.exports=b()):"function"==typeof define&&define.amd&&define(["TweenLite"],b)}("DrawSVGPlugin");

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,12 @@
/*!
* VERSION: 0.1.3
* DATE: 2018-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
var _gsScope="undefined"!=typeof module&&module.exports&&"undefined"!=typeof global?global:this||window;(_gsScope._gsQueue||(_gsScope._gsQueue=[])).push(function(){"use strict";_gsScope._gsDefine.plugin({propName:"endArray",API:2,version:"0.1.3",init:function(a,b,c){var d,e,f=b.length,g=this.a=[];if(this.target=a,this._mod=0,!f)return!1;for(;--f>-1;)d=a[f],e=b[f],d!==e&&g.push({i:f,s:d,c:e-d});return!0},mod:function(a){"function"==typeof a.endArray&&(this._mod=a.endArray)},set:function(a){var b,c,d=this.target,e=this.a,f=e.length,g=this._mod;if(g)for(;--f>-1;)b=e[f],d[b.i]=g(b.s+b.c*a,d);else for(;--f>-1;)b=e[f],c=b.s+b.c*a,d[b.i]=1e-6>c&&c>-1e-6?0:c}})}),_gsScope._gsDefine&&_gsScope._gsQueue.pop()();

View File

@ -0,0 +1,12 @@
/*!
* VERSION: 0.0.4
* DATE: 2018-05-21
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
var _gsScope="undefined"!=typeof module&&module.exports&&"undefined"!=typeof global?global:this||window;(_gsScope._gsQueue||(_gsScope._gsQueue=[])).push(function(){"use strict";var a=function(a,b,c){var d=a.type,e=a.setRatio,f=b._tween,g=b._target;a.type=2,a.m=c,a.setRatio=function(b){var h,i,j,k=1e-6;if(1!==b||f._time!==f._duration&&0!==f._time)if(b||f._time!==f._duration&&0!==f._time||f._rawPrevTime===-1e-6)if(h=a.c*b+a.s,a.r?h=Math.round(h):k>h&&h>-k&&(h=0),d)if(1===d){for(i=a.xs0+h+a.xs1,j=1;j<a.l;j++)i+=a["xn"+j]+a["xs"+(j+1)];a.t[a.p]=c.call(f,i,g,f)}else-1===d?a.t[a.p]=c.call(f,a.xs0,g,f):e&&e.call(a,b);else a.t[a.p]=c.call(f,h+a.xs0,g,f);else 2!==d?a.t[a.p]=c.call(f,a.b,g,f):e.call(a,b);else if(2!==d)if(a.r&&-1!==d)if(h=Math.round(a.s+a.c),d){if(1===d){for(i=a.xs0+h+a.xs1,j=1;j<a.l;j++)i+=a["xn"+j]+a["xs"+(j+1)];a.t[a.p]=c.call(f,i,g,f)}}else a.t[a.p]=c.call(f,h+a.xs0,g,f);else a.t[a.p]=c.call(f,a.e,g,f);else e.call(a,b)}},b=function(b,c){var d=c._firstPT,e=b.rotation&&-1!==c._overwriteProps.join("").indexOf("bezier");for(b.scale?b.scaleX=b.scaleY=b.scale:b.rotationZ&&(b.rotation=b.rotationZ);d;)"function"==typeof b[d.p]?a(d,c,b[d.p]):e&&"bezier"===d.n&&-1!==d.plugin._overwriteProps.join("").indexOf("rotation")&&(d.data.mod=b.rotation),d=d._next},c=_gsScope._gsDefine.plugin({propName:"modifiers",version:"0.0.4",API:2,init:function(a,b,c){return this._tween=c,this._vars=b,!0},initAll:function(){var a,c,d=this._tween,e=this._vars,f=this,g=d._firstPT;if(g._modInitted)return!1;for(g._modInitted=1;g;)c=g._next,a=e[g.n],g.pg?"css"===g.t._propName?b(e,g.t):g.t!==f&&(a=e[g.t._propName],g.t._tween=d,g.t._mod("object"==typeof a?a:e)):"function"==typeof a&&(2===g.f&&g.t?(g.t._applyPT.m=a,g.t._tween=d):(this._add(g.t,g.p,g.s,g.c,a),c&&(c._prev=g._prev),g._prev?g._prev._next=c:d._firstPT===g&&(d._firstPT=c),g._next=g._prev=null,d._propLookup[g.n]=f)),g=c;return!1}}),d=c.prototype;d._add=function(a,b,c,d,e){this._addTween(a,b,c,c+d,b,e),this._overwriteProps.push(b)},d=_gsScope._gsDefine.globals.TweenLite.version.split("."),Number(d[0])<=1&&Number(d[1])<19&&_gsScope.console&&console.log("ModifiersPlugin requires GSAP 1.19.0 or later.")}),_gsScope._gsDefine&&_gsScope._gsQueue.pop()(),function(a){"use strict";var b=function(){return(_gsScope.GreenSockGlobals||_gsScope)[a]};"undefined"!=typeof module&&module.exports?(require("../TweenLite.min.js"),module.exports=b()):"function"==typeof define&&define.amd&&define(["TweenLite"],b)}("ModifiersPlugin");

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,13 @@
/*!
* VERSION: 0.2.1
* DATE: 2018-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* Physics2DPlugin is a Club GreenSock membership benefit; You must have a valid membership to use
* this code without violating the terms of use. Visit http://greensock.com/club/ to sign up or get more details.
* This work is subject to the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
var _gsScope="undefined"!=typeof module&&module.exports&&"undefined"!=typeof global?global:this||window;(_gsScope._gsQueue||(_gsScope._gsQueue=[])).push(function(){"use strict";var a=Math.PI/180,b=function(a,b,c,d,e){this.p=b,this.f="function"==typeof a[b],this.start=this.value=this.f?a[b.indexOf("set")||"function"!=typeof a["get"+b.substr(3)]?b:"get"+b.substr(3)]():parseFloat(a[b]),this.velocity=c||0,this.v=this.velocity/e,d||0===d?(this.acceleration=d,this.a=this.acceleration/(e*e)):this.acceleration=this.a=0},c=Math.random(),d=_gsScope._gsDefine.globals,e=d.com.greensock.core.Animation._rootFramesTimeline,f=_gsScope._gsDefine.plugin({propName:"physics2D",version:"0.2.1",API:2,init:function(c,d,f,g){"function"==typeof d&&(d=d(g,c)),this._target=c,this._tween=f,this._runBackwards=f.vars.runBackwards===!0,this._step=0;for(var h,i=f._timeline,j=Number(d.angle)||0,k=Number(d.velocity)||0,l=Number(d.acceleration)||0,m=d.xProp||"x",n=d.yProp||"y",o=d.accelerationAngle||0===d.accelerationAngle?Number(d.accelerationAngle):j;i._timeline;)i=i._timeline;return this._stepsPerTimeUnit=h=i===e?1:30,d.gravity&&(l=Number(d.gravity),o=90),j*=a,o*=a,this._friction=1-Number(d.friction||0),this._overwriteProps.push(m),this._overwriteProps.push(n),this._x=new b(c,m,Math.cos(j)*k,Math.cos(o)*l,h),this._y=new b(c,n,Math.sin(j)*k,Math.sin(o)*l,h),this._skipX=this._skipY=!1,!0},set:function(a){var b,c,d,e,f,g,h=this._tween._time,i=this._x,j=this._y;if(this._runBackwards===!0&&(h=this._tween._duration-h),1===this._friction)d=h*h*.5,b=i.start+(i.velocity*h+i.acceleration*d),c=j.start+(j.velocity*h+j.acceleration*d);else{if(h*=this._stepsPerTimeUnit,e=g=(0|h)-this._step,f=h%1,g>=0)for(;--g>-1;)i.v+=i.a,j.v+=j.a,i.v*=this._friction,j.v*=this._friction,i.value+=i.v,j.value+=j.v;else for(g=-g;--g>-1;)i.value-=i.v,j.value-=j.v,i.v/=this._friction,j.v/=this._friction,i.v-=i.a,j.v-=j.a;b=i.value+i.v*f,c=j.value+j.v*f,this._step+=e}this._skipX||(i.m&&(b=i.m(b,this._target)),i.f?this._target[i.p](b):this._target[i.p]=b),this._skipY||(j.m&&(c=j.m(c,this._target)),j.f?this._target[j.p](c):this._target[j.p]=c)}}),g=f.prototype;g._kill=function(a){return null!=a[this._x.p]&&(this._skipX=!0),null!=a[this._y.p]&&(this._skipY=!0),this._super._kill.call(this,a)},g._mod=function(a){var b=a[this._x.p]||a.physics2D;b&&"function"==typeof b&&(this._x.m=b),b=a[this._y.p]||a.physics2D,b&&"function"==typeof b&&(this._y.m=b)},f._autoCSS=!0,f._cssRegister=function(){var a=d.CSSPlugin;if(a){var b=a._internals,e=b._parseToProxy,g=b._setPluginRatio,h=b.CSSPropTween;b._registerComplexSpecialProp("physics2D",{parser:function(a,b,d,i,j,k){k=new f;var l,m=b.xProp||"x",n=b.yProp||"y",o={};return o[m]=o[n]=c++,l=e(a,o,i,j,k),j=new h(a,"physics2D",0,0,l.pt,2),j.data=l,j.plugin=k,j.setRatio=g,k._onInitTween(l.proxy,b,i._tween),j}})}}}),_gsScope._gsDefine&&_gsScope._gsQueue.pop()(),function(a){"use strict";var b=function(){return(_gsScope.GreenSockGlobals||_gsScope)[a]};"undefined"!=typeof module&&module.exports?(require("../TweenLite.min.js"),module.exports=b()):"function"==typeof define&&define.amd&&define(["TweenLite"],b)}("Physics2DPlugin");

View File

@ -0,0 +1,13 @@
/*!
* VERSION: 0.2.1
* DATE: 2018-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* PhysicsPropsPlugin is a Club GreenSock membership benefit; You must have a valid membership to use
* this code without violating the terms of use. Visit http://greensock.com/club/ to sign up or get more details.
* This work is subject to the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
var _gsScope="undefined"!=typeof module&&module.exports&&"undefined"!=typeof global?global:this||window;(_gsScope._gsQueue||(_gsScope._gsQueue=[])).push(function(){"use strict";var a=function(a,b,c,d,e,f){this.p=b,this.f="function"==typeof a[b],this.start=this.value=this.f?a[b.indexOf("set")||"function"!=typeof a["get"+b.substr(3)]?b:"get"+b.substr(3)]():parseFloat(a[b]),this.velocity=c||0,this.v=this.velocity/f,d||0==d?(this.acceleration=d,this.a=this.acceleration/(f*f)):this.acceleration=this.a=0,this.friction=1-(e||0)},b=Math.random(),c=_gsScope._gsDefine.globals,d=c.com.greensock.core.Animation._rootFramesTimeline,e=_gsScope._gsDefine.plugin({propName:"physicsProps",version:"0.2.1",API:2,init:function(b,c,e,f){"function"==typeof c&&(c=c(b)),this._target=b,this._tween=e,this._runBackwards=e.vars.runBackwards===!0,this._step=0;for(var g,h,i=e._timeline,j=0;i._timeline;)i=i._timeline;this._stepsPerTimeUnit=i===d?1:30,this._props=[];for(g in c)h=c[g],"function"==typeof h&&(h=h(f,b)),(h.velocity||h.acceleration)&&(this._props[j++]=new a(b,g,h.velocity,h.acceleration,h.friction,this._stepsPerTimeUnit),this._overwriteProps[j]=g,h.friction&&(this._hasFriction=!0));return!0},set:function(a){var b,c,d,e,f,g,h=this._props.length,i=this._tween._time,j=this._target;if(this._runBackwards&&(i=this._tween._duration-i),this._hasFriction){if(i*=this._stepsPerTimeUnit,d=(0|i)-this._step,e=i%1,d>=0)for(;--h>-1;){for(b=this._props[h],f=d;--f>-1;)b.v+=b.a,b.v*=b.friction,b.value+=b.v;c=b.value+b.v*e,b.m&&(c=b.m(c,j)),b.f?j[b.p](c):j[b.p]=c}else for(;--h>-1;){for(b=this._props[h],f=-d;--f>-1;)b.value-=b.v,b.v/=b.friction,b.v-=b.a;c=b.value+b.v*e,b.m&&(c=b.m(c,j)),b.f?j[b.p](c):j[b.p]=c}this._step+=d}else for(g=i*i*.5;--h>-1;)b=this._props[h],c=b.start+(b.velocity*i+b.acceleration*g),b.m&&(c=b.m(c,j)),b.f?j[b.p](c):j[b.p]=c}}),f=e.prototype;f._kill=function(a){for(var b=this._props.length;--b>-1;)this._props[b].p in a&&this._props.splice(b,1);return this._super._kill.call(this,a)},f._mod=function(a){for(var b,c=this._props.length;--c>-1;)b=a[this._props[c].p]||a.physicsProps,"function"==typeof b&&(this._props[c].m=b)},e._autoCSS=!0,e._cssRegister=function(){var a=c.CSSPlugin;if(a){var d=a._internals,f=d._parseToProxy,g=d._setPluginRatio,h=d.CSSPropTween;d._registerComplexSpecialProp("physicsProps",{parser:function(a,c,d,i,j,k){k=new e;var l,m,n={};c.scale&&(c.scaleX=c.scaleY=c.scale,delete c.scale);for(l in c)n[l]=b++;return m=f(a,n,i,j,k),j=new h(a,"physicsProps",0,0,m.pt,2),j.data=m,j.plugin=k,j.setRatio=g,k._onInitTween(m.proxy,c,i._tween),j}})}}}),_gsScope._gsDefine&&_gsScope._gsQueue.pop()(),function(a){"use strict";var b=function(){return(_gsScope.GreenSockGlobals||_gsScope)[a]};"undefined"!=typeof module&&module.exports?(require("../TweenLite.min.js"),module.exports=b()):"function"==typeof define&&define.amd&&define(["TweenLite"],b)}("PhysicsPropsPlugin");

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,12 @@
/*!
* VERSION: 1.7.0
* DATE: 2018-05-21
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
var _gsScope="undefined"!=typeof module&&module.exports&&"undefined"!=typeof global?global:this||window;(_gsScope._gsQueue||(_gsScope._gsQueue=[])).push(function(){"use strict";var a=_gsScope._gsDefine.plugin({propName:"roundProps",version:"1.7.0",priority:-1,API:2,init:function(a,b,c){return this._tween=c,!0}}),b=function(a){var b=1>a?Math.pow(10,(a+"").length-2):1;return function(c){return(Math.round(c/a)*a*b|0)/b}},c=function(a,b){for(;a;)a.f||a.blob||(a.m=b||Math.round),a=a._next},d=a.prototype;d._onInitAllProps=function(){var a,d,e,f,g=this._tween,h=g.vars.roundProps,i={},j=g._propLookup.roundProps;if("object"!=typeof h||h.push)for("string"==typeof h&&(h=h.split(",")),e=h.length;--e>-1;)i[h[e]]=Math.round;else for(f in h)i[f]=b(h[f]);for(f in i)for(a=g._firstPT;a;)d=a._next,a.pg?a.t._mod(i):a.n===f&&(2===a.f&&a.t?c(a.t._firstPT,i[f]):(this._add(a.t,f,a.s,a.c,i[f]),d&&(d._prev=a._prev),a._prev?a._prev._next=d:g._firstPT===a&&(g._firstPT=d),a._next=a._prev=null,g._propLookup[f]=j)),a=d;return!1},d._add=function(a,b,c,d,e){this._addTween(a,b,c,c+d,b,e||Math.round),this._overwriteProps.push(b)}}),_gsScope._gsDefine&&_gsScope._gsQueue.pop()();

View File

@ -0,0 +1,13 @@
/*!
* VERSION: 0.5.2
* DATE: 2019-02-07
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* ScrambleTextPlugin is a Club GreenSock membership benefit; You must have a valid membership to use
* this code without violating the terms of use. Visit http://greensock.com/club/ to sign up or get more details.
* This work is subject to the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
var _gsScope="undefined"!=typeof module&&module.exports&&"undefined"!=typeof global?global:this||window;(_gsScope._gsQueue||(_gsScope._gsQueue=[])).push(function(){"use strict";var a=/(^\s+|\s+$)/g,b=/\s+/g,c=function(a){var b=a.nodeType,d="";if(1===b||9===b||11===b){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)d+=c(a)}else if(3===b||4===b)return a.nodeValue;return d},d=function(a,b){for(var c=b.length,d="";--a>-1;)d+=b[Math.random()*c|0];return d},e=function(a){this.chars=i(a),this.sets=[],this.length=50;var b;for(b=0;20>b;b++)this.sets[b]=d(80,this.chars);this.grow=function(a){for(b=0;20>b;b++)this.sets[b]+=d(a-this.length,this.chars);this.length=a}},f="[-]|<7C>[<5B>-<2D>]|<7C>[<5B>-<2D>]|[⚔-⚗]|<7C>[<5B>-<2D>]|[<5B>-<2D>][<5B>-<2D>]",g=new RegExp(f),h=new RegExp(f+"|.","g"),i=function(b,c,d){return d&&(b=b.replace(a,"")),""!==c&&c||!g.test(b)?b.split(c||""):b.match(h)},j="ABCDEFGHIJKLMNOPQRSTUVWXYZ",k=j.toLowerCase(),l={upperCase:new e(j),lowerCase:new e(k),upperAndLowerCase:new e(j+k)},m=_gsScope._gsDefine.plugin({propName:"scrambleText",version:"0.5.2",API:2,overwriteProps:["scrambleText","text"],init:function(a,d,f,h){if(this._prop="innerHTML"in a?"innerHTML":"textContent"in a?"textContent":0,!this._prop)return!1;"function"==typeof d&&(d=d(h,a)),this._target=a,"object"!=typeof d&&(d={text:d});var j,k,m,n,o=d.text||d.value,p=d.trim!==!1;return this._delimiter=j=d.delimiter||"",this._original=i(c(a).replace(b," ").split("&nbsp;").join(""),j,p),("{original}"===o||o===!0||null==o)&&(o=this._original.join(j)),this._text=i((o||"").replace(b," "),j,p),this._hasClass=!1,"string"==typeof d.newClass&&(this._newClass=d.newClass,this._hasClass=!0),"string"==typeof d.oldClass&&(this._oldClass=d.oldClass,this._hasClass=!0),n=""===j,this._textHasEmoji=g.test(this._text.join(j))&&n,this._charsHaveEmoji=!!d.chars&&g.test(d.chars),this._length=n?this._original.length:this._original.join(j).length,this._lengthDif=(n?this._text.length:this._text.join(j).length)-this._length,this._fillChar=d.fillChar||d.chars&&-1!==d.chars.indexOf(" ")?"&nbsp;":"",this._charSet=m=l[d.chars||"upperCase"]||new e(d.chars),this._speed=.016/(d.speed||1),this._prevScrambleTime=0,this._setIndex=20*Math.random()|0,k=this._length+Math.max(this._lengthDif,0),k>m.length&&m.grow(k),this._chars=m.sets[this._setIndex],this._revealDelay=d.revealDelay||0,this._tweenLength=d.tweenLength!==!1,this._tween=f,this._rightToLeft=!!d.rightToLeft,!0},set:function(a){var b,c,d,e,f,g,h,j,k,l=this._text.length,m=this._delimiter,n=this._tween._time,o=n-this._prevScrambleTime;this._revealDelay&&(this._tween.vars.runBackwards&&(n=this._tween._duration-n),a=0===n?0:n<this._revealDelay?1e-6:n===this._tween._duration?1:this._tween._ease.getRatio((n-this._revealDelay)/(this._tween._duration-this._revealDelay))),0>a?a=0:a>1&&(a=1),this._rightToLeft&&(a=1-a),b=a*l+.5|0,a?((o>this._speed||o<-this._speed)&&(this._setIndex=(this._setIndex+(19*Math.random()|0))%20,this._chars=this._charSet.sets[this._setIndex],this._prevScrambleTime+=o),e=this._chars):e=this._original.join(m),this._rightToLeft?1!==a||!this._tween.vars.runBackwards&&"isFromStart"!==this._tween.data?(h=this._text.slice(b).join(m),d=this._charsHaveEmoji?i(e).slice(0,this._length+(this._tweenLength?1-a*a*a:1)*this._lengthDif-(this._textHasEmoji?i(h):h).length+.5|0).join(""):e.substr(0,this._length+(this._tweenLength?1-a*a*a:1)*this._lengthDif-(this._textHasEmoji?i(h):h).length+.5|0),e=h):(d="",e=this._original.join(m)):(d=this._text.slice(0,b).join(m),c=(this._textHasEmoji?i(d):d).length,e=this._charsHaveEmoji?i(e).slice(c,this._length+(this._tweenLength?1-(a=1-a)*a*a*a:1)*this._lengthDif+.5|0).join(""):e.substr(c,this._length+(this._tweenLength?1-(a=1-a)*a*a*a:1)*this._lengthDif-c+.5|0)),this._hasClass?(j=this._rightToLeft?this._oldClass:this._newClass,k=this._rightToLeft?this._newClass:this._oldClass,f=j&&0!==b,g=k&&b!==l,h=(f?"<span class='"+j+"'>":"")+d+(f?"</span>":"")+(g?"<span class='"+k+"'>":"")+m+e+(g?"</span>":"")):h=d+m+e,this._target[this._prop]="&nbsp;"===this._fillChar&&-1!==h.indexOf(" ")?h.split(" ").join("&nbsp;&nbsp;"):h}}),n=m.prototype;n._newClass=n._oldClass="";for(n in l)l[n.toLowerCase()]=l[n],l[n.toUpperCase()]=l[n]}),_gsScope._gsDefine&&_gsScope._gsQueue.pop()(),function(a){"use strict";var b=function(){return(_gsScope.GreenSockGlobals||_gsScope)[a]};"undefined"!=typeof module&&module.exports?(require("../TweenLite.min.js"),module.exports=b()):"function"==typeof define&&define.amd&&define(["TweenLite"],b)}("ScrambleTextPlugin");

View File

@ -0,0 +1,12 @@
/*!
* VERSION: 1.9.2
* DATE: 2019-02-07
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
var _gsScope="undefined"!=typeof module&&module.exports&&"undefined"!=typeof global?global:this||window;(_gsScope._gsQueue||(_gsScope._gsQueue=[])).push(function(){"use strict";var a=(_gsScope.document||{}).documentElement,b=_gsScope,c=function(c,d){var e="x"===d?"Width":"Height",f="scroll"+e,g="client"+e,h=document.body;return c===b||c===a||c===h?Math.max(a[f],h[f])-(b["inner"+e]||a[g]||h[g]):c[f]-c["offset"+e]},d=function(a){return"string"==typeof a&&(a=TweenLite.selector(a)),a.length&&a!==b&&a[0]&&a[0].style&&!a.nodeType&&(a=a[0]),a===b||a.nodeType&&a.style?a:null},e=function(c,d){var e="scroll"+("x"===d?"Left":"Top");return c===b&&(null!=c.pageXOffset?e="page"+d.toUpperCase()+"Offset":c=null!=a[e]?a:document.body),function(){return c[e]}},f=function(c,f){var g=d(c).getBoundingClientRect(),h=document.body,i=!f||f===b||f===h,j=i?{top:a.clientTop-(window.pageYOffset||a.scrollTop||h.scrollTop||0),left:a.clientLeft-(window.pageXOffset||a.scrollLeft||h.scrollLeft||0)}:f.getBoundingClientRect(),k={x:g.left-j.left,y:g.top-j.top};return!i&&f&&(k.x+=e(f,"x")(),k.y+=e(f,"y")()),k},g=function(a,b,d,e){var g=typeof a;return isNaN(a)?"string"===g&&"="===a.charAt(1)?parseInt(a.charAt(0)+"1",10)*parseFloat(a.substr(2))+e:"max"===a?c(b,d):Math.min(c(b,d),f(a,b)[d]):parseFloat(a)},h=_gsScope._gsDefine.plugin({propName:"scrollTo",API:2,global:!0,version:"1.9.2",init:function(a,c,d){return this._wdw=a===b,this._target=a,this._tween=d,"object"!=typeof c?(c={y:c},"string"==typeof c.y&&"max"!==c.y&&"="!==c.y.charAt(1)&&(c.x=c.y)):c.nodeType&&(c={y:c,x:c}),this.vars=c,this._autoKill=c.autoKill!==!1,this.getX=e(a,"x"),this.getY=e(a,"y"),this.x=this.xPrev=this.getX(),this.y=this.yPrev=this.getY(),null!=c.x?(this._addTween(this,"x",this.x,g(c.x,a,"x",this.x)-(c.offsetX||0),"scrollTo_x",!0),this._overwriteProps.push("scrollTo_x")):this.skipX=!0,null!=c.y?(this._addTween(this,"y",this.y,g(c.y,a,"y",this.y)-(c.offsetY||0),"scrollTo_y",!0),this._overwriteProps.push("scrollTo_y")):this.skipY=!0,!0},set:function(a){this._super.setRatio.call(this,a);var d=this._wdw||!this.skipX?this.getX():this.xPrev,e=this._wdw||!this.skipY?this.getY():this.yPrev,f=e-this.yPrev,g=d-this.xPrev,i=h.autoKillThreshold;this.x<0&&(this.x=0),this.y<0&&(this.y=0),this._autoKill&&(!this.skipX&&(g>i||-i>g)&&d<c(this._target,"x")&&(this.skipX=!0),!this.skipY&&(f>i||-i>f)&&e<c(this._target,"y")&&(this.skipY=!0),this.skipX&&this.skipY&&(this._tween.kill(),this.vars.onAutoKill&&this.vars.onAutoKill.apply(this.vars.onAutoKillScope||this._tween,this.vars.onAutoKillParams||[]))),this._wdw?b.scrollTo(this.skipX?d:this.x,this.skipY?e:this.y):(this.skipY||(this._target.scrollTop=this.y),this.skipX||(this._target.scrollLeft=this.x)),this.xPrev=this.x,this.yPrev=this.y}}),i=h.prototype;h.max=c,h.getOffset=f,h.buildGetter=e,h.autoKillThreshold=7,i._kill=function(a){return a.scrollTo_x&&(this.skipX=!0),a.scrollTo_y&&(this.skipY=!0),this._super._kill.call(this,a)}}),_gsScope._gsDefine&&_gsScope._gsQueue.pop()(),function(a){"use strict";var b=function(){return(_gsScope.GreenSockGlobals||_gsScope)[a]};"undefined"!=typeof module&&module.exports?(require("../TweenLite.min.js"),module.exports=b()):"function"==typeof define&&define.amd&&define(["TweenLite"],b)}("ScrollToPlugin");

View File

@ -0,0 +1,12 @@
/*!
* VERSION: 0.6.2
* DATE: 2018-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
var _gsScope="undefined"!=typeof module&&module.exports&&"undefined"!=typeof global?global:this||window;(_gsScope._gsQueue||(_gsScope._gsQueue=[])).push(function(){"use strict";var a=function(b){var c=b.nodeType,d="";if(1===c||9===c||11===c){if("string"==typeof b.textContent)return b.textContent;for(b=b.firstChild;b;b=b.nextSibling)d+=a(b)}else if(3===c||4===c)return b.nodeValue;return d},b="[-]|<7C>[<5B>-<2D>]|<7C>[<5B>-<2D>]|[⚔-⚗]|<7C>[<5B>-<2D>]|[<5B>-<2D>][<5B>-<2D>]",c=new RegExp(b),d=new RegExp(b+"|.","g"),e=function(a,b){return""!==b&&b||!c.test(a)?a.split(b||""):a.match(d)},f=_gsScope._gsDefine.plugin({propName:"text",API:2,version:"0.6.2",init:function(b,c,d,f){var g,h=b.nodeName.toUpperCase();if("function"==typeof c&&(c=c(f,b)),this._svg=b.getBBox&&("TEXT"===h||"TSPAN"===h),!("innerHTML"in b||this._svg))return!1;if(this._target=b,"object"!=typeof c&&(c={value:c}),void 0===c.value)return this._text=this._original=[""],!0;for(this._delimiter=c.delimiter||"",this._original=e(a(b).replace(/\s+/g," "),this._delimiter),this._text=e(c.value.replace(/\s+/g," "),this._delimiter),this._runBackwards=d.vars.runBackwards===!0,this._runBackwards&&(h=this._original,this._original=this._text,this._text=h),"string"==typeof c.newClass&&(this._newClass=c.newClass,this._hasClass=!0),"string"==typeof c.oldClass&&(this._oldClass=c.oldClass,this._hasClass=!0),h=this._original.length-this._text.length,g=0>h?this._original:this._text,this._fillChar=c.fillChar||(c.padSpace?"&nbsp;":""),0>h&&(h=-h);--h>-1;)g.push(this._fillChar);return!0},set:function(a){a>1?a=1:0>a&&(a=0),this._runBackwards&&(a=1-a);var b,c,d,e=this._text.length,f=a*e+.5|0;this._hasClass?(b=this._newClass&&0!==f,c=this._oldClass&&f!==e,d=(b?"<span class='"+this._newClass+"'>":"")+this._text.slice(0,f).join(this._delimiter)+(b?"</span>":"")+(c?"<span class='"+this._oldClass+"'>":"")+this._delimiter+this._original.slice(f).join(this._delimiter)+(c?"</span>":"")):d=this._text.slice(0,f).join(this._delimiter)+this._delimiter+this._original.slice(f).join(this._delimiter),this._svg?this._target.textContent=d:this._target.innerHTML="&nbsp;"===this._fillChar&&-1!==d.indexOf(" ")?d.split(" ").join("&nbsp;&nbsp;"):d}}),g=f.prototype;g._newClass=g._oldClass=g._delimiter=""}),_gsScope._gsDefine&&_gsScope._gsQueue.pop()(),function(a){"use strict";var b=function(){return(_gsScope.GreenSockGlobals||_gsScope)[a]};"undefined"!=typeof module&&module.exports?(require("../TweenLite.min.js"),module.exports=b()):"function"==typeof define&&define.amd&&define(["TweenLite"],b)}("TextPlugin");

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,860 @@
/*!
* VERSION: 2.1.0
* DATE: 2019-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || window; //helps ensure compatibility with AMD/RequireJS and CommonJS/Node
(_gsScope._gsQueue || (_gsScope._gsQueue = [])).push( function() {
"use strict";
_gsScope._gsDefine("TimelineLite", ["core.Animation","core.SimpleTimeline","TweenLite"], function(Animation, SimpleTimeline, TweenLite) {
var TimelineLite = function(vars) {
SimpleTimeline.call(this, vars);
var self = this,
v = self.vars,
val, p;
self._labels = {};
self.autoRemoveChildren = !!v.autoRemoveChildren;
self.smoothChildTiming = !!v.smoothChildTiming;
self._sortChildren = true;
self._onUpdate = v.onUpdate;
for (p in v) {
val = v[p];
if (_isArray(val)) if (val.join("").indexOf("{self}") !== -1) {
v[p] = self._swapSelfInParams(val);
}
}
if (_isArray(v.tweens)) {
self.add(v.tweens, 0, v.align, v.stagger);
}
},
_tinyNum = 0.00000001,
TweenLiteInternals = TweenLite._internals,
_internals = TimelineLite._internals = {},
_isSelector = TweenLiteInternals.isSelector,
_isArray = TweenLiteInternals.isArray,
_lazyTweens = TweenLiteInternals.lazyTweens,
_lazyRender = TweenLiteInternals.lazyRender,
_globals = _gsScope._gsDefine.globals,
_copy = function(vars) {
var copy = {}, p;
for (p in vars) {
copy[p] = vars[p];
}
return copy;
},
_applyCycle = function(vars, targets, i) {
var alt = vars.cycle,
p, val;
for (p in alt) {
val = alt[p];
vars[p] = (typeof(val) === "function") ? val(i, targets[i], targets) : val[i % val.length];
}
delete vars.cycle;
},
_pauseCallback = _internals.pauseCallback = function() {},
_slice = function(a) { //don't use [].slice because that doesn't work in IE8 with a NodeList that's returned by querySelectorAll()
var b = [],
l = a.length,
i;
for (i = 0; i !== l; b.push(a[i++]));
return b;
},
_defaultImmediateRender = function(tl, toVars, fromVars, defaultFalse) { //default to immediateRender:true unless otherwise set in toVars, fromVars or if defaultFalse is passed in as true
var ir = "immediateRender";
if (!(ir in toVars)) {
toVars[ir] = !(tl._paused || (fromVars && fromVars[ir] === false) || defaultFalse);
}
return toVars;
},
//for distributing values across an array. Can accept a number, a function or (most commonly) a function which can contain the following properties: {base, amount, from, ease, grid, axis, length}. Returns a function that expects the following parameters: index, target, array. Recognizes the following
_distribute = function(v) {
if (typeof(v) === "function") {
return v;
}
var vars = isNaN(v) ? v : {n:1, from:(v < 0) ? ((v = -v) && "end") : 0}, //n:1 is just to indicate v was a number; we leverage that later to set v according to the length we get. If a number is passed in, we treat it like the old stagger value where 0.1, for example, would mean that things would be distributed with 0.1 between each element in the array rather than a total "amount" that's chunked out among them all.
ease = vars.ease,
from = vars.from || 0,
base = vars.base || 0,
cache = {},
isFromKeyword = isNaN(from),
axis = vars.axis,
ratio = {center:0.5, end:1}[from] || 0;
return function(i, target, a) {
var l = (a || vars).length,
distances = cache[l],
originX, originY, x, y, d, j, max, min, wrap;
if (!distances) {
wrap = (vars.grid === "auto") ? 0 : (vars.grid || [Infinity])[0];
if (!wrap) {
max = -Infinity;
while (max < (max = a[wrap++].getBoundingClientRect().left) && wrap < l) { }
wrap--;
}
distances = cache[l] = [];
originX = isFromKeyword ? (Math.min(wrap, l) * ratio) - 0.5 : from % wrap;
originY = isFromKeyword ? l * ratio / wrap - 0.5 : (from / wrap) | 0;
max = 0;
min = Infinity;
for (j = 0; j < l; j++) {
x = (j % wrap) - originX;
y = originY - ((j / wrap) | 0);
distances[j] = d = !axis ? Math.sqrt(x * x + y * y) : Math.abs((axis === "y") ? y : x);
if (d > max) {
max = d;
}
if (d < min) {
min = d;
}
}
distances.max = max - min;
distances.min = min;
distances.v = vars.n ? l * (v || 0) : vars.amount;
}
l = (distances[i] - distances.min) / distances.max;
return base + (ease ? ease.getRatio(l) : l) * distances.v;
};
},
p = TimelineLite.prototype = new SimpleTimeline();
TimelineLite.version = "2.1.0";
TimelineLite.distribute = _distribute;
p.constructor = TimelineLite;
p.kill()._gc = p._forcingPlayhead = p._hasPause = false;
/* might use later...
//translates a local time inside an animation to the corresponding time on the root/global timeline, factoring in all nesting and timeScales.
function localToGlobal(time, animation) {
while (animation) {
time = (time / animation._timeScale) + animation._startTime;
animation = animation.timeline;
}
return time;
}
//translates the supplied time on the root/global timeline into the corresponding local time inside a particular animation, factoring in all nesting and timeScales
function globalToLocal(time, animation) {
var scale = 1;
time -= localToGlobal(0, animation);
while (animation) {
scale *= animation._timeScale;
animation = animation.timeline;
}
return time * scale;
}
*/
p.to = function(target, duration, vars, position) {
var Engine = (vars.repeat && _globals.TweenMax) || TweenLite;
return duration ? this.add( new Engine(target, duration, vars), position) : this.set(target, vars, position);
};
p.from = function(target, duration, vars, position) {
return this.add( ((vars.repeat && _globals.TweenMax) || TweenLite).from(target, duration, _defaultImmediateRender(this, vars)), position);
};
p.fromTo = function(target, duration, fromVars, toVars, position) {
var Engine = (toVars.repeat && _globals.TweenMax) || TweenLite;
toVars = _defaultImmediateRender(this, toVars, fromVars);
return duration ? this.add( Engine.fromTo(target, duration, fromVars, toVars), position) : this.set(target, toVars, position);
};
p.staggerTo = function(targets, duration, vars, stagger, position, onCompleteAll, onCompleteAllParams, onCompleteAllScope) {
var tl = new TimelineLite({onComplete:onCompleteAll, onCompleteParams:onCompleteAllParams, callbackScope:onCompleteAllScope, smoothChildTiming:this.smoothChildTiming}),
staggerFunc = _distribute(vars.stagger || stagger),
startAt = vars.startAt,
cycle = vars.cycle,
copy, i;
if (typeof(targets) === "string") {
targets = TweenLite.selector(targets) || targets;
}
targets = targets || [];
if (_isSelector(targets)) { //if the targets object is a selector, translate it into an array.
targets = _slice(targets);
}
for (i = 0; i < targets.length; i++) {
copy = _copy(vars);
if (startAt) {
copy.startAt = _copy(startAt);
if (startAt.cycle) {
_applyCycle(copy.startAt, targets, i);
}
}
if (cycle) {
_applyCycle(copy, targets, i);
if (copy.duration != null) {
duration = copy.duration;
delete copy.duration;
}
}
tl.to(targets[i], duration, copy, staggerFunc(i, targets[i], targets));
}
return this.add(tl, position);
};
p.staggerFrom = function(targets, duration, vars, stagger, position, onCompleteAll, onCompleteAllParams, onCompleteAllScope) {
vars.runBackwards = true;
return this.staggerTo(targets, duration, _defaultImmediateRender(this, vars), stagger, position, onCompleteAll, onCompleteAllParams, onCompleteAllScope);
};
p.staggerFromTo = function(targets, duration, fromVars, toVars, stagger, position, onCompleteAll, onCompleteAllParams, onCompleteAllScope) {
toVars.startAt = fromVars;
return this.staggerTo(targets, duration, _defaultImmediateRender(this, toVars, fromVars), stagger, position, onCompleteAll, onCompleteAllParams, onCompleteAllScope);
};
p.call = function(callback, params, scope, position) {
return this.add( TweenLite.delayedCall(0, callback, params, scope), position);
};
p.set = function(target, vars, position) {
return this.add( new TweenLite(target, 0, _defaultImmediateRender(this, vars, null, true)), position);
};
TimelineLite.exportRoot = function(vars, ignoreDelayedCalls) {
vars = vars || {};
if (vars.smoothChildTiming == null) {
vars.smoothChildTiming = true;
}
var tl = new TimelineLite(vars),
root = tl._timeline,
hasNegativeStart, time, tween, next;
if (ignoreDelayedCalls == null) {
ignoreDelayedCalls = true;
}
root._remove(tl, true);
tl._startTime = 0;
tl._rawPrevTime = tl._time = tl._totalTime = root._time;
tween = root._first;
while (tween) {
next = tween._next;
if (!ignoreDelayedCalls || !(tween instanceof TweenLite && tween.target === tween.vars.onComplete)) {
time = tween._startTime - tween._delay;
if (time < 0) {
hasNegativeStart = 1;
}
tl.add(tween, time);
}
tween = next;
}
root.add(tl, 0);
if (hasNegativeStart) { //calling totalDuration() will force the adjustment necessary to shift the children forward so none of them start before zero, and moves the timeline backwards the same amount, so the playhead is still aligned where it should be globally, but the timeline doesn't have illegal children that start before zero.
tl.totalDuration();
}
return tl;
};
p.add = function(value, position, align, stagger) {
var self = this,
curTime, l, i, child, tl, beforeRawTime;
if (typeof(position) !== "number") {
position = self._parseTimeOrLabel(position, 0, true, value);
}
if (!(value instanceof Animation)) {
if ((value instanceof Array) || (value && value.push && _isArray(value))) {
align = align || "normal";
stagger = stagger || 0;
curTime = position;
l = value.length;
for (i = 0; i < l; i++) {
if (_isArray(child = value[i])) {
child = new TimelineLite({tweens:child});
}
self.add(child, curTime);
if (typeof(child) !== "string" && typeof(child) !== "function") {
if (align === "sequence") {
curTime = child._startTime + (child.totalDuration() / child._timeScale);
} else if (align === "start") {
child._startTime -= child.delay();
}
}
curTime += stagger;
}
return self._uncache(true);
} else if (typeof(value) === "string") {
return self.addLabel(value, position);
} else if (typeof(value) === "function") {
value = TweenLite.delayedCall(0, value);
} else {
throw("Cannot add " + value + " into the timeline; it is not a tween, timeline, function, or string.");
}
}
SimpleTimeline.prototype.add.call(self, value, position);
if (value._time || (!value._duration && value._initted)) { //in case, for example, the _startTime is moved on a tween that has already rendered. Imagine it's at its end state, then the startTime is moved WAY later (after the end of this timeline), it should render at its beginning.
curTime = (self.rawTime() - value._startTime) * value._timeScale;
if (!value._duration || Math.abs(Math.max(0, Math.min(value.totalDuration(), curTime))) - value._totalTime > 0.00001) {
value.render(curTime, false, false);
}
}
//if the timeline has already ended but the inserted tween/timeline extends the duration, we should enable this timeline again so that it renders properly. We should also align the playhead with the parent timeline's when appropriate.
if (self._gc || self._time === self._duration) if (!self._paused) if (self._duration < self.duration()) {
//in case any of the ancestors had completed but should now be enabled...
tl = self;
beforeRawTime = (tl.rawTime() > value._startTime); //if the tween is placed on the timeline so that it starts BEFORE the current rawTime, we should align the playhead (move the timeline). This is because sometimes users will create a timeline, let it finish, and much later append a tween and expect it to run instead of jumping to its end state. While technically one could argue that it should jump to its end state, that's not what users intuitively expect.
while (tl._timeline) {
if (beforeRawTime && tl._timeline.smoothChildTiming) {
tl.totalTime(tl._totalTime, true); //moves the timeline (shifts its startTime) if necessary, and also enables it.
} else if (tl._gc) {
tl._enabled(true, false);
}
tl = tl._timeline;
}
}
return self;
};
p.remove = function(value) {
if (value instanceof Animation) {
this._remove(value, false);
var tl = value._timeline = value.vars.useFrames ? Animation._rootFramesTimeline : Animation._rootTimeline; //now that it's removed, default it to the root timeline so that if it gets played again, it doesn't jump back into this timeline.
value._startTime = (value._paused ? value._pauseTime : tl._time) - ((!value._reversed ? value._totalTime : value.totalDuration() - value._totalTime) / value._timeScale); //ensure that if it gets played again, the timing is correct.
return this;
} else if (value instanceof Array || (value && value.push && _isArray(value))) {
var i = value.length;
while (--i > -1) {
this.remove(value[i]);
}
return this;
} else if (typeof(value) === "string") {
return this.removeLabel(value);
}
return this.kill(null, value);
};
p._remove = function(tween, skipDisable) {
SimpleTimeline.prototype._remove.call(this, tween, skipDisable);
var last = this._last;
if (!last) {
this._time = this._totalTime = this._duration = this._totalDuration = 0;
} else if (this._time > this.duration()) {
this._time = this._duration;
this._totalTime = this._totalDuration;
}
return this;
};
p.append = function(value, offsetOrLabel) {
return this.add(value, this._parseTimeOrLabel(null, offsetOrLabel, true, value));
};
p.insert = p.insertMultiple = function(value, position, align, stagger) {
return this.add(value, position || 0, align, stagger);
};
p.appendMultiple = function(tweens, offsetOrLabel, align, stagger) {
return this.add(tweens, this._parseTimeOrLabel(null, offsetOrLabel, true, tweens), align, stagger);
};
p.addLabel = function(label, position) {
this._labels[label] = this._parseTimeOrLabel(position);
return this;
};
p.addPause = function(position, callback, params, scope) {
var t = TweenLite.delayedCall(0, _pauseCallback, params, scope || this);
t.vars.onComplete = t.vars.onReverseComplete = callback;
t.data = "isPause";
this._hasPause = true;
return this.add(t, position);
};
p.removeLabel = function(label) {
delete this._labels[label];
return this;
};
p.getLabelTime = function(label) {
return (this._labels[label] != null) ? this._labels[label] : -1;
};
p._parseTimeOrLabel = function(timeOrLabel, offsetOrLabel, appendIfAbsent, ignore) {
var clippedDuration, i;
//if we're about to add a tween/timeline (or an array of them) that's already a child of this timeline, we should remove it first so that it doesn't contaminate the duration().
if (ignore instanceof Animation && ignore.timeline === this) {
this.remove(ignore);
} else if (ignore && ((ignore instanceof Array) || (ignore.push && _isArray(ignore)))) {
i = ignore.length;
while (--i > -1) {
if (ignore[i] instanceof Animation && ignore[i].timeline === this) {
this.remove(ignore[i]);
}
}
}
clippedDuration = (typeof(timeOrLabel) === "number" && !offsetOrLabel) ? 0 : (this.duration() > 99999999999) ? this.recent().endTime(false) : this._duration; //in case there's a child that infinitely repeats, users almost never intend for the insertion point of a new child to be based on a SUPER long value like that so we clip it and assume the most recently-added child's endTime should be used instead.
if (typeof(offsetOrLabel) === "string") {
return this._parseTimeOrLabel(offsetOrLabel, (appendIfAbsent && typeof(timeOrLabel) === "number" && this._labels[offsetOrLabel] == null) ? timeOrLabel - clippedDuration : 0, appendIfAbsent);
}
offsetOrLabel = offsetOrLabel || 0;
if (typeof(timeOrLabel) === "string" && (isNaN(timeOrLabel) || this._labels[timeOrLabel] != null)) { //if the string is a number like "1", check to see if there's a label with that name, otherwise interpret it as a number (absolute value).
i = timeOrLabel.indexOf("=");
if (i === -1) {
if (this._labels[timeOrLabel] == null) {
return appendIfAbsent ? (this._labels[timeOrLabel] = clippedDuration + offsetOrLabel) : offsetOrLabel;
}
return this._labels[timeOrLabel] + offsetOrLabel;
}
offsetOrLabel = parseInt(timeOrLabel.charAt(i-1) + "1", 10) * Number(timeOrLabel.substr(i+1));
timeOrLabel = (i > 1) ? this._parseTimeOrLabel(timeOrLabel.substr(0, i-1), 0, appendIfAbsent) : clippedDuration;
} else if (timeOrLabel == null) {
timeOrLabel = clippedDuration;
}
return Number(timeOrLabel) + offsetOrLabel;
};
p.seek = function(position, suppressEvents) {
return this.totalTime((typeof(position) === "number") ? position : this._parseTimeOrLabel(position), (suppressEvents !== false));
};
p.stop = function() {
return this.paused(true);
};
p.gotoAndPlay = function(position, suppressEvents) {
return this.play(position, suppressEvents);
};
p.gotoAndStop = function(position, suppressEvents) {
return this.pause(position, suppressEvents);
};
p.render = function(time, suppressEvents, force) {
if (this._gc) {
this._enabled(true, false);
}
var self = this,
prevTime = self._time,
totalDur = (!self._dirty) ? self._totalDuration : self.totalDuration(),
prevStart = self._startTime,
prevTimeScale = self._timeScale,
prevPaused = self._paused,
tween, isComplete, next, callback, internalForce, pauseTween, curTime, pauseTime;
if (prevTime !== self._time) { //if totalDuration() finds a child with a negative startTime and smoothChildTiming is true, things get shifted around internally so we need to adjust the time accordingly. For example, if a tween starts at -30 we must shift EVERYTHING forward 30 seconds and move this timeline's startTime backward by 30 seconds so that things align with the playhead (no jump).
time += self._time - prevTime;
}
if (time >= totalDur - _tinyNum && time >= 0) { //to work around occasional floating point math artifacts.
self._totalTime = self._time = totalDur;
if (!self._reversed) if (!self._hasPausedChild()) {
isComplete = true;
callback = "onComplete";
internalForce = !!self._timeline.autoRemoveChildren; //otherwise, if the animation is unpaused/activated after it's already finished, it doesn't get removed from the parent timeline.
if (self._duration === 0) if ((time <= 0 && time >= -_tinyNum) || self._rawPrevTime < 0 || self._rawPrevTime === _tinyNum) if (self._rawPrevTime !== time && self._first) {
internalForce = true;
if (self._rawPrevTime > _tinyNum) {
callback = "onReverseComplete";
}
}
}
self._rawPrevTime = (self._duration || !suppressEvents || time || self._rawPrevTime === time) ? time : _tinyNum; //when the playhead arrives at EXACTLY time 0 (right on top) of a zero-duration timeline or tween, we need to discern if events are suppressed so that when the playhead moves again (next time), it'll trigger the callback. If events are NOT suppressed, obviously the callback would be triggered in this render. Basically, the callback should fire either when the playhead ARRIVES or LEAVES this exact spot, not both. Imagine doing a timeline.seek(0) and there's a callback that sits at 0. Since events are suppressed on that seek() by default, nothing will fire, but when the playhead moves off of that position, the callback should fire. This behavior is what people intuitively expect. We set the _rawPrevTime to be a precise tiny number to indicate this scenario rather than using another property/variable which would increase memory usage. This technique is less readable, but more efficient.
time = totalDur + 0.0001; //to avoid occasional floating point rounding errors - sometimes child tweens/timelines were not being fully completed (their progress might be 0.999999999999998 instead of 1 because when _time - tween._startTime is performed, floating point errors would return a value that was SLIGHTLY off). Try (999999999999.7 - 999999999999) * 1 = 0.699951171875 instead of 0.7.
} else if (time < _tinyNum) { //to work around occasional floating point math artifacts, round super small values to 0.
self._totalTime = self._time = 0;
if (time > -_tinyNum) {
time = 0;
}
if (prevTime !== 0 || (self._duration === 0 && self._rawPrevTime !== _tinyNum && (self._rawPrevTime > 0 || (time < 0 && self._rawPrevTime >= 0)))) {
callback = "onReverseComplete";
isComplete = self._reversed;
}
if (time < 0) {
self._active = false;
if (self._timeline.autoRemoveChildren && self._reversed) { //ensures proper GC if a timeline is resumed after it's finished reversing.
internalForce = isComplete = true;
callback = "onReverseComplete";
} else if (self._rawPrevTime >= 0 && self._first) { //when going back beyond the start, force a render so that zero-duration tweens that sit at the very beginning render their start values properly. Otherwise, if the parent timeline's playhead lands exactly at this timeline's startTime, and then moves backwards, the zero-duration tweens at the beginning would still be at their end state.
internalForce = true;
}
self._rawPrevTime = time;
} else {
self._rawPrevTime = (self._duration || !suppressEvents || time || self._rawPrevTime === time) ? time : _tinyNum; //when the playhead arrives at EXACTLY time 0 (right on top) of a zero-duration timeline or tween, we need to discern if events are suppressed so that when the playhead moves again (next time), it'll trigger the callback. If events are NOT suppressed, obviously the callback would be triggered in this render. Basically, the callback should fire either when the playhead ARRIVES or LEAVES this exact spot, not both. Imagine doing a timeline.seek(0) and there's a callback that sits at 0. Since events are suppressed on that seek() by default, nothing will fire, but when the playhead moves off of that position, the callback should fire. This behavior is what people intuitively expect. We set the _rawPrevTime to be a precise tiny number to indicate this scenario rather than using another property/variable which would increase memory usage. This technique is less readable, but more efficient.
if (time === 0 && isComplete) { //if there's a zero-duration tween at the very beginning of a timeline and the playhead lands EXACTLY at time 0, that tween will correctly render its end values, but we need to keep the timeline alive for one more render so that the beginning values render properly as the parent's playhead keeps moving beyond the begining. Imagine obj.x starts at 0 and then we do tl.set(obj, {x:100}).to(obj, 1, {x:200}) and then later we tl.reverse()...the goal is to have obj.x revert to 0. If the playhead happens to land on exactly 0, without this chunk of code, it'd complete the timeline and remove it from the rendering queue (not good).
tween = self._first;
while (tween && tween._startTime === 0) {
if (!tween._duration) {
isComplete = false;
}
tween = tween._next;
}
}
time = 0; //to avoid occasional floating point rounding errors (could cause problems especially with zero-duration tweens at the very beginning of the timeline)
if (!self._initted) {
internalForce = true;
}
}
} else {
if (self._hasPause && !self._forcingPlayhead && !suppressEvents) {
if (time >= prevTime) {
tween = self._first;
while (tween && tween._startTime <= time && !pauseTween) {
if (!tween._duration) if (tween.data === "isPause" && !tween.ratio && !(tween._startTime === 0 && self._rawPrevTime === 0)) {
pauseTween = tween;
}
tween = tween._next;
}
} else {
tween = self._last;
while (tween && tween._startTime >= time && !pauseTween) {
if (!tween._duration) if (tween.data === "isPause" && tween._rawPrevTime > 0) {
pauseTween = tween;
}
tween = tween._prev;
}
}
if (pauseTween) {
self._time = self._totalTime = time = pauseTween._startTime;
pauseTime = self._startTime + (time / self._timeScale);
}
}
self._totalTime = self._time = self._rawPrevTime = time;
}
if ((self._time === prevTime || !self._first) && !force && !internalForce && !pauseTween) {
return;
} else if (!self._initted) {
self._initted = true;
}
if (!self._active) if (!self._paused && self._time !== prevTime && time > 0) {
self._active = true; //so that if the user renders the timeline (as opposed to the parent timeline rendering it), it is forced to re-render and align it with the proper time/frame on the next rendering cycle. Maybe the timeline already finished but the user manually re-renders it as halfway done, for example.
}
if (prevTime === 0) if (self.vars.onStart) if (self._time !== 0 || !self._duration) if (!suppressEvents) {
self._callback("onStart");
}
curTime = self._time;
if (curTime >= prevTime) {
tween = self._first;
while (tween) {
next = tween._next; //record it here because the value could change after rendering...
if (curTime !== self._time || (self._paused && !prevPaused)) { //in case a tween pauses or seeks the timeline when rendering, like inside of an onUpdate/onComplete
break;
} else if (tween._active || (tween._startTime <= curTime && !tween._paused && !tween._gc)) {
if (pauseTween === tween) {
self.pause();
self._pauseTime = pauseTime; //so that when we resume(), it's starting from exactly the right spot (the pause() method uses the rawTime for the parent, but that may be a bit too far ahead)
}
if (!tween._reversed) {
tween.render((time - tween._startTime) * tween._timeScale, suppressEvents, force);
} else {
tween.render(((!tween._dirty) ? tween._totalDuration : tween.totalDuration()) - ((time - tween._startTime) * tween._timeScale), suppressEvents, force);
}
}
tween = next;
}
} else {
tween = self._last;
while (tween) {
next = tween._prev; //record it here because the value could change after rendering...
if (curTime !== self._time || (self._paused && !prevPaused)) { //in case a tween pauses or seeks the timeline when rendering, like inside of an onUpdate/onComplete
break;
} else if (tween._active || (tween._startTime <= prevTime && !tween._paused && !tween._gc)) {
if (pauseTween === tween) {
pauseTween = tween._prev; //the linked list is organized by _startTime, thus it's possible that a tween could start BEFORE the pause and end after it, in which case it would be positioned before the pause tween in the linked list, but we should render it before we pause() the timeline and cease rendering. This is only a concern when going in reverse.
while (pauseTween && pauseTween.endTime() > self._time) {
pauseTween.render( (pauseTween._reversed ? pauseTween.totalDuration() - ((time - pauseTween._startTime) * pauseTween._timeScale) : (time - pauseTween._startTime) * pauseTween._timeScale), suppressEvents, force);
pauseTween = pauseTween._prev;
}
pauseTween = null;
self.pause();
self._pauseTime = pauseTime; //so that when we resume(), it's starting from exactly the right spot (the pause() method uses the rawTime for the parent, but that may be a bit too far ahead)
}
if (!tween._reversed) {
tween.render((time - tween._startTime) * tween._timeScale, suppressEvents, force);
} else {
tween.render(((!tween._dirty) ? tween._totalDuration : tween.totalDuration()) - ((time - tween._startTime) * tween._timeScale), suppressEvents, force);
}
}
tween = next;
}
}
if (self._onUpdate) if (!suppressEvents) {
if (_lazyTweens.length) { //in case rendering caused any tweens to lazy-init, we should render them because typically when a timeline finishes, users expect things to have rendered fully. Imagine an onUpdate on a timeline that reports/checks tweened values.
_lazyRender();
}
self._callback("onUpdate");
}
if (callback) if (!self._gc) if (prevStart === self._startTime || prevTimeScale !== self._timeScale) if (self._time === 0 || totalDur >= self.totalDuration()) { //if one of the tweens that was rendered altered this timeline's startTime (like if an onComplete reversed the timeline), it probably isn't complete. If it is, don't worry, because whatever call altered the startTime would complete if it was necessary at the new time. The only exception is the timeScale property. Also check _gc because there's a chance that kill() could be called in an onUpdate
if (isComplete) {
if (_lazyTweens.length) { //in case rendering caused any tweens to lazy-init, we should render them because typically when a timeline finishes, users expect things to have rendered fully. Imagine an onComplete on a timeline that reports/checks tweened values.
_lazyRender();
}
if (self._timeline.autoRemoveChildren) {
self._enabled(false, false);
}
self._active = false;
}
if (!suppressEvents && self.vars[callback]) {
self._callback(callback);
}
}
};
p._hasPausedChild = function() {
var tween = this._first;
while (tween) {
if (tween._paused || ((tween instanceof TimelineLite) && tween._hasPausedChild())) {
return true;
}
tween = tween._next;
}
return false;
};
p.getChildren = function(nested, tweens, timelines, ignoreBeforeTime) {
ignoreBeforeTime = ignoreBeforeTime || -9999999999;
var a = [],
tween = this._first,
cnt = 0;
while (tween) {
if (tween._startTime < ignoreBeforeTime) {
//do nothing
} else if (tween instanceof TweenLite) {
if (tweens !== false) {
a[cnt++] = tween;
}
} else {
if (timelines !== false) {
a[cnt++] = tween;
}
if (nested !== false) {
a = a.concat(tween.getChildren(true, tweens, timelines));
cnt = a.length;
}
}
tween = tween._next;
}
return a;
};
p.getTweensOf = function(target, nested) {
var disabled = this._gc,
a = [],
cnt = 0,
tweens, i;
if (disabled) {
this._enabled(true, true); //getTweensOf() filters out disabled tweens, and we have to mark them as _gc = true when the timeline completes in order to allow clean garbage collection, so temporarily re-enable the timeline here.
}
tweens = TweenLite.getTweensOf(target);
i = tweens.length;
while (--i > -1) {
if (tweens[i].timeline === this || (nested && this._contains(tweens[i]))) {
a[cnt++] = tweens[i];
}
}
if (disabled) {
this._enabled(false, true);
}
return a;
};
p.recent = function() {
return this._recent;
};
p._contains = function(tween) {
var tl = tween.timeline;
while (tl) {
if (tl === this) {
return true;
}
tl = tl.timeline;
}
return false;
};
p.shiftChildren = function(amount, adjustLabels, ignoreBeforeTime) {
ignoreBeforeTime = ignoreBeforeTime || 0;
var tween = this._first,
labels = this._labels,
p;
while (tween) {
if (tween._startTime >= ignoreBeforeTime) {
tween._startTime += amount;
}
tween = tween._next;
}
if (adjustLabels) {
for (p in labels) {
if (labels[p] >= ignoreBeforeTime) {
labels[p] += amount;
}
}
}
return this._uncache(true);
};
p._kill = function(vars, target) {
if (!vars && !target) {
return this._enabled(false, false);
}
var tweens = (!target) ? this.getChildren(true, true, false) : this.getTweensOf(target),
i = tweens.length,
changed = false;
while (--i > -1) {
if (tweens[i]._kill(vars, target)) {
changed = true;
}
}
return changed;
};
p.clear = function(labels) {
var tweens = this.getChildren(false, true, true),
i = tweens.length;
this._time = this._totalTime = 0;
while (--i > -1) {
tweens[i]._enabled(false, false);
}
if (labels !== false) {
this._labels = {};
}
return this._uncache(true);
};
p.invalidate = function() {
var tween = this._first;
while (tween) {
tween.invalidate();
tween = tween._next;
}
return Animation.prototype.invalidate.call(this);;
};
p._enabled = function(enabled, ignoreTimeline) {
if (enabled === this._gc) {
var tween = this._first;
while (tween) {
tween._enabled(enabled, true);
tween = tween._next;
}
}
return SimpleTimeline.prototype._enabled.call(this, enabled, ignoreTimeline);
};
p.totalTime = function(time, suppressEvents, uncapped) {
this._forcingPlayhead = true;
var val = Animation.prototype.totalTime.apply(this, arguments);
this._forcingPlayhead = false;
return val;
};
p.duration = function(value) {
if (!arguments.length) {
if (this._dirty) {
this.totalDuration(); //just triggers recalculation
}
return this._duration;
}
if (this.duration() !== 0 && value !== 0) {
this.timeScale(this._duration / value);
}
return this;
};
p.totalDuration = function(value) {
if (!arguments.length) {
if (this._dirty) {
var max = 0,
self = this,
tween = self._last,
prevStart = 999999999999,
prev, end;
while (tween) {
prev = tween._prev; //record it here in case the tween changes position in the sequence...
if (tween._dirty) {
tween.totalDuration(); //could change the tween._startTime, so make sure the tween's cache is clean before analyzing it.
}
if (tween._startTime > prevStart && self._sortChildren && !tween._paused && !self._calculatingDuration) { //in case one of the tweens shifted out of order, it needs to be re-inserted into the correct position in the sequence
self._calculatingDuration = 1; //prevent endless recursive calls - there are methods that get triggered that check duration/totalDuration when we add(), like _parseTimeOrLabel().
self.add(tween, tween._startTime - tween._delay);
self._calculatingDuration = 0;
} else {
prevStart = tween._startTime;
}
if (tween._startTime < 0 && !tween._paused) { //children aren't allowed to have negative startTimes unless smoothChildTiming is true, so adjust here if one is found.
max -= tween._startTime;
if (self._timeline.smoothChildTiming) {
self._startTime += tween._startTime / self._timeScale;
self._time -= tween._startTime;
self._totalTime -= tween._startTime;
self._rawPrevTime -= tween._startTime;
}
self.shiftChildren(-tween._startTime, false, -9999999999);
prevStart = 0;
}
end = tween._startTime + (tween._totalDuration / tween._timeScale);
if (end > max) {
max = end;
}
tween = prev;
}
self._duration = self._totalDuration = max;
self._dirty = false;
}
return this._totalDuration;
}
return (value && this.totalDuration()) ? this.timeScale(this._totalDuration / value) : this;
};
p.paused = function(value) {
if (value === false && this._paused) { //if there's a pause directly at the spot from where we're unpausing, skip it.
var tween = this._first;
while (tween) {
if (tween._startTime === this._time && tween.data === "isPause") {
tween._rawPrevTime = 0; //remember, _rawPrevTime is how zero-duration tweens/callbacks sense directionality and determine whether or not to fire. If _rawPrevTime is the same as _startTime on the next render, it won't fire.
}
tween = tween._next;
}
}
return Animation.prototype.paused.apply(this, arguments);
};
p.usesFrames = function() {
var tl = this._timeline;
while (tl._timeline) {
tl = tl._timeline;
}
return (tl === Animation._rootFramesTimeline);
};
p.rawTime = function(wrapRepeats) {
return (wrapRepeats && (this._paused || (this._repeat && this.time() > 0 && this.totalProgress() < 1))) ? this._totalTime % (this._duration + this._repeatDelay) : this._paused ? this._totalTime : (this._timeline.rawTime(wrapRepeats) - this._startTime) * this._timeScale;
};
return TimelineLite;
}, true);
}); if (_gsScope._gsDefine) { _gsScope._gsQueue.pop()(); }
//export to AMD/RequireJS and CommonJS/Node (precursor to full modular build system coming at a later date)
(function(name) {
"use strict";
var getGlobal = function() {
return (_gsScope.GreenSockGlobals || _gsScope)[name];
};
if (typeof(module) !== "undefined" && module.exports) { //node
require("./TweenLite.js"); //dependency
module.exports = getGlobal();
} else if (typeof(define) === "function" && define.amd) { //AMD
define(["TweenLite"], getGlobal);
}
}("TimelineLite"));

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,167 @@
/*!
* VERSION: 0.2.1
* DATE: 2018-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
/* eslint-disable */
var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || window; //helps ensure compatibility with AMD/RequireJS and CommonJS/Node
(_gsScope._gsQueue || (_gsScope._gsQueue = [])).push( function() {
"use strict";
_gsScope._gsDefine("easing.CustomBounce", ["easing.CustomEase"], function(CustomEase) {
var _normalizeX = function (a) { //scales all the x values in an array [x, y, x, y...] AND rounds them to the closest hundredth (decimal)
var l = a.length,
s = 1 / a[l - 2],
rnd = 1000,
i;
for (i = 2; i < l; i += 2) {
a[i] = ((a[i] * s * rnd) | 0) / rnd;
}
a[l - 2] = 1; //in case there are any rounding errors. x should always end at 1.
},
CustomBounce = function(id, vars) {
this.vars = vars = vars || {};
if (vars.squash) {
this.squash = new CustomEase(vars.squashID || (id + "-squash"));
}
CustomEase.call(this, id);
this.bounce = this;
this.update(vars);
},
p;
CustomBounce.prototype = p = new CustomEase();
p.constructor = CustomBounce;
p.update = function(vars) {
vars = vars || this.vars;
var max = 0.999,
decay = Math.min(max, vars.strength || 0.7), // Math.min(0.999, 1 - 0.3 / (vars.strength || 1)),
decayX = decay,
gap = (vars.squash || 0) / 100,
originalGap = gap,
slope = 1 / 0.03,
w = 0.2,
h = 1,
prevX = 0.1,
path = [0, 0, 0.07, 0, 0.1, 1, 0.1, 1],
squashPath = [0, 0, 0, 0, 0.1, 0, 0.1, 0],
cp1, cp2, x, y, i, nextX, squishMagnitude;
for (i = 0; i < 200; i++) {
w *= decayX * ((decayX + 1) / 2);
h *= decay * decay;
nextX = prevX + w;
x = prevX + w * 0.49;
y = 1 - h;
cp1 = prevX + h / slope;
cp2 = x + (x - cp1) * 0.8;
if (gap) {
prevX += gap;
cp1 += gap;
x += gap;
cp2 += gap;
nextX += gap;
squishMagnitude = gap / originalGap;
squashPath.push(
prevX - gap, 0,
prevX - gap, squishMagnitude,
prevX - gap / 2, squishMagnitude, //center peak anchor
prevX, squishMagnitude,
prevX, 0,
prevX, 0, //base anchor
prevX, squishMagnitude * -0.6,
prevX + (nextX - prevX) / 6, 0,
nextX, 0
);
path.push(prevX - gap, 1,
prevX, 1,
prevX, 1);
gap *= decay * decay;
}
path.push(prevX, 1,
cp1, y,
x, y,
cp2, y,
nextX, 1,
nextX, 1);
decay *= 0.95;
slope = h / (nextX - cp2);
prevX = nextX;
if (y > max) {
break;
}
}
if (vars.endAtStart) {
x = -0.1;
path.unshift(x, 1, x, 1, -0.07, 0);
if (originalGap) {
gap = originalGap * 2.5; //make the initial anticipation squash longer (more realistic)
x -= gap;
path.unshift(x, 1, x, 1, x, 1);
squashPath.splice(0, 6);
squashPath.unshift(x, 0, x, 0, x, 1, x + gap / 2, 1, x + gap, 1, x + gap, 0, x + gap, 0, x + gap, -0.6, x + gap + 0.033, 0);
for (i = 0; i < squashPath.length; i+=2) {
squashPath[i] -= x;
}
}
for (i = 0; i < path.length; i+=2) {
path[i] -= x;
path[i+1] = 1 - path[i+1];
}
}
if (gap) {
_normalizeX(squashPath);
squashPath[2] = "C" + squashPath[2];
if (!this.squash) {
this.squash = new CustomEase(vars.squashID || (this.id + "-squash"));
}
this.squash.setData("M" + squashPath.join(","));
}
_normalizeX(path);
path[2] = "C" + path[2];
return this.setData("M" + path.join(","));
};
CustomBounce.create = function(id, vars) {
return new CustomBounce(id, vars);
};
CustomBounce.version = "0.2.1";
return CustomBounce;
}, true);
}); if (_gsScope._gsDefine) { _gsScope._gsQueue.pop()(); }
//export to AMD/RequireJS and CommonJS/Node (precursor to full modular build system coming at a later date)
(function(name) {
"use strict";
var getGlobal = function() {
return (_gsScope.GreenSockGlobals || _gsScope)[name];
};
if (typeof(module) !== "undefined" && module.exports) { //node
require("./CustomEase.js");
require("../TweenLite.js");
module.exports = getGlobal();
} else if (typeof(define) === "function" && define.amd) { //AMD
define(["TweenLite", "CustomEase"], getGlobal);
}
}("CustomBounce"));

View File

@ -0,0 +1,394 @@
/*!
* VERSION: 0.2.2
* DATE: 2018-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
/* eslint-disable */
var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || window; //helps ensure compatibility with AMD/RequireJS and CommonJS/Node
(_gsScope._gsQueue || (_gsScope._gsQueue = [])).push( function() {
"use strict";
_gsScope._gsDefine("easing.CustomEase", ["easing.Ease"], function(Ease) {
var _numbersExp = /(?:(-|-=|\+=)?\d*\.?\d*(?:e[\-+]?\d+)?)[0-9]/ig,
_svgPathExp = /[achlmqstvz]|(-?\d*\.?\d*(?:e[\-+]?\d+)?)[0-9]/ig,
_scientific = /[\+\-]?\d*\.?\d+e[\+\-]?\d+/ig,
_needsParsingExp = /[cLlsS]/g,
_bezierError = "CustomEase only accepts Cubic Bezier data.",
_bezierToPoints = function (x1, y1, x2, y2, x3, y3, x4, y4, threshold, points, index) {
var x12 = (x1 + x2) / 2,
y12 = (y1 + y2) / 2,
x23 = (x2 + x3) / 2,
y23 = (y2 + y3) / 2,
x34 = (x3 + x4) / 2,
y34 = (y3 + y4) / 2,
x123 = (x12 + x23) / 2,
y123 = (y12 + y23) / 2,
x234 = (x23 + x34) / 2,
y234 = (y23 + y34) / 2,
x1234 = (x123 + x234) / 2,
y1234 = (y123 + y234) / 2,
dx = x4 - x1,
dy = y4 - y1,
d2 = Math.abs((x2 - x4) * dy - (y2 - y4) * dx),
d3 = Math.abs((x3 - x4) * dy - (y3 - y4) * dx),
length;
if (!points) {
points = [{x: x1, y: y1}, {x: x4, y: y4}];
index = 1;
}
points.splice(index || points.length - 1, 0, {x: x1234, y: y1234});
if ((d2 + d3) * (d2 + d3) > threshold * (dx * dx + dy * dy)) {
length = points.length;
_bezierToPoints(x1, y1, x12, y12, x123, y123, x1234, y1234, threshold, points, index);
_bezierToPoints(x1234, y1234, x234, y234, x34, y34, x4, y4, threshold, points, index + 1 + (points.length - length));
}
return points;
},
_pathDataToBezier = function (d) {
var a = (d + "").replace(_scientific, function (m) {
var n = +m;
return (n < 0.0001 && n > -0.0001) ? 0 : n;
}).match(_svgPathExp) || [], //some authoring programs spit out very small numbers in scientific notation like "1e-5", so make sure we round that down to 0 first.
path = [],
relativeX = 0,
relativeY = 0,
elements = a.length,
l = 2,
i, x, y, command, isRelative, segment, startX, startY, prevCommand, difX, difY;
for (i = 0; i < elements; i++) {
prevCommand = command;
if (isNaN(a[i])) {
command = a[i].toUpperCase();
isRelative = (command !== a[i]); //lower case means relative
} else { //commands like "C" can be strung together without any new command characters between.
i--;
}
x = +a[i + 1];
y = +a[i + 2];
if (isRelative) {
x += relativeX;
y += relativeY;
}
if (!i) {
startX = x;
startY = y;
}
if (command === "M") {
if (segment && segment.length < 8) { //if the path data was funky and just had a M with no actual drawing anywhere, skip it.
path.length -= 1;
l = 0;
}
relativeX = startX = x;
relativeY = startY = y;
segment = [x, y];
l = 2;
path.push(segment);
i += 2;
command = "L"; //an "M" with more than 2 values gets interpreted as "lineTo" commands ("L").
} else if (command === "C") {
if (!segment) {
segment = [0, 0];
}
segment[l++] = x;
segment[l++] = y;
if (!isRelative) {
relativeX = relativeY = 0;
}
segment[l++] = relativeX + a[i + 3] * 1; //note: "*1" is just a fast/short way to cast the value as a Number. WAAAY faster in Chrome, slightly slower in Firefox.
segment[l++] = relativeY + a[i + 4] * 1;
segment[l++] = relativeX = relativeX + a[i + 5] * 1;
segment[l++] = relativeY = relativeY + a[i + 6] * 1;
i += 6;
} else if (command === "S") {
if (prevCommand === "C" || prevCommand === "S") {
difX = relativeX - segment[l - 4];
difY = relativeY - segment[l - 3];
segment[l++] = relativeX + difX;
segment[l++] = relativeY + difY;
} else {
segment[l++] = relativeX;
segment[l++] = relativeY;
}
segment[l++] = x;
segment[l++] = y;
if (!isRelative) {
relativeX = relativeY = 0;
}
segment[l++] = relativeX = relativeX + a[i + 3] * 1;
segment[l++] = relativeY = relativeY + a[i + 4] * 1;
i += 4;
} else if (command === "L" || command === "Z") {
if (command === "Z") {
x = startX;
y = startY;
segment.closed = true;
}
if (command === "L" || Math.abs(relativeX - x) > 0.5 || Math.abs(relativeY - y) > 0.5) {
segment[l++] = relativeX + (x - relativeX) / 3;
segment[l++] = relativeY + (y - relativeY) / 3;
segment[l++] = relativeX + (x - relativeX) * 2 / 3;
segment[l++] = relativeY + (y - relativeY) * 2 / 3;
segment[l++] = x;
segment[l++] = y;
if (command === "L") {
i += 2;
}
}
relativeX = x;
relativeY = y;
} else {
throw _bezierError;
}
}
return path[0];
},
_findMinimum = function (values) {
var l = values.length,
min = 999999999999,
i;
for (i = 1; i < l; i += 6) {
if (+values[i] < min) {
min = +values[i];
}
}
return min;
},
_normalize = function (values, height, originY) { //takes all the points and translates/scales them so that the x starts at 0 and ends at 1.
if (!originY && originY !== 0) {
originY = Math.max(+values[values.length-1], +values[1]);
}
var tx = +values[0] * -1,
ty = -originY,
l = values.length,
sx = 1 / (+values[l - 2] + tx),
sy = -height || ((Math.abs(+values[l - 1] - +values[1]) < 0.01 * (+values[l - 2] - +values[0])) ? _findMinimum(values) + ty : +values[l - 1] + ty),
i;
if (sy) { //typically y ends at 1 (so that the end values are reached)
sy = 1 / sy;
} else { //in case the ease returns to its beginning value, scale everything proportionally
sy = -sx;
}
for (i = 0; i < l; i += 2) {
values[i] = (+values[i] + tx) * sx;
values[i + 1] = (+values[i + 1] + ty) * sy;
}
},
_getRatio = function (p) {
var point = this.lookup[(p * this.l) | 0] || this.lookup[this.l - 1];
if (point.nx < p) {
point = point.n;
}
return point.y + ((p - point.x) / point.cx) * point.cy;
},
CustomEase = function (id, data, config) {
this._calcEnd = true;
this.id = id;
if (id) {
Ease.map[id] = this;
}
this.getRatio = _getRatio; //speed optimization, faster lookups.
this.setData(data, config);
},
p = CustomEase.prototype = new Ease();
p.constructor = CustomEase;
p.setData = function(data, config) {
data = data || "0,0,1,1";
var values = data.match(_numbersExp),
closest = 1,
points = [],
l, a1, a2, i, inc, j, point, prevPoint, p, precision;
config = config || {};
precision = config.precision || 1;
this.data = data;
this.lookup = [];
this.points = points;
this.fast = (precision <= 1);
if (_needsParsingExp.test(data) || (data.indexOf("M") !== -1 && data.indexOf("C") === -1)) {
values = _pathDataToBezier(data);
}
l = values.length;
if (l === 4) {
values.unshift(0, 0);
values.push(1, 1);
l = 8;
} else if ((l - 2) % 6) {
throw _bezierError;
}
if (+values[0] !== 0 || +values[l - 2] !== 1) {
_normalize(values, config.height, config.originY);
}
this.rawBezier = values;
for (i = 2; i < l; i += 6) {
a1 = {x: +values[i - 2], y: +values[i - 1]};
a2 = {x: +values[i + 4], y: +values[i + 5]};
points.push(a1, a2);
_bezierToPoints(a1.x, a1.y, +values[i], +values[i + 1], +values[i + 2], +values[i + 3], a2.x, a2.y, 1 / (precision * 200000), points, points.length - 1);
}
l = points.length;
for (i = 0; i < l; i++) {
point = points[i];
prevPoint = points[i - 1] || point;
if (point.x > prevPoint.x || (prevPoint.y !== point.y && prevPoint.x === point.x) || point === prevPoint) { //if a point goes BACKWARD in time or is a duplicate, just drop it.
prevPoint.cx = point.x - prevPoint.x; //change in x between this point and the next point (performance optimization)
prevPoint.cy = point.y - prevPoint.y;
prevPoint.n = point;
prevPoint.nx = point.x; //next point's x value (performance optimization, making lookups faster in getRatio()). Remember, the lookup will always land on a spot where it's either this point or the very next one (never beyond that)
if (this.fast && i > 1 && Math.abs(prevPoint.cy / prevPoint.cx - points[i - 2].cy / points[i - 2].cx) > 2) { //if there's a sudden change in direction, prioritize accuracy over speed. Like a bounce ease - you don't want to risk the sampling chunks landing on each side of the bounce anchor and having it clipped off.
this.fast = false;
}
if (prevPoint.cx < closest) {
if (!prevPoint.cx) {
prevPoint.cx = 0.001; //avoids math problems in getRatio() (dividing by zero)
if (i === l - 1) { //in case the final segment goes vertical RIGHT at the end, make sure we end at the end.
prevPoint.x -= 0.001;
closest = Math.min(closest, 0.001);
this.fast = false;
}
} else {
closest = prevPoint.cx;
}
}
} else {
points.splice(i--, 1);
l--;
}
}
l = (1 / closest + 1) | 0;
this.l = l; //record for speed optimization
inc = 1 / l;
j = 0;
point = points[0];
if (this.fast) {
for (i = 0; i < l; i++) { //for fastest lookups, we just sample along the path at equal x (time) distance. Uses more memory and is slightly less accurate for anchors that don't land on the sampling points, but for the vast majority of eases it's excellent (and fast).
p = i * inc;
if (point.nx < p) {
point = points[++j];
}
a1 = point.y + ((p - point.x) / point.cx) * point.cy;
this.lookup[i] = {x: p, cx: inc, y: a1, cy: 0, nx: 9};
if (i) {
this.lookup[i - 1].cy = a1 - this.lookup[i - 1].y;
}
}
this.lookup[l - 1].cy = points[points.length - 1].y - a1;
} else { //this option is more accurate, ensuring that EVERY anchor is hit perfectly. Clipping across a bounce, for example, would never happen.
for (i = 0; i < l; i++) { //build a lookup table based on the smallest distance so that we can instantly find the appropriate point (well, it'll either be that point or the very next one). We'll look up based on the linear progress. So it's it's 0.5 and the lookup table has 100 elements, it'd be like lookup[Math.floor(0.5 * 100)]
if (point.nx < i * inc) {
point = points[++j];
}
this.lookup[i] = point;
}
if (j < points.length - 1) {
this.lookup[i-1] = points[points.length-2];
}
}
this._calcEnd = (points[points.length-1].y !== 1 || points[0].y !== 0); //ensures that we don't run into floating point errors. As long as we're starting at 0 and ending at 1, tell GSAP to skip the final calculation and use 0/1 as the factor.
return this;
};
p.getRatio = _getRatio;
p.getSVGData = function(config) {
return CustomEase.getSVGData(this, config);
};
CustomEase.create = function (id, data, config) {
return new CustomEase(id, data, config);
};
CustomEase.version = "0.2.2";
CustomEase.bezierToPoints = _bezierToPoints;
CustomEase.get = function (id) {
return Ease.map[id];
};
CustomEase.getSVGData = function(ease, config) {
config = config || {};
var rnd = 1000,
width = config.width || 100,
height = config.height || 100,
x = config.x || 0,
y = (config.y || 0) + height,
e = config.path,
a, slope, i, inc, tx, ty, precision, threshold, prevX, prevY;
if (config.invert) {
height = -height;
y = 0;
}
ease = ease.getRatio ? ease : Ease.map[ease] || console.log("No ease found: ", ease);
if (!ease.rawBezier) {
a = ["M" + x + "," + y];
precision = Math.max(5, (config.precision || 1) * 200);
inc = 1 / precision;
precision += 2;
threshold = 5 / precision;
prevX = (((x + inc * width) * rnd) | 0) / rnd;
prevY = (((y + ease.getRatio(inc) * -height) * rnd) | 0) / rnd;
slope = (prevY - y) / (prevX - x);
for (i = 2; i < precision; i++) {
tx = (((x + i * inc * width) * rnd) | 0) / rnd;
ty = (((y + ease.getRatio(i * inc) * -height) * rnd) | 0) / rnd;
if (Math.abs((ty - prevY) / (tx - prevX) - slope) > threshold || i === precision - 1) { //only add points when the slope changes beyond the threshold
a.push(prevX + "," + prevY);
slope = (ty - prevY) / (tx - prevX);
}
prevX = tx;
prevY = ty;
}
} else {
a = [];
precision = ease.rawBezier.length;
for (i = 0; i < precision; i += 2) {
a.push((((x + ease.rawBezier[i] * width) * rnd) | 0) / rnd + "," + (((y + ease.rawBezier[i + 1] * -height) * rnd) | 0) / rnd);
}
a[0] = "M" + a[0];
a[1] = "C" + a[1];
}
if (e) {
(typeof(e) === "string" ? document.querySelector(e) : e).setAttribute("d", a.join(" "));
}
return a.join(" ");
};
return CustomEase;
}, true);
}); if (_gsScope._gsDefine) { _gsScope._gsQueue.pop()(); }
//export to AMD/RequireJS and CommonJS/Node (precursor to full modular build system coming at a later date)
(function(name) {
"use strict";
var getGlobal = function() {
return (_gsScope.GreenSockGlobals || _gsScope)[name];
};
if (typeof(module) !== "undefined" && module.exports) { //node
require("../TweenLite.js");
module.exports = getGlobal();
} else if (typeof(define) === "function" && define.amd) { //AMD
define(["TweenLite"], getGlobal);
}
}("CustomEase"));

View File

@ -0,0 +1,128 @@
/*!
* VERSION: 0.2.1
* DATE: 2018-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
/* eslint-disable */
var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || window; //helps ensure compatibility with AMD/RequireJS and CommonJS/Node
(_gsScope._gsQueue || (_gsScope._gsQueue = [])).push( function() {
"use strict";
_gsScope._gsDefine("easing.CustomWiggle", ["easing.CustomEase", "easing.Ease"], function(CustomEase, Ease) {
var eases = {
easeOut: new CustomEase("", "M0,1,C0.7,1,0.6,0,1,0"),
easeInOut: new CustomEase("", "M0,0,C0.104,0,0.242,1,0.444,1,0.644,1,0.608,0,1,0"),
anticipate: new CustomEase("", "M0,0,C0,0.222,0.024,0.386,0.06,0.402,0.181,0.455,0.647,0.646,0.7,0.67,0.9,0.76,1,0.846,1,1"),
uniform: new CustomEase("", "M0,0,C0,0.95,0.01,1,0.01,1,0.01,1,1,1,1,1,1,1,1,0.01,1,0")
},
_linearEase = new CustomEase(), //linear
_parseEase = function(ease, invertNonCustomEases) {
ease = ease.getRatio ? ease : Ease.map[ease] || new CustomEase("", ease);
return (ease.rawBezier || !invertNonCustomEases) ? ease : {getRatio:function(n) { return 1 - ease.getRatio(n); }};
},
CustomWiggle = function(id, vars) {
this.vars = vars || {};
CustomEase.call(this, id);
this.update(this.vars);
},
p;
CustomWiggle.prototype = p = new CustomEase();
p.constructor = CustomWiggle;
p.update = function(vars) {
vars = vars || this.vars;
var wiggles = (vars.wiggles || 10) | 0,
inc = 1 / wiggles,
x = inc / 2,
anticipate = (vars.type === "anticipate"),
yEase = eases[vars.type] || eases.easeOut,
xEase = _linearEase,
rnd = 1000,
nextX, nextY, angle, handleX, handleY, easedX, y, path, i;
if (anticipate) { //the anticipate ease is actually applied on the x-axis (timing) and uses easeOut for amplitude.
xEase = yEase;
yEase = eases.easeOut;
}
if (vars.timingEase) {
xEase = _parseEase(vars.timingEase);
}
if (vars.amplitudeEase) {
yEase = _parseEase(vars.amplitudeEase, true);
}
easedX = xEase.getRatio(x);
y = anticipate ? -yEase.getRatio(x) : yEase.getRatio(x);
path = [0, 0, easedX / 4, 0, easedX / 2, y, easedX, y];
if (vars.type === "random") { //if we just select random values on the y-axis and plug them into the "normal" algorithm, since the control points are always straight horizontal, it creates a bit of a slowdown at each anchor which just didn't seem as desirable, so we switched to an algorithm that bends the control points to be more in line with their context.
path.length = 4;
nextX = xEase.getRatio(inc);
nextY = Math.random() * 2 - 1;
for (i = 2; i < wiggles; i++) {
x = nextX;
y = nextY;
nextX = xEase.getRatio(inc * i);
nextY = Math.random() * 2 - 1;
angle = Math.atan2(nextY - path[path.length - 3], nextX - path[path.length - 4]);
handleX = Math.cos(angle) * inc;
handleY = Math.sin(angle) * inc;
path.push(x - handleX, y - handleY, x, y, x + handleX, y + handleY);
}
path.push(nextX, 0, 1, 0);
} else {
for (i = 1; i < wiggles; i++) {
path.push(xEase.getRatio(x + inc / 2), y);
x += inc;
y = ((y > 0) ? -1 : 1) * (yEase.getRatio(i * inc));
easedX = xEase.getRatio(x);
path.push(xEase.getRatio(x - inc / 2), y, easedX, y);
}
path.push(xEase.getRatio(x + inc / 4), y, xEase.getRatio(x + inc / 4), 0, 1, 0);
}
i = path.length;
while (--i > -1) {
path[i] = ((path[i] * rnd) | 0) / rnd; //round values to avoid odd strings for super tiny values
}
path[2] = "C" + path[2];
this.setData("M" + path.join(","));
};
CustomWiggle.create = function (id, vars) {
return new CustomWiggle(id, vars);
};
CustomWiggle.version = "0.2.1";
CustomWiggle.eases = eases;
return CustomWiggle;
}, true);
}); if (_gsScope._gsDefine) { _gsScope._gsQueue.pop()(); }
//export to AMD/RequireJS and CommonJS/Node (precursor to full modular build system coming at a later date)
(function(name) {
"use strict";
var getGlobal = function() {
return (_gsScope.GreenSockGlobals || _gsScope)[name];
};
if (typeof(module) !== "undefined" && module.exports) { //node
require("./CustomEase.js");
require("../TweenLite.js");
module.exports = getGlobal();
} else if (typeof(define) === "function" && define.amd) { //AMD
define(["TweenLite", "CustomEase"], getGlobal);
}
}("CustomWiggle"));

View File

@ -0,0 +1,381 @@
/*!
* VERSION: 1.16.0
* DATE: 2018-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
/* eslint-disable */
var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || window; //helps ensure compatibility with AMD/RequireJS and CommonJS/Node
(_gsScope._gsQueue || (_gsScope._gsQueue = [])).push( function() {
"use strict";
_gsScope._gsDefine("easing.Back", ["easing.Ease"], function(Ease) {
var w = (_gsScope.GreenSockGlobals || _gsScope),
gs = w.com.greensock,
_2PI = Math.PI * 2,
_HALF_PI = Math.PI / 2,
_class = gs._class,
_create = function(n, f) {
var C = _class("easing." + n, function(){}, true),
p = C.prototype = new Ease();
p.constructor = C;
p.getRatio = f;
return C;
},
_easeReg = Ease.register || function(){}, //put an empty function in place just as a safety measure in case someone loads an OLD version of TweenLite.js where Ease.register doesn't exist.
_wrap = function(name, EaseOut, EaseIn, EaseInOut, aliases) {
var C = _class("easing."+name, {
easeOut:new EaseOut(),
easeIn:new EaseIn(),
easeInOut:new EaseInOut()
}, true);
_easeReg(C, name);
return C;
},
EasePoint = function(time, value, next) {
this.t = time;
this.v = value;
if (next) {
this.next = next;
next.prev = this;
this.c = next.v - value;
this.gap = next.t - time;
}
},
//Back
_createBack = function(n, f) {
var C = _class("easing." + n, function(overshoot) {
this._p1 = (overshoot || overshoot === 0) ? overshoot : 1.70158;
this._p2 = this._p1 * 1.525;
}, true),
p = C.prototype = new Ease();
p.constructor = C;
p.getRatio = f;
p.config = function(overshoot) {
return new C(overshoot);
};
return C;
},
Back = _wrap("Back",
_createBack("BackOut", function(p) {
return ((p = p - 1) * p * ((this._p1 + 1) * p + this._p1) + 1);
}),
_createBack("BackIn", function(p) {
return p * p * ((this._p1 + 1) * p - this._p1);
}),
_createBack("BackInOut", function(p) {
return ((p *= 2) < 1) ? 0.5 * p * p * ((this._p2 + 1) * p - this._p2) : 0.5 * ((p -= 2) * p * ((this._p2 + 1) * p + this._p2) + 2);
})
),
//SlowMo
SlowMo = _class("easing.SlowMo", function(linearRatio, power, yoyoMode) {
power = (power || power === 0) ? power : 0.7;
if (linearRatio == null) {
linearRatio = 0.7;
} else if (linearRatio > 1) {
linearRatio = 1;
}
this._p = (linearRatio !== 1) ? power : 0;
this._p1 = (1 - linearRatio) / 2;
this._p2 = linearRatio;
this._p3 = this._p1 + this._p2;
this._calcEnd = (yoyoMode === true);
}, true),
p = SlowMo.prototype = new Ease(),
SteppedEase, ExpoScaleEase, RoughEase, _createElastic;
p.constructor = SlowMo;
p.getRatio = function(p) {
var r = p + (0.5 - p) * this._p;
if (p < this._p1) {
return this._calcEnd ? 1 - ((p = 1 - (p / this._p1)) * p) : r - ((p = 1 - (p / this._p1)) * p * p * p * r);
} else if (p > this._p3) {
return this._calcEnd ? (p === 1 ? 0 : 1 - (p = (p - this._p3) / this._p1) * p) : r + ((p - r) * (p = (p - this._p3) / this._p1) * p * p * p); //added p === 1 ? 0 to avoid floating point rounding errors from affecting the final value, like 1 - 0.7 = 0.30000000000000004 instead of 0.3
}
return this._calcEnd ? 1 : r;
};
SlowMo.ease = new SlowMo(0.7, 0.7);
p.config = SlowMo.config = function(linearRatio, power, yoyoMode) {
return new SlowMo(linearRatio, power, yoyoMode);
};
//SteppedEase
SteppedEase = _class("easing.SteppedEase", function(steps, immediateStart) {
steps = steps || 1;
this._p1 = 1 / steps;
this._p2 = steps + (immediateStart ? 0 : 1);
this._p3 = immediateStart ? 1 : 0;
}, true);
p = SteppedEase.prototype = new Ease();
p.constructor = SteppedEase;
p.getRatio = function(p) {
if (p < 0) {
p = 0;
} else if (p >= 1) {
p = 0.999999999;
}
return (((this._p2 * p) | 0) + this._p3) * this._p1;
};
p.config = SteppedEase.config = function(steps, immediateStart) {
return new SteppedEase(steps, immediateStart);
};
//ExpoScaleEase
ExpoScaleEase = _class("easing.ExpoScaleEase", function(start, end, ease) {
this._p1 = Math.log(end / start);
this._p2 = end - start;
this._p3 = start;
this._ease = ease;
}, true);
p = ExpoScaleEase.prototype = new Ease();
p.constructor = ExpoScaleEase;
p.getRatio = function(p) {
if (this._ease) {
p = this._ease.getRatio(p);
}
return (this._p3 * Math.exp(this._p1 * p) - this._p3) / this._p2;
};
p.config = ExpoScaleEase.config = function(start, end, ease) {
return new ExpoScaleEase(start, end, ease);
};
//RoughEase
RoughEase = _class("easing.RoughEase", function(vars) {
vars = vars || {};
var taper = vars.taper || "none",
a = [],
cnt = 0,
points = (vars.points || 20) | 0,
i = points,
randomize = (vars.randomize !== false),
clamp = (vars.clamp === true),
template = (vars.template instanceof Ease) ? vars.template : null,
strength = (typeof(vars.strength) === "number") ? vars.strength * 0.4 : 0.4,
x, y, bump, invX, obj, pnt;
while (--i > -1) {
x = randomize ? Math.random() : (1 / points) * i;
y = template ? template.getRatio(x) : x;
if (taper === "none") {
bump = strength;
} else if (taper === "out") {
invX = 1 - x;
bump = invX * invX * strength;
} else if (taper === "in") {
bump = x * x * strength;
} else if (x < 0.5) { //"both" (start)
invX = x * 2;
bump = invX * invX * 0.5 * strength;
} else { //"both" (end)
invX = (1 - x) * 2;
bump = invX * invX * 0.5 * strength;
}
if (randomize) {
y += (Math.random() * bump) - (bump * 0.5);
} else if (i % 2) {
y += bump * 0.5;
} else {
y -= bump * 0.5;
}
if (clamp) {
if (y > 1) {
y = 1;
} else if (y < 0) {
y = 0;
}
}
a[cnt++] = {x:x, y:y};
}
a.sort(function(a, b) {
return a.x - b.x;
});
pnt = new EasePoint(1, 1, null);
i = points;
while (--i > -1) {
obj = a[i];
pnt = new EasePoint(obj.x, obj.y, pnt);
}
this._prev = new EasePoint(0, 0, (pnt.t !== 0) ? pnt : pnt.next);
}, true);
p = RoughEase.prototype = new Ease();
p.constructor = RoughEase;
p.getRatio = function(p) {
var pnt = this._prev;
if (p > pnt.t) {
while (pnt.next && p >= pnt.t) {
pnt = pnt.next;
}
pnt = pnt.prev;
} else {
while (pnt.prev && p <= pnt.t) {
pnt = pnt.prev;
}
}
this._prev = pnt;
return (pnt.v + ((p - pnt.t) / pnt.gap) * pnt.c);
};
p.config = function(vars) {
return new RoughEase(vars);
};
RoughEase.ease = new RoughEase();
//Bounce
_wrap("Bounce",
_create("BounceOut", function(p) {
if (p < 1 / 2.75) {
return 7.5625 * p * p;
} else if (p < 2 / 2.75) {
return 7.5625 * (p -= 1.5 / 2.75) * p + 0.75;
} else if (p < 2.5 / 2.75) {
return 7.5625 * (p -= 2.25 / 2.75) * p + 0.9375;
}
return 7.5625 * (p -= 2.625 / 2.75) * p + 0.984375;
}),
_create("BounceIn", function(p) {
if ((p = 1 - p) < 1 / 2.75) {
return 1 - (7.5625 * p * p);
} else if (p < 2 / 2.75) {
return 1 - (7.5625 * (p -= 1.5 / 2.75) * p + 0.75);
} else if (p < 2.5 / 2.75) {
return 1 - (7.5625 * (p -= 2.25 / 2.75) * p + 0.9375);
}
return 1 - (7.5625 * (p -= 2.625 / 2.75) * p + 0.984375);
}),
_create("BounceInOut", function(p) {
var invert = (p < 0.5);
if (invert) {
p = 1 - (p * 2);
} else {
p = (p * 2) - 1;
}
if (p < 1 / 2.75) {
p = 7.5625 * p * p;
} else if (p < 2 / 2.75) {
p = 7.5625 * (p -= 1.5 / 2.75) * p + 0.75;
} else if (p < 2.5 / 2.75) {
p = 7.5625 * (p -= 2.25 / 2.75) * p + 0.9375;
} else {
p = 7.5625 * (p -= 2.625 / 2.75) * p + 0.984375;
}
return invert ? (1 - p) * 0.5 : p * 0.5 + 0.5;
})
);
//CIRC
_wrap("Circ",
_create("CircOut", function(p) {
return Math.sqrt(1 - (p = p - 1) * p);
}),
_create("CircIn", function(p) {
return -(Math.sqrt(1 - (p * p)) - 1);
}),
_create("CircInOut", function(p) {
return ((p*=2) < 1) ? -0.5 * (Math.sqrt(1 - p * p) - 1) : 0.5 * (Math.sqrt(1 - (p -= 2) * p) + 1);
})
);
//Elastic
_createElastic = function(n, f, def) {
var C = _class("easing." + n, function(amplitude, period) {
this._p1 = (amplitude >= 1) ? amplitude : 1; //note: if amplitude is < 1, we simply adjust the period for a more natural feel. Otherwise the math doesn't work right and the curve starts at 1.
this._p2 = (period || def) / (amplitude < 1 ? amplitude : 1);
this._p3 = this._p2 / _2PI * (Math.asin(1 / this._p1) || 0);
this._p2 = _2PI / this._p2; //precalculate to optimize
}, true),
p = C.prototype = new Ease();
p.constructor = C;
p.getRatio = f;
p.config = function(amplitude, period) {
return new C(amplitude, period);
};
return C;
};
_wrap("Elastic",
_createElastic("ElasticOut", function(p) {
return this._p1 * Math.pow(2, -10 * p) * Math.sin( (p - this._p3) * this._p2 ) + 1;
}, 0.3),
_createElastic("ElasticIn", function(p) {
return -(this._p1 * Math.pow(2, 10 * (p -= 1)) * Math.sin( (p - this._p3) * this._p2 ));
}, 0.3),
_createElastic("ElasticInOut", function(p) {
return ((p *= 2) < 1) ? -0.5 * (this._p1 * Math.pow(2, 10 * (p -= 1)) * Math.sin( (p - this._p3) * this._p2)) : this._p1 * Math.pow(2, -10 *(p -= 1)) * Math.sin( (p - this._p3) * this._p2 ) * 0.5 + 1;
}, 0.45)
);
//Expo
_wrap("Expo",
_create("ExpoOut", function(p) {
return 1 - Math.pow(2, -10 * p);
}),
_create("ExpoIn", function(p) {
return Math.pow(2, 10 * (p - 1)) - 0.001;
}),
_create("ExpoInOut", function(p) {
return ((p *= 2) < 1) ? 0.5 * Math.pow(2, 10 * (p - 1)) : 0.5 * (2 - Math.pow(2, -10 * (p - 1)));
})
);
//Sine
_wrap("Sine",
_create("SineOut", function(p) {
return Math.sin(p * _HALF_PI);
}),
_create("SineIn", function(p) {
return -Math.cos(p * _HALF_PI) + 1;
}),
_create("SineInOut", function(p) {
return -0.5 * (Math.cos(Math.PI * p) - 1);
})
);
_class("easing.EaseLookup", {
find:function(s) {
return Ease.map[s];
}
}, true);
//register the non-standard eases
_easeReg(w.SlowMo, "SlowMo", "ease,");
_easeReg(RoughEase, "RoughEase", "ease,");
_easeReg(SteppedEase, "SteppedEase", "ease,");
return Back;
}, true);
}); if (_gsScope._gsDefine) { _gsScope._gsQueue.pop()(); }
//export to AMD/RequireJS and CommonJS/Node (precursor to full modular build system coming at a later date)
(function() {
"use strict";
var getGlobal = function() {
return (_gsScope.GreenSockGlobals || _gsScope);
};
if (typeof(module) !== "undefined" && module.exports) { //node
require("../TweenLite.js");
module.exports = getGlobal();
} else if (typeof(define) === "function" && define.amd) { //AMD
define(["TweenLite"], getGlobal);
}
}());

View File

@ -0,0 +1,184 @@
/*!
* VERSION: 0.1.13
* DATE: 2018-08-27
* UPDATES AND DOCS AT: http://greensock.com/jquery-gsap-plugin/
*
* Requires TweenLite version 1.8.0 or higher and CSSPlugin.
*
* @license Copyright (c) 2013-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
(function($) {
"use strict";
var _animate = $.fn.animate,
_stop = $.fn.stop,
_enabled = true,
TweenLite, CSSPlugin, _warned,
_copy = function(o) {
var copy = {},
p;
for (p in o) {
copy[p] = o[p];
}
return copy;
},
_reserved = {overwrite:1, delay:1, useFrames:1, runBackwards:1, easeParams:1, yoyo:1, immediateRender:1, repeat:1, repeatDelay:1, autoCSS:1},
_defaultLegacyProps = ",scrollTop,scrollLeft,show,hide,toggle,",
_legacyProps = _defaultLegacyProps,
_copyCriticalReserved = function(main, sub) {
for (var p in _reserved) {
if (_reserved[p] && main[p] !== undefined) {
sub[p] = main[p];
}
}
},
_createEase = function(ease) {
return function(p) {
return ease.getRatio(p);
};
},
_easeMap = {},
_init = function() {
var globals = window.GreenSockGlobals || window,
p;
TweenLite = globals.TweenMax || globals.TweenLite; //we prioritize TweenMax if it's loaded so that we can accommodate special features like repeat, yoyo, repeatDelay, etc.
if (TweenLite) {
globals = globals.com.greensock;
CSSPlugin = globals.plugins.CSSPlugin;
_easeMap = globals.easing.Ease.map || {}; //don't do just window.Ease or window.CSSPlugin because some other libraries like EaselJS/TweenJS use those same names and there could be a collision.
}
if (!TweenLite || !CSSPlugin) {
TweenLite = null;
if (!_warned && window.console) {
window.console.log("The jquery.gsap.js plugin requires the TweenMax (or at least TweenLite and CSSPlugin) JavaScript file(s).");
_warned = true;
}
return;
}
if ($.easing) {
for (p in _easeMap) {
$.easing[p] = _createEase(_easeMap[p]);
}
_init = false;
}
};
$.fn.animate = function(prop, speed, easing, callback) {
prop = prop || {};
if (_init) {
_init();
if (!TweenLite || !CSSPlugin) {
return _animate.call(this, prop, speed, easing, callback);
}
}
if (!_enabled || prop.skipGSAP === true || (typeof(speed) === "object" && typeof(speed.step) === "function")) { //we don't support the "step" feature because it's too costly performance-wise, so fall back to the native animate() call if we sense one. Same with scrollTop and scrollLeft which are handled in a special way in jQuery.
return _animate.call(this, prop, speed, easing, callback);
}
var config = $.speed(speed, easing, callback),
vars = {ease:(_easeMap[config.easing] || ((config.easing === false) ? _easeMap.linear : _easeMap.swing))},
obj = this,
specEasing = (typeof(speed) === "object") ? speed.specialEasing : null,
val, p, doAnimation, specEasingVars;
for (p in prop) {
val = prop[p];
if (val instanceof Array && _easeMap[val[1]]) {
specEasing = specEasing || {};
specEasing[p] = val[1];
val = val[0];
}
if (val === "show" || val === "hide" || val === "toggle" || (_legacyProps.indexOf(p) !== -1 && _legacyProps.indexOf("," + p + ",") !== -1)) { //note: slideUp() and slideDown() pass in opacity:"show" or opacity:"hide"
return _animate.call(this, prop, speed, easing, callback);
} else {
vars[(p.indexOf("-") === -1) ? p : $.camelCase(p)] = val;
}
}
if (specEasing) {
vars = _copy(vars);
specEasingVars = [];
for (p in specEasing) {
val = specEasingVars[specEasingVars.length] = {};
_copyCriticalReserved(vars, val);
val.ease = (_easeMap[specEasing[p]] || vars.ease);
if (p.indexOf("-") !== -1) {
p = $.camelCase(p);
}
val[p] = vars[p];
delete vars[p];
}
if (specEasingVars.length === 0) {
specEasingVars = null;
}
}
doAnimation = function(next) {
var varsCopy = _copy(vars),
i;
if (specEasingVars) {
i = specEasingVars.length;
while (--i > -1) {
TweenLite.to(this, $.fx.off ? 0 : config.duration / 1000, specEasingVars[i]);
}
}
varsCopy.onComplete = function() {
if (next) {
next();
} else if (config.old) {
$(this).each(config.old);
}
};
TweenLite.to(this, $.fx.off ? 0 : config.duration / 1000, varsCopy);
};
if (config.queue !== false) {
obj.queue(config.queue, doAnimation); //note: the queued function will get called once for each element in the jQuery collection.
if (typeof(config.old) === "function") {
$(obj[obj.length-1]).queue(config.queue, function(next) {
config.old.call(obj);
next();
});
}
} else {
doAnimation.call(obj);
}
return obj;
};
$.fn.stop = function(clearQueue, gotoEnd) {
_stop.call(this, clearQueue, gotoEnd);
if (TweenLite) {
if (gotoEnd) {
var tweens = TweenLite.getTweensOf(this),
i = tweens.length,
progress;
while (--i > -1) {
progress = tweens[i].totalTime() / tweens[i].totalDuration();
if (progress > 0 && progress < 1) {
tweens[i].seek(tweens[i].totalDuration());
}
}
}
TweenLite.killTweensOf(this);
}
return this;
};
$.gsap = {
enabled:function(value) {
_enabled = value;
},
version:"0.1.13",
legacyProps:function(value) {
_legacyProps = _defaultLegacyProps + value + ",";
}
};
}(jQuery));

View File

@ -0,0 +1,56 @@
/*!
* VERSION: 0.6.1
* DATE: 2018-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || window; //helps ensure compatibility with AMD/RequireJS and CommonJS/Node
(_gsScope._gsQueue || (_gsScope._gsQueue = [])).push( function() {
"use strict";
_gsScope._gsDefine.plugin({
propName: "attr",
API: 2,
version: "0.6.1",
//called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
init: function(target, value, tween, index) {
var p, end;
if (typeof(target.setAttribute) !== "function") {
return false;
}
for (p in value) {
end = value[p];
if (typeof(end) === "function") {
end = end(index, target);
}
this._addTween(target, "setAttribute", target.getAttribute(p) + "", end + "", p, false, p);
this._overwriteProps.push(p);
}
return true;
}
});
}); if (_gsScope._gsDefine) { _gsScope._gsQueue.pop()(); }
//export to AMD/RequireJS and CommonJS/Node (precursor to full modular build system coming at a later date)
(function(name) {
"use strict";
var getGlobal = function() {
return (_gsScope.GreenSockGlobals || _gsScope)[name];
};
if (typeof(module) !== "undefined" && module.exports) { //node
require("../TweenLite.js");
module.exports = getGlobal();
} else if (typeof(define) === "function" && define.amd) { //AMD
define(["TweenLite"], getGlobal);
}
}("AttrPlugin"));

View File

@ -0,0 +1,621 @@
/*!
* VERSION: 1.3.8
* DATE: 2018-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
/* eslint-disable */
var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || window; //helps ensure compatibility with AMD/RequireJS and CommonJS/Node
(_gsScope._gsQueue || (_gsScope._gsQueue = [])).push( function() {
"use strict";
var _RAD2DEG = 180 / Math.PI,
_r1 = [],
_r2 = [],
_r3 = [],
_corProps = {},
_globals = _gsScope._gsDefine.globals,
Segment = function(a, b, c, d) {
if (c === d) { //if c and d match, the final autoRotate value could lock at -90 degrees, so differentiate them slightly.
c = d - (d - b) / 1000000;
}
if (a === b) { //if a and b match, the starting autoRotate value could lock at -90 degrees, so differentiate them slightly.
b = a + (c - a) / 1000000;
}
this.a = a;
this.b = b;
this.c = c;
this.d = d;
this.da = d - a;
this.ca = c - a;
this.ba = b - a;
},
_correlate = ",x,y,z,left,top,right,bottom,marginTop,marginLeft,marginRight,marginBottom,paddingLeft,paddingTop,paddingRight,paddingBottom,backgroundPosition,backgroundPosition_y,",
cubicToQuadratic = function(a, b, c, d) {
var q1 = {a:a},
q2 = {},
q3 = {},
q4 = {c:d},
mab = (a + b) / 2,
mbc = (b + c) / 2,
mcd = (c + d) / 2,
mabc = (mab + mbc) / 2,
mbcd = (mbc + mcd) / 2,
m8 = (mbcd - mabc) / 8;
q1.b = mab + (a - mab) / 4;
q2.b = mabc + m8;
q1.c = q2.a = (q1.b + q2.b) / 2;
q2.c = q3.a = (mabc + mbcd) / 2;
q3.b = mbcd - m8;
q4.b = mcd + (d - mcd) / 4;
q3.c = q4.a = (q3.b + q4.b) / 2;
return [q1, q2, q3, q4];
},
_calculateControlPoints = function(a, curviness, quad, basic, correlate) {
var l = a.length - 1,
ii = 0,
cp1 = a[0].a,
i, p1, p2, p3, seg, m1, m2, mm, cp2, qb, r1, r2, tl;
for (i = 0; i < l; i++) {
seg = a[ii];
p1 = seg.a;
p2 = seg.d;
p3 = a[ii+1].d;
if (correlate) {
r1 = _r1[i];
r2 = _r2[i];
tl = ((r2 + r1) * curviness * 0.25) / (basic ? 0.5 : _r3[i] || 0.5);
m1 = p2 - (p2 - p1) * (basic ? curviness * 0.5 : (r1 !== 0 ? tl / r1 : 0));
m2 = p2 + (p3 - p2) * (basic ? curviness * 0.5 : (r2 !== 0 ? tl / r2 : 0));
mm = p2 - (m1 + (((m2 - m1) * ((r1 * 3 / (r1 + r2)) + 0.5) / 4) || 0));
} else {
m1 = p2 - (p2 - p1) * curviness * 0.5;
m2 = p2 + (p3 - p2) * curviness * 0.5;
mm = p2 - (m1 + m2) / 2;
}
m1 += mm;
m2 += mm;
seg.c = cp2 = m1;
if (i !== 0) {
seg.b = cp1;
} else {
seg.b = cp1 = seg.a + (seg.c - seg.a) * 0.6; //instead of placing b on a exactly, we move it inline with c so that if the user specifies an ease like Back.easeIn or Elastic.easeIn which goes BEYOND the beginning, it will do so smoothly.
}
seg.da = p2 - p1;
seg.ca = cp2 - p1;
seg.ba = cp1 - p1;
if (quad) {
qb = cubicToQuadratic(p1, cp1, cp2, p2);
a.splice(ii, 1, qb[0], qb[1], qb[2], qb[3]);
ii += 4;
} else {
ii++;
}
cp1 = m2;
}
seg = a[ii];
seg.b = cp1;
seg.c = cp1 + (seg.d - cp1) * 0.4; //instead of placing c on d exactly, we move it inline with b so that if the user specifies an ease like Back.easeOut or Elastic.easeOut which goes BEYOND the end, it will do so smoothly.
seg.da = seg.d - seg.a;
seg.ca = seg.c - seg.a;
seg.ba = cp1 - seg.a;
if (quad) {
qb = cubicToQuadratic(seg.a, cp1, seg.c, seg.d);
a.splice(ii, 1, qb[0], qb[1], qb[2], qb[3]);
}
},
_parseAnchors = function(values, p, correlate, prepend) {
var a = [],
l, i, p1, p2, p3, tmp;
if (prepend) {
values = [prepend].concat(values);
i = values.length;
while (--i > -1) {
if (typeof( (tmp = values[i][p]) ) === "string") if (tmp.charAt(1) === "=") {
values[i][p] = prepend[p] + Number(tmp.charAt(0) + tmp.substr(2)); //accommodate relative values. Do it inline instead of breaking it out into a function for speed reasons
}
}
}
l = values.length - 2;
if (l < 0) {
a[0] = new Segment(values[0][p], 0, 0, values[0][p]);
return a;
}
for (i = 0; i < l; i++) {
p1 = values[i][p];
p2 = values[i+1][p];
a[i] = new Segment(p1, 0, 0, p2);
if (correlate) {
p3 = values[i+2][p];
_r1[i] = (_r1[i] || 0) + (p2 - p1) * (p2 - p1);
_r2[i] = (_r2[i] || 0) + (p3 - p2) * (p3 - p2);
}
}
a[i] = new Segment(values[i][p], 0, 0, values[i+1][p]);
return a;
},
bezierThrough = function(values, curviness, quadratic, basic, correlate, prepend) {
var obj = {},
props = [],
first = prepend || values[0],
i, p, a, j, r, l, seamless, last;
correlate = (typeof(correlate) === "string") ? ","+correlate+"," : _correlate;
if (curviness == null) {
curviness = 1;
}
for (p in values[0]) {
props.push(p);
}
//check to see if the last and first values are identical (well, within 0.05). If so, make seamless by appending the second element to the very end of the values array and the 2nd-to-last element to the very beginning (we'll remove those segments later)
if (values.length > 1) {
last = values[values.length - 1];
seamless = true;
i = props.length;
while (--i > -1) {
p = props[i];
if (Math.abs(first[p] - last[p]) > 0.05) { //build in a tolerance of +/-0.05 to accommodate rounding errors.
seamless = false;
break;
}
}
if (seamless) {
values = values.concat(); //duplicate the array to avoid contaminating the original which the user may be reusing for other tweens
if (prepend) {
values.unshift(prepend);
}
values.push(values[1]);
prepend = values[values.length - 3];
}
}
_r1.length = _r2.length = _r3.length = 0;
i = props.length;
while (--i > -1) {
p = props[i];
_corProps[p] = (correlate.indexOf(","+p+",") !== -1);
obj[p] = _parseAnchors(values, p, _corProps[p], prepend);
}
i = _r1.length;
while (--i > -1) {
_r1[i] = Math.sqrt(_r1[i]);
_r2[i] = Math.sqrt(_r2[i]);
}
if (!basic) {
i = props.length;
while (--i > -1) {
if (_corProps[p]) {
a = obj[props[i]];
l = a.length - 1;
for (j = 0; j < l; j++) {
r = (a[j+1].da / _r2[j] + a[j].da / _r1[j]) || 0;
_r3[j] = (_r3[j] || 0) + r * r;
}
}
}
i = _r3.length;
while (--i > -1) {
_r3[i] = Math.sqrt(_r3[i]);
}
}
i = props.length;
j = quadratic ? 4 : 1;
while (--i > -1) {
p = props[i];
a = obj[p];
_calculateControlPoints(a, curviness, quadratic, basic, _corProps[p]); //this method requires that _parseAnchors() and _setSegmentRatios() ran first so that _r1, _r2, and _r3 values are populated for all properties
if (seamless) {
a.splice(0, j);
a.splice(a.length - j, j);
}
}
return obj;
},
_parseBezierData = function(values, type, prepend) {
type = type || "soft";
var obj = {},
inc = (type === "cubic") ? 3 : 2,
soft = (type === "soft"),
props = [],
a, b, c, d, cur, i, j, l, p, cnt, tmp;
if (soft && prepend) {
values = [prepend].concat(values);
}
if (values == null || values.length < inc + 1) { throw "invalid Bezier data"; }
for (p in values[0]) {
props.push(p);
}
i = props.length;
while (--i > -1) {
p = props[i];
obj[p] = cur = [];
cnt = 0;
l = values.length;
for (j = 0; j < l; j++) {
a = (prepend == null) ? values[j][p] : (typeof( (tmp = values[j][p]) ) === "string" && tmp.charAt(1) === "=") ? prepend[p] + Number(tmp.charAt(0) + tmp.substr(2)) : Number(tmp);
if (soft) if (j > 1) if (j < l - 1) {
cur[cnt++] = (a + cur[cnt-2]) / 2;
}
cur[cnt++] = a;
}
l = cnt - inc + 1;
cnt = 0;
for (j = 0; j < l; j += inc) {
a = cur[j];
b = cur[j+1];
c = cur[j+2];
d = (inc === 2) ? 0 : cur[j+3];
cur[cnt++] = tmp = (inc === 3) ? new Segment(a, b, c, d) : new Segment(a, (2 * b + a) / 3, (2 * b + c) / 3, c);
}
cur.length = cnt;
}
return obj;
},
_addCubicLengths = function(a, steps, resolution) {
var inc = 1 / resolution,
j = a.length,
d, d1, s, da, ca, ba, p, i, inv, bez, index;
while (--j > -1) {
bez = a[j];
s = bez.a;
da = bez.d - s;
ca = bez.c - s;
ba = bez.b - s;
d = d1 = 0;
for (i = 1; i <= resolution; i++) {
p = inc * i;
inv = 1 - p;
d = d1 - (d1 = (p * p * da + 3 * inv * (p * ca + inv * ba)) * p);
index = j * resolution + i - 1;
steps[index] = (steps[index] || 0) + d * d;
}
}
},
_parseLengthData = function(obj, resolution) {
resolution = resolution >> 0 || 6;
var a = [],
lengths = [],
d = 0,
total = 0,
threshold = resolution - 1,
segments = [],
curLS = [], //current length segments array
p, i, l, index;
for (p in obj) {
_addCubicLengths(obj[p], a, resolution);
}
l = a.length;
for (i = 0; i < l; i++) {
d += Math.sqrt(a[i]);
index = i % resolution;
curLS[index] = d;
if (index === threshold) {
total += d;
index = (i / resolution) >> 0;
segments[index] = curLS;
lengths[index] = total;
d = 0;
curLS = [];
}
}
return {length:total, lengths:lengths, segments:segments};
},
BezierPlugin = _gsScope._gsDefine.plugin({
propName: "bezier",
priority: -1,
version: "1.3.8",
API: 2,
global:true,
//gets called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
init: function(target, vars, tween) {
this._target = target;
if (vars instanceof Array) {
vars = {values:vars};
}
this._func = {};
this._mod = {};
this._props = [];
this._timeRes = (vars.timeResolution == null) ? 6 : parseInt(vars.timeResolution, 10);
var values = vars.values || [],
first = {},
second = values[0],
autoRotate = vars.autoRotate || tween.vars.orientToBezier,
p, isFunc, i, j, prepend;
this._autoRotate = autoRotate ? (autoRotate instanceof Array) ? autoRotate : [["x","y","rotation",((autoRotate === true) ? 0 : Number(autoRotate) || 0)]] : null;
for (p in second) {
this._props.push(p);
}
i = this._props.length;
while (--i > -1) {
p = this._props[i];
this._overwriteProps.push(p);
isFunc = this._func[p] = (typeof(target[p]) === "function");
first[p] = (!isFunc) ? parseFloat(target[p]) : target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]();
if (!prepend) if (first[p] !== values[0][p]) {
prepend = first;
}
}
this._beziers = (vars.type !== "cubic" && vars.type !== "quadratic" && vars.type !== "soft") ? bezierThrough(values, isNaN(vars.curviness) ? 1 : vars.curviness, false, (vars.type === "thruBasic"), vars.correlate, prepend) : _parseBezierData(values, vars.type, first);
this._segCount = this._beziers[p].length;
if (this._timeRes) {
var ld = _parseLengthData(this._beziers, this._timeRes);
this._length = ld.length;
this._lengths = ld.lengths;
this._segments = ld.segments;
this._l1 = this._li = this._s1 = this._si = 0;
this._l2 = this._lengths[0];
this._curSeg = this._segments[0];
this._s2 = this._curSeg[0];
this._prec = 1 / this._curSeg.length;
}
if ((autoRotate = this._autoRotate)) {
this._initialRotations = [];
if (!(autoRotate[0] instanceof Array)) {
this._autoRotate = autoRotate = [autoRotate];
}
i = autoRotate.length;
while (--i > -1) {
for (j = 0; j < 3; j++) {
p = autoRotate[i][j];
this._func[p] = (typeof(target[p]) === "function") ? target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ] : false;
}
p = autoRotate[i][2];
this._initialRotations[i] = (this._func[p] ? this._func[p].call(this._target) : this._target[p]) || 0;
this._overwriteProps.push(p);
}
}
this._startRatio = tween.vars.runBackwards ? 1 : 0; //we determine the starting ratio when the tween inits which is always 0 unless the tween has runBackwards:true (indicating it's a from() tween) in which case it's 1.
return true;
},
//called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.)
set: function(v) {
var segments = this._segCount,
func = this._func,
target = this._target,
notStart = (v !== this._startRatio),
curIndex, inv, i, p, b, t, val, l, lengths, curSeg;
if (!this._timeRes) {
curIndex = (v < 0) ? 0 : (v >= 1) ? segments - 1 : (segments * v) >> 0;
t = (v - (curIndex * (1 / segments))) * segments;
} else {
lengths = this._lengths;
curSeg = this._curSeg;
v *= this._length;
i = this._li;
//find the appropriate segment (if the currently cached one isn't correct)
if (v > this._l2 && i < segments - 1) {
l = segments - 1;
while (i < l && (this._l2 = lengths[++i]) <= v) { }
this._l1 = lengths[i-1];
this._li = i;
this._curSeg = curSeg = this._segments[i];
this._s2 = curSeg[(this._s1 = this._si = 0)];
} else if (v < this._l1 && i > 0) {
while (i > 0 && (this._l1 = lengths[--i]) >= v) { }
if (i === 0 && v < this._l1) {
this._l1 = 0;
} else {
i++;
}
this._l2 = lengths[i];
this._li = i;
this._curSeg = curSeg = this._segments[i];
this._s1 = curSeg[(this._si = curSeg.length - 1) - 1] || 0;
this._s2 = curSeg[this._si];
}
curIndex = i;
//now find the appropriate sub-segment (we split it into the number of pieces that was defined by "precision" and measured each one)
v -= this._l1;
i = this._si;
if (v > this._s2 && i < curSeg.length - 1) {
l = curSeg.length - 1;
while (i < l && (this._s2 = curSeg[++i]) <= v) { }
this._s1 = curSeg[i-1];
this._si = i;
} else if (v < this._s1 && i > 0) {
while (i > 0 && (this._s1 = curSeg[--i]) >= v) { }
if (i === 0 && v < this._s1) {
this._s1 = 0;
} else {
i++;
}
this._s2 = curSeg[i];
this._si = i;
}
t = ((i + (v - this._s1) / (this._s2 - this._s1)) * this._prec) || 0;
}
inv = 1 - t;
i = this._props.length;
while (--i > -1) {
p = this._props[i];
b = this._beziers[p][curIndex];
val = (t * t * b.da + 3 * inv * (t * b.ca + inv * b.ba)) * t + b.a;
if (this._mod[p]) {
val = this._mod[p](val, target);
}
if (func[p]) {
target[p](val);
} else {
target[p] = val;
}
}
if (this._autoRotate) {
var ar = this._autoRotate,
b2, x1, y1, x2, y2, add, conv;
i = ar.length;
while (--i > -1) {
p = ar[i][2];
add = ar[i][3] || 0;
conv = (ar[i][4] === true) ? 1 : _RAD2DEG;
b = this._beziers[ar[i][0]];
b2 = this._beziers[ar[i][1]];
if (b && b2) { //in case one of the properties got overwritten.
b = b[curIndex];
b2 = b2[curIndex];
x1 = b.a + (b.b - b.a) * t;
x2 = b.b + (b.c - b.b) * t;
x1 += (x2 - x1) * t;
x2 += ((b.c + (b.d - b.c) * t) - x2) * t;
y1 = b2.a + (b2.b - b2.a) * t;
y2 = b2.b + (b2.c - b2.b) * t;
y1 += (y2 - y1) * t;
y2 += ((b2.c + (b2.d - b2.c) * t) - y2) * t;
val = notStart ? Math.atan2(y2 - y1, x2 - x1) * conv + add : this._initialRotations[i];
if (this._mod[p]) {
val = this._mod[p](val, target); //for modProps
}
if (func[p]) {
target[p](val);
} else {
target[p] = val;
}
}
}
}
}
}),
p = BezierPlugin.prototype;
BezierPlugin.bezierThrough = bezierThrough;
BezierPlugin.cubicToQuadratic = cubicToQuadratic;
BezierPlugin._autoCSS = true; //indicates that this plugin can be inserted into the "css" object using the autoCSS feature of TweenLite
BezierPlugin.quadraticToCubic = function(a, b, c) {
return new Segment(a, (2 * b + a) / 3, (2 * b + c) / 3, c);
};
BezierPlugin._cssRegister = function() {
var CSSPlugin = _globals.CSSPlugin;
if (!CSSPlugin) {
return;
}
var _internals = CSSPlugin._internals,
_parseToProxy = _internals._parseToProxy,
_setPluginRatio = _internals._setPluginRatio,
CSSPropTween = _internals.CSSPropTween;
_internals._registerComplexSpecialProp("bezier", {parser:function(t, e, prop, cssp, pt, plugin) {
if (e instanceof Array) {
e = {values:e};
}
plugin = new BezierPlugin();
var values = e.values,
l = values.length - 1,
pluginValues = [],
v = {},
i, p, data;
if (l < 0) {
return pt;
}
for (i = 0; i <= l; i++) {
data = _parseToProxy(t, values[i], cssp, pt, plugin, (l !== i));
pluginValues[i] = data.end;
}
for (p in e) {
v[p] = e[p]; //duplicate the vars object because we need to alter some things which would cause problems if the user plans to reuse the same vars object for another tween.
}
v.values = pluginValues;
pt = new CSSPropTween(t, "bezier", 0, 0, data.pt, 2);
pt.data = data;
pt.plugin = plugin;
pt.setRatio = _setPluginRatio;
if (v.autoRotate === 0) {
v.autoRotate = true;
}
if (v.autoRotate && !(v.autoRotate instanceof Array)) {
i = (v.autoRotate === true) ? 0 : Number(v.autoRotate);
v.autoRotate = (data.end.left != null) ? [["left","top","rotation",i,false]] : (data.end.x != null) ? [["x","y","rotation",i,false]] : false;
}
if (v.autoRotate) {
if (!cssp._transform) {
cssp._enableTransforms(false);
}
data.autoRotate = cssp._target._gsTransform;
data.proxy.rotation = data.autoRotate.rotation || 0;
cssp._overwriteProps.push("rotation");
}
plugin._onInitTween(data.proxy, v, cssp._tween);
return pt;
}});
};
p._mod = function(lookup) {
var op = this._overwriteProps,
i = op.length,
val;
while (--i > -1) {
val = lookup[op[i]];
if (val && typeof(val) === "function") {
this._mod[op[i]] = val;
}
}
};
p._kill = function(lookup) {
var a = this._props,
p, i;
for (p in this._beziers) {
if (p in lookup) {
delete this._beziers[p];
delete this._func[p];
i = a.length;
while (--i > -1) {
if (a[i] === p) {
a.splice(i, 1);
}
}
}
}
a = this._autoRotate;
if (a) {
i = a.length;
while (--i > -1) {
if (lookup[a[i][2]]) {
a.splice(i, 1);
}
}
}
return this._super._kill.call(this, lookup);
};
}); if (_gsScope._gsDefine) { _gsScope._gsQueue.pop()(); }
//export to AMD/RequireJS and CommonJS/Node (precursor to full modular build system coming at a later date)
(function(name) {
"use strict";
var getGlobal = function() {
return (_gsScope.GreenSockGlobals || _gsScope)[name];
};
if (typeof(module) !== "undefined" && module.exports) { //node
require("../TweenLite.js");
module.exports = getGlobal();
} else if (typeof(define) === "function" && define.amd) { //AMD
define(["TweenLite"], getGlobal);
}
}("BezierPlugin"));

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,120 @@
/*!
* VERSION: 0.6.6
* DATE: 2018-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || window; //helps ensure compatibility with AMD/RequireJS and CommonJS/Node
(_gsScope._gsQueue || (_gsScope._gsQueue = [])).push( function() {
"use strict";
_gsScope._gsDefine("plugins.CSSRulePlugin", ["plugins.TweenPlugin","TweenLite","plugins.CSSPlugin"], function(TweenPlugin, TweenLite, CSSPlugin) {
/** @constructor **/
var CSSRulePlugin = function() {
TweenPlugin.call(this, "cssRule");
this._overwriteProps.length = 0;
},
_doc = _gsScope.document,
_superSetRatio = CSSPlugin.prototype.setRatio,
p = CSSRulePlugin.prototype = new CSSPlugin();
p._propName = "cssRule";
p.constructor = CSSRulePlugin;
CSSRulePlugin.version = "0.6.6";
CSSRulePlugin.API = 2;
/**
* Searches the style sheets in the document for a particular selector like ".myClass" or "a" or "a:hover" or ":after" and
* returns a reference to that style sheet (or an array of them in the case of a pseudo selector like ":after"). Then you
* can animate the individual properties of the style sheet.
*
* @param {!string} selector a string describing the selector, like ".myClass" or "a" or "a:hover" or ":after"
* @return a reference to the style sheet (or an array of them in the case of a pseudo selector). If none was found, null is returned (or an empty array for a pseudo selector)
*/
CSSRulePlugin.getRule = function(selector) {
var ruleProp = _doc.all ? "rules" : "cssRules",
ss = _doc.styleSheets,
i = ss.length,
pseudo = (selector.charAt(0) === ":"),
j, curSS, cs, a;
selector = (pseudo ? "" : ",") + selector.split("::").join(":").toLowerCase() + ","; //note: old versions of IE report tag name selectors as upper case, so we just change everything to lowercase.
if (pseudo) {
a = [];
}
while (--i > -1) {
//Firefox may throw insecure operation errors when css is loaded from other domains, so try/catch.
try {
curSS = ss[i][ruleProp];
if (!curSS) {
continue;
}
j = curSS.length;
} catch (e) {
console.log(e);
continue;
}
while (--j > -1) {
cs = curSS[j];
if (cs.selectorText && ("," + cs.selectorText.split("::").join(":").toLowerCase() + ",").indexOf(selector) !== -1) { //note: IE adds an extra ":" to pseudo selectors, so .myClass:after becomes .myClass::after, so we need to strip the extra one out.
if (pseudo) {
a.push(cs.style);
} else {
return cs.style;
}
}
}
}
return a;
};
// @private gets called when the tween renders for the first time. This kicks everything off, recording start/end values, etc.
p._onInitTween = function(target, value, tween) {
if (target.cssText === undefined) {
return false;
}
var div = target._gsProxy = target._gsProxy || _doc.createElement("div");
this._ss = target;
this._proxy = div.style;
div.style.cssText = target.cssText;
CSSPlugin.prototype._onInitTween.call(this, div, value, tween); //we just offload all the work to the regular CSSPlugin and then copy the cssText back over to the rule in the setRatio() method. This allows us to have all of the updates to CSSPlugin automatically flow through to CSSRulePlugin instead of having to maintain both
return true;
};
// @private gets called every time the tween updates, passing the new ratio (typically a value between 0 and 1, but not always (for example, if an Elastic.easeOut is used, the value can jump above 1 mid-tween). It will always start and 0 and end at 1.
p.setRatio = function(v) {
_superSetRatio.call(this, v);
this._ss.cssText = this._proxy.cssText;
};
TweenPlugin.activate([CSSRulePlugin]);
return CSSRulePlugin;
}, true);
}); if (_gsScope._gsDefine) { _gsScope._gsQueue.pop()(); }
//export to AMD/RequireJS and CommonJS/Node (precursor to full modular build system coming at a later date)
(function(name) {
"use strict";
var getGlobal = function() {
return (_gsScope.GreenSockGlobals || _gsScope)[name];
};
if (typeof(module) !== "undefined" && module.exports) { //node
require("../TweenLite.js");
module.exports = getGlobal();
} else if (typeof(define) === "function" && define.amd) { //AMD
define(["TweenLite"], getGlobal);
}
}("CSSRulePlugin"));

View File

@ -0,0 +1,246 @@
/*!
* VERSION: 1.5.3
* DATE: 2018-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
/* eslint-disable */
var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || window; //helps ensure compatibility with AMD/RequireJS and CommonJS/Node
(_gsScope._gsQueue || (_gsScope._gsQueue = [])).push( function() {
"use strict";
var _numExp = /(\d|\.)+/g,
_relNumExp = /(?:\d|\-\d|\.\d|\-\.\d|\+=\d|\-=\d|\+=.\d|\-=\.\d)+/g,
_colorLookup = {aqua:[0,255,255],
lime:[0,255,0],
silver:[192,192,192],
black:[0,0,0],
maroon:[128,0,0],
teal:[0,128,128],
blue:[0,0,255],
navy:[0,0,128],
white:[255,255,255],
fuchsia:[255,0,255],
olive:[128,128,0],
yellow:[255,255,0],
orange:[255,165,0],
gray:[128,128,128],
purple:[128,0,128],
green:[0,128,0],
red:[255,0,0],
pink:[255,192,203],
cyan:[0,255,255],
transparent:[255,255,255,0]},
_hue = function(h, m1, m2) {
h = (h < 0) ? h + 1 : (h > 1) ? h - 1 : h;
return ((((h * 6 < 1) ? m1 + (m2 - m1) * h * 6 : (h < 0.5) ? m2 : (h * 3 < 2) ? m1 + (m2 - m1) * (2 / 3 - h) * 6 : m1) * 255) + 0.5) | 0;
},
/**
* @private Parses a color (like #9F0, #FF9900, rgb(255,51,153) or hsl(108, 50%, 10%)) into an array with 3 elements for red, green, and blue or if toHSL parameter is true, it will populate the array with hue, saturation, and lightness values. If a relative value is found in an hsl() or hsla() string, it will preserve those relative prefixes and all the values in the array will be strings instead of numbers (in all other cases it will be populated with numbers).
* @param {(string|number)} v The value the should be parsed which could be a string like #9F0 or rgb(255,102,51) or rgba(255,0,0,0.5) or it could be a number like 0xFF00CC or even a named color like red, blue, purple, etc.
* @param {(boolean)} toHSL If true, an hsl() or hsla() value will be returned instead of rgb() or rgba()
* @return {Array.<number>} An array containing red, green, and blue (and optionally alpha) in that order, or if the toHSL parameter was true, the array will contain hue, saturation and lightness (and optionally alpha) in that order. Always numbers unless there's a relative prefix found in an hsl() or hsla() string and toHSL is true.
*/
_parseColor = function(v, toHSL) {
var a, r, g, b, h, s, l, max, min, d, wasHSL;
if (!v) {
a = _colorLookup.black;
} else if (typeof(v) === "number") {
a = [v >> 16, (v >> 8) & 255, v & 255];
} else {
if (v.charAt(v.length - 1) === ",") { //sometimes a trailing comma is included and we should chop it off (typically from a comma-delimited list of values like a textShadow:"2px 2px 2px blue, 5px 5px 5px rgb(255,0,0)" - in this example "blue," has a trailing comma. We could strip it out inside parseComplex() but we'd need to do it to the beginning and ending values plus it wouldn't provide protection from other potential scenarios like if the user passes in a similar value.
v = v.substr(0, v.length - 1);
}
if (_colorLookup[v]) {
a = _colorLookup[v];
} else if (v.charAt(0) === "#") {
if (v.length === 4) { //for shorthand like #9F0
r = v.charAt(1);
g = v.charAt(2);
b = v.charAt(3);
v = "#" + r + r + g + g + b + b;
}
v = parseInt(v.substr(1), 16);
a = [v >> 16, (v >> 8) & 255, v & 255];
} else if (v.substr(0, 3) === "hsl") {
a = wasHSL = v.match(_numExp);
if (!toHSL) {
h = (Number(a[0]) % 360) / 360;
s = Number(a[1]) / 100;
l = Number(a[2]) / 100;
g = (l <= 0.5) ? l * (s + 1) : l + s - l * s;
r = l * 2 - g;
if (a.length > 3) {
a[3] = Number(a[3]);
}
a[0] = _hue(h + 1 / 3, r, g);
a[1] = _hue(h, r, g);
a[2] = _hue(h - 1 / 3, r, g);
} else if (v.indexOf("=") !== -1) { //if relative values are found, just return the raw strings with the relative prefixes in place.
return v.match(_relNumExp);
}
} else {
a = v.match(_numExp) || _colorLookup.transparent;
}
a[0] = Number(a[0]);
a[1] = Number(a[1]);
a[2] = Number(a[2]);
if (a.length > 3) {
a[3] = Number(a[3]);
}
}
if (toHSL && !wasHSL) {
r = a[0] / 255;
g = a[1] / 255;
b = a[2] / 255;
max = Math.max(r, g, b);
min = Math.min(r, g, b);
l = (max + min) / 2;
if (max === min) {
h = s = 0;
} else {
d = max - min;
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
h = (max === r) ? (g - b) / d + (g < b ? 6 : 0) : (max === g) ? (b - r) / d + 2 : (r - g) / d + 4;
h *= 60;
}
a[0] = (h + 0.5) | 0;
a[1] = (s * 100 + 0.5) | 0;
a[2] = (l * 100 + 0.5) | 0;
}
return a;
},
_formatColors = function(s, toHSL) {
var colors = (s + "").match(_colorExp) || [],
charIndex = 0,
parsed = "",
i, color, temp;
if (!colors.length) {
return s;
}
for (i = 0; i < colors.length; i++) {
color = colors[i];
temp = s.substr(charIndex, s.indexOf(color, charIndex)-charIndex);
charIndex += temp.length + color.length;
color = _parseColor(color, toHSL);
if (color.length === 3) {
color.push(1);
}
parsed += temp + (toHSL ? "hsla(" + color[0] + "," + color[1] + "%," + color[2] + "%," + color[3] : "rgba(" + color.join(",")) + ")";
}
return parsed + s.substr(charIndex);
}, p, _colorStringFilter,
TweenLite = (_gsScope.GreenSockGlobals || _gsScope).TweenLite,
_colorExp = "(?:\\b(?:(?:rgb|rgba|hsl|hsla)\\(.+?\\))|\\B#(?:[0-9a-f]{3}){1,2}\\b", //we'll dynamically build this Regular Expression to conserve file size. After building it, it will be able to find rgb(), rgba(), # (hexadecimal), and named color values like red, blue, purple, etc.
ColorPropsPlugin = _gsScope._gsDefine.plugin({
propName: "colorProps",
version: "1.5.3",
priority: -1,
API: 2,
global: true,
//called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
init: function(target, value, tween, index) {
var p, proxy, pt, val;
this._target = target;
this._proxy = proxy = ((value.format + "").toUpperCase() === "NUMBER") ? {} : 0;
for (p in value) {
if (p !== "format") {
if (proxy) {
this._firstNumPT = pt = {_next:this._firstNumPT, t:target, p:p, f:(typeof(target[p]) === "function")};
proxy[p] = "rgb(" + _parseColor(!pt.f ? target[p] : target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]()).join(",") + ")";
val = value[p];
if (typeof(val) === "function") {
val = val(index, target);
}
this._addTween(proxy, p, "get", ((typeof(val) === "number") ? "rgb(" + _parseColor(val, false).join(",") + ")" : val), p, null, null, _colorStringFilter);
} else {
this._addTween(target, p, "get", value[p], p, null, null, _colorStringFilter, index);
}
}
}
return true;
},
//called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.)
set: function(v) {
var pt = this._firstNumPT,
val;
this._super.setRatio.call(this, v);
while (pt) {
val = _parseColor(this._proxy[pt.p], false);
val = val[0] << 16 | val[1] << 8 | val[2];
if (pt.f) {
this._target[pt.p](val);
} else {
this._target[pt.p] = val;
}
pt = pt._next;
}
}
});
for (p in _colorLookup) {
_colorExp += "|" + p + "\\b";
}
_colorExp = new RegExp(_colorExp+")", "gi");
ColorPropsPlugin.colorStringFilter = _colorStringFilter = function(a) {
var combined = a[0] + " " + a[1],
toHSL;
_colorExp.lastIndex = 0;
if (_colorExp.test(combined)) {
toHSL = (combined.indexOf("hsl(") !== -1 || combined.indexOf("hsla(") !== -1);
a[0] = _formatColors(a[0], toHSL);
a[1] = _formatColors(a[1], toHSL);
}
};
if (!TweenLite.defaultStringFilter) {
TweenLite.defaultStringFilter = ColorPropsPlugin.colorStringFilter;
}
ColorPropsPlugin.parseColor = _parseColor;
p = ColorPropsPlugin.prototype;
p._firstNumPT = null;
p._kill = function(lookup) {
var pt = this._firstNumPT,
prev;
while (pt) {
if (pt.p in lookup) {
if (pt === p._firstNumPT) {
this._firstNumPT = pt._next;
}
if (prev) {
prev._next = pt._next;
}
} else {
prev = pt;
}
pt = pt._next;
}
return this._super._kill(lookup);
};
}); if (_gsScope._gsDefine) { _gsScope._gsQueue.pop()(); }
//export to AMD/RequireJS and CommonJS/Node (precursor to full modular build system coming at a later date)
(function(name) {
"use strict";
var getGlobal = function() {
return (_gsScope.GreenSockGlobals || _gsScope)[name];
};
if (typeof(module) !== "undefined" && module.exports) { //node
require("../TweenLite.js");
module.exports = getGlobal();
} else if (typeof(define) === "function" && define.amd) { //AMD
define(["TweenLite"], getGlobal);
}
}("ColorPropsPlugin"));

View File

@ -0,0 +1,100 @@
/*!
* VERSION: 0.3.1
* DATE: 2018-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
/* eslint-disable */
var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || window; //helps ensure compatibility with AMD/RequireJS and CommonJS/Node
(_gsScope._gsQueue || (_gsScope._gsQueue = [])).push( function() {
"use strict";
_gsScope._gsDefine.plugin({
propName: "directionalRotation",
version: "0.3.1",
API: 2,
//called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
init: function(target, value, tween, index) {
if (typeof(value) !== "object") {
value = {rotation:value};
}
this.finals = {};
var cap = (value.useRadians === true) ? Math.PI * 2 : 360,
min = 0.000001,
p, v, start, end, dif, split;
for (p in value) {
if (p !== "useRadians") {
end = value[p];
if (typeof(end) === "function") {
end = end(index, target);
}
split = (end + "").split("_");
v = split[0];
start = parseFloat( (typeof(target[p]) !== "function") ? target[p] : target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]() );
end = this.finals[p] = (typeof(v) === "string" && v.charAt(1) === "=") ? start + parseInt(v.charAt(0) + "1", 10) * Number(v.substr(2)) : Number(v) || 0;
dif = end - start;
if (split.length) {
v = split.join("_");
if (v.indexOf("short") !== -1) {
dif = dif % cap;
if (dif !== dif % (cap / 2)) {
dif = (dif < 0) ? dif + cap : dif - cap;
}
}
if (v.indexOf("_cw") !== -1 && dif < 0) {
dif = ((dif + cap * 9999999999) % cap) - ((dif / cap) | 0) * cap;
} else if (v.indexOf("ccw") !== -1 && dif > 0) {
dif = ((dif - cap * 9999999999) % cap) - ((dif / cap) | 0) * cap;
}
}
if (dif > min || dif < -min) {
this._addTween(target, p, start, start + dif, p);
this._overwriteProps.push(p);
}
}
}
return true;
},
//called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.)
set: function(ratio) {
var pt;
if (ratio !== 1) {
this._super.setRatio.call(this, ratio);
} else {
pt = this._firstPT;
while (pt) {
if (pt.f) {
pt.t[pt.p](this.finals[pt.p]);
} else {
pt.t[pt.p] = this.finals[pt.p];
}
pt = pt._next;
}
}
}
})._autoCSS = true;
}); if (_gsScope._gsDefine) { _gsScope._gsQueue.pop()(); }
//export to AMD/RequireJS and CommonJS/Node (precursor to full modular build system coming at a later date)
(function(name) {
"use strict";
var getGlobal = function() {
return (_gsScope.GreenSockGlobals || _gsScope)[name];
};
if (typeof(module) !== "undefined" && module.exports) { //node
require("../TweenLite.js");
module.exports = getGlobal();
} else if (typeof(define) === "function" && define.amd) { //AMD
define(["TweenLite"], getGlobal);
}
}("DirectionalRotationPlugin"));

View File

@ -0,0 +1,245 @@
/*!
* VERSION: 0.2.1
* DATE: 2019-02-07
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* DrawSVGPlugin is a Club GreenSock membership benefit; You must have a valid membership to use
* this code without violating the terms of use. Visit http://greensock.com/club/ to sign up or get more details.
* This work is subject to the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || window; //helps ensure compatibility with AMD/RequireJS and CommonJS/Node
(_gsScope._gsQueue || (_gsScope._gsQueue = [])).push( function() {
"use strict";
var _doc = _gsScope.document,
_computedStyleScope = (typeof(window) !== "undefined" ? window : _doc.defaultView || {getComputedStyle:function() {}}),
_getComputedStyle = function(e) {
return _computedStyleScope.getComputedStyle(e); //to avoid errors in Microsoft Edge, we need to call getComputedStyle() from a specific scope, typically window.
},
_numbersExp = /(?:(-|-=|\+=)?\d*\.?\d*(?:e[\-+]?\d+)?)[0-9]/ig,
_isEdge = (((_gsScope.navigator || {}).userAgent || "").indexOf("Edge") !== -1), //Microsoft Edge has a bug that causes it not to redraw the path correctly if the stroke-linecap is anything other than "butt" (like "round") and it doesn't match the stroke-linejoin. A way to trigger it is to change the stroke-miterlimit, so we'll only do that if/when we have to (to maximize performance)
_types = {rect:["width","height"], circle:["r","r"], ellipse:["rx","ry"], line:["x2","y2"]},
DrawSVGPlugin;
function getDistance(x1, y1, x2, y2, scaleX, scaleY) {
x2 = (parseFloat(x2 || 0) - parseFloat(x1 || 0)) * scaleX;
y2 = (parseFloat(y2 || 0) - parseFloat(y1 || 0)) * scaleY;
return Math.sqrt(x2 * x2 + y2 * y2);
}
function unwrap(element) {
if (typeof(element) === "string" || !element.nodeType) {
element = _gsScope.TweenLite.selector(element);
if (element.length) {
element = element[0];
}
}
return element;
}
//accepts values like "100%" or "20% 80%" or "20 50" and parses it into an absolute start and end position on the line/stroke based on its length. Returns an an array with the start and end values, like [0, 243]
function parse(value, length, defaultStart) {
var i = value.indexOf(" "),
s, e;
if (i === -1) {
s = defaultStart !== undefined ? defaultStart + "" : value;
e = value;
} else {
s = value.substr(0, i);
e = value.substr(i+1);
}
s = (s.indexOf("%") !== -1) ? (parseFloat(s) / 100) * length : parseFloat(s);
e = (e.indexOf("%") !== -1) ? (parseFloat(e) / 100) * length : parseFloat(e);
return (s > e) ? [e, s] : [s, e];
}
function getLength(element) {
if (!element) {
return 0;
}
element = unwrap(element);
var type = element.tagName.toLowerCase(),
scaleX = 1,
scaleY = 1,
length, bbox, points, prevPoint, i, rx, ry;
if (element.getAttribute("vector-effect") === "non-scaling-stroke") { //non-scaling-stroke basically scales the shape and then strokes it at the screen-level (after transforms), thus we need to adjust the length accordingly.
scaleY = element.getScreenCTM();
scaleX = Math.sqrt(scaleY.a * scaleY.a + scaleY.b * scaleY.b);
scaleY = Math.sqrt(scaleY.d * scaleY.d + scaleY.c * scaleY.c);
}
try { //IE bug: calling <path>.getTotalLength() locks the repaint area of the stroke to whatever its current dimensions are on that frame/tick. To work around that, we must call getBBox() to force IE to recalculate things.
bbox = element.getBBox(); //solely for fixing bug in IE - we don't actually use the bbox.
} catch (e) {
//firefox has a bug that throws an error if the element isn't visible.
console.log("Error: Some browsers like Firefox won't report measurements of invisible elements (like display:none or masks inside defs).");
}
if ((!bbox || (!bbox.width && !bbox.height)) && _types[type]) { //if the element isn't visible, try to discern width/height using its attributes.
bbox = {
width: parseFloat( element.getAttribute(_types[type][0]) ),
height: parseFloat( element.getAttribute(_types[type][1]) )
};
if (type !== "rect" && type !== "line") { //double the radius for circles and ellipses
bbox.width *= 2;
bbox.height *= 2;
}
if (type === "line") {
bbox.x = parseFloat( element.getAttribute("x1") );
bbox.y = parseFloat( element.getAttribute("y1") );
bbox.width = Math.abs(bbox.width - bbox.x);
bbox.height = Math.abs(bbox.height - bbox.y);
}
}
if (type === "path") {
prevPoint = element.style.strokeDasharray;
element.style.strokeDasharray = "none";
length = element.getTotalLength() || 0;
if (scaleX !== scaleY) {
console.log("Warning: <path> length cannot be measured accurately when vector-effect is non-scaling-stroke and the element isn't proportionally scaled.");
}
length *= (scaleX + scaleY) / 2;
element.style.strokeDasharray = prevPoint;
} else if (type === "rect") {
length = bbox.width * 2 * scaleX + bbox.height * 2 * scaleY;
} else if (type === "line") {
length = getDistance(bbox.x, bbox.y, bbox.x + bbox.width, bbox.y + bbox.height, scaleX, scaleY);
} else if (type === "polyline" || type === "polygon") {
points = element.getAttribute("points").match(_numbersExp) || [];
if (type === "polygon") {
points.push(points[0], points[1]);
}
length = 0;
for (i = 2; i < points.length; i+=2) {
length += getDistance(points[i-2], points[i-1], points[i], points[i+1], scaleX, scaleY) || 0;
}
} else if (type === "circle" || type === "ellipse") {
rx = (bbox.width / 2) * scaleX;
ry = (bbox.height / 2) * scaleY;
length = Math.PI * ( 3 * (rx + ry) - Math.sqrt((3 * rx + ry) * (rx + 3 * ry)) );
}
return length || 0;
}
function getPosition(element, length) {
if (!element) {
return [0, 0];
}
element = unwrap(element);
length = length || (getLength(element) + 1);
var cs = _getComputedStyle(element),
dash = cs.strokeDasharray || "",
offset = parseFloat(cs.strokeDashoffset),
i = dash.indexOf(",");
if (i < 0) {
i = dash.indexOf(" ");
}
dash = (i < 0) ? length : parseFloat(dash.substr(0, i)) || 0.00001;
if (dash > length) {
dash = length;
}
return [Math.max(0, -offset), Math.max(0, dash - offset)];
}
DrawSVGPlugin = _gsScope._gsDefine.plugin({
propName: "drawSVG",
API: 2,
version: "0.2.1",
global: true,
overwriteProps: ["drawSVG"],
init: function(target, value, tween, index) {
if (!target.getBBox) {
return false;
}
var length = getLength(target) + 1,
start, end, overage, cs;
this._style = target.style;
this._target = target;
if (typeof(value) === "function") {
value = value(index, target);
}
if (value === true || value === "true") {
value = "0 100%";
} else if (!value) {
value = "0 0";
} else if ((value + "").indexOf(" ") === -1) {
value = "0 " + value;
}
start = getPosition(target, length);
end = parse(value, length, start[0]);
this._length = length + 10;
if (start[0] === 0 && end[0] === 0) {
overage = Math.max(0.00001, end[1] - length); //allow people to go past the end, like values of 105% because for some paths, Firefox doesn't return an accurate getTotalLength(), so it could end up coming up short.
this._dash = length + overage;
this._offset = length - start[1] + overage;
this._offsetPT = this._addTween(this, "_offset", this._offset, length - end[1] + overage, "drawSVG");
} else {
this._dash = (start[1] - start[0]) || 0.000001; //some browsers render artifacts if dash is 0, so we use a very small number in that case.
this._offset = -start[0];
this._dashPT = this._addTween(this, "_dash", this._dash, (end[1] - end[0]) || 0.00001, "drawSVG");
this._offsetPT = this._addTween(this, "_offset", this._offset, -end[0], "drawSVG");
}
if (_isEdge) { //to work around a bug in Microsoft Edge, animate the stroke-miterlimit by 0.0001 just to trigger the repaint (unnecessary if it's "round" and stroke-linejoin is also "round"). Imperceptible, relatively high-performance, and effective. Another option was to set the "d" <path> attribute to its current value on every tick, but that seems like it'd be much less performant.
cs = _getComputedStyle(target);
if (cs.strokeLinecap !== cs.strokeLinejoin) {
end = parseFloat(cs.strokeMiterlimit);
this._addTween(target.style, "strokeMiterlimit", end, end + 0.0001, "strokeMiterlimit");
}
}
this._live = (target.getAttribute("vector-effect") === "non-scaling-stroke" || (value + "").indexOf("live") !== -1);
return true;
},
//called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.)
set: function(ratio) {
if (this._firstPT) {
//when the element has vector-effect="non-scaling-stroke" and the SVG is resized (like on a window resize), it actually changes the length of the stroke! So we must sense that and make the proper adjustments.
if (this._live) {
var length = getLength(this._target) + 11,
lengthRatio;
if (length !== this._length) {
lengthRatio = length / this._length;
this._length = length;
this._offsetPT.s *= lengthRatio;
this._offsetPT.c *= lengthRatio;
if (this._dashPT) {
this._dashPT.s *= lengthRatio;
this._dashPT.c *= lengthRatio;
} else {
this._dash *= lengthRatio;
}
}
}
this._super.setRatio.call(this, ratio);
this._style.strokeDashoffset = this._offset;
if (ratio === 1 || ratio === 0) {
this._style.strokeDasharray = (this._offset < 0.001 && this._length - this._dash <= 10) ? "none" : (this._offset === this._dash) ? "0px, 999999px" : this._dash + "px," + this._length + "px";
} else {
this._style.strokeDasharray = this._dash + "px," + this._length + "px";
}
}
}
});
DrawSVGPlugin.getLength = getLength;
DrawSVGPlugin.getPosition = getPosition;
}); if (_gsScope._gsDefine) { _gsScope._gsQueue.pop()(); }
//export to AMD/RequireJS and CommonJS/Node (precursor to full modular build system coming at a later date)
(function(name) {
"use strict";
var getGlobal = function() {
return (_gsScope.GreenSockGlobals || _gsScope)[name];
};
if (typeof(module) !== "undefined" && module.exports) { //node
require("../TweenLite.js");
module.exports = getGlobal();
} else if (typeof(define) === "function" && define.amd) { //AMD
define(["TweenLite"], getGlobal);
}
}("DrawSVGPlugin"));

View File

@ -0,0 +1,325 @@
/*!
* VERSION: 0.2.2
* DATE: 2018-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
/* eslint-disable */
var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || window; //helps ensure compatibility with AMD/RequireJS and CommonJS/Node
(_gsScope._gsQueue || (_gsScope._gsQueue = [])).push( function() {
"use strict";
var _numExp = /(\d|\.)+/g,
_ColorFilter, _ColorMatrixFilter,
_colorProps = ["redMultiplier","greenMultiplier","blueMultiplier","alphaMultiplier","redOffset","greenOffset","blueOffset","alphaOffset"],
_colorLookup = {aqua:[0,255,255],
lime:[0,255,0],
silver:[192,192,192],
black:[0,0,0],
maroon:[128,0,0],
teal:[0,128,128],
blue:[0,0,255],
navy:[0,0,128],
white:[255,255,255],
fuchsia:[255,0,255],
olive:[128,128,0],
yellow:[255,255,0],
orange:[255,165,0],
gray:[128,128,128],
purple:[128,0,128],
green:[0,128,0],
red:[255,0,0],
pink:[255,192,203],
cyan:[0,255,255],
transparent:[255,255,255,0]},
_parseColor = function(color) {
if (color === "" || color == null || color === "none") {
return _colorLookup.transparent;
} else if (_colorLookup[color]) {
return _colorLookup[color];
} else if (typeof(color) === "number") {
return [color >> 16, (color >> 8) & 255, color & 255];
} else if (color.charAt(0) === "#") {
if (color.length === 4) { //for shorthand like #9F0
color = "#" + color.charAt(1) + color.charAt(1) + color.charAt(2) + color.charAt(2) + color.charAt(3) + color.charAt(3);
}
color = parseInt(color.substr(1), 16);
return [color >> 16, (color >> 8) & 255, color & 255];
}
return color.match(_numExp) || _colorLookup.transparent;
},
_parseColorFilter = function(t, v, pg) {
if (!_ColorFilter) {
_ColorFilter = (_gsScope.ColorFilter || _gsScope.createjs.ColorFilter);
if (!_ColorFilter) {
throw("EaselPlugin error: The EaselJS ColorFilter JavaScript file wasn't loaded.");
}
}
var filters = t.filters || [],
i = filters.length,
c, s, e, a, p;
while (--i > -1) {
if (filters[i] instanceof _ColorFilter) {
s = filters[i];
break;
}
}
if (!s) {
s = new _ColorFilter();
filters.push(s);
t.filters = filters;
}
e = s.clone();
if (v.tint != null) {
c = _parseColor(v.tint);
a = (v.tintAmount != null) ? Number(v.tintAmount) : 1;
e.redOffset = Number(c[0]) * a;
e.greenOffset = Number(c[1]) * a;
e.blueOffset = Number(c[2]) * a;
e.redMultiplier = e.greenMultiplier = e.blueMultiplier = 1 - a;
} else {
for (p in v) {
if (p !== "exposure") if (p !== "brightness") {
e[p] = Number(v[p]);
}
}
}
if (v.exposure != null) {
e.redOffset = e.greenOffset = e.blueOffset = 255 * (Number(v.exposure) - 1);
e.redMultiplier = e.greenMultiplier = e.blueMultiplier = 1;
} else if (v.brightness != null) {
a = Number(v.brightness) - 1;
e.redOffset = e.greenOffset = e.blueOffset = (a > 0) ? a * 255 : 0;
e.redMultiplier = e.greenMultiplier = e.blueMultiplier = 1 - Math.abs(a);
}
i = 8;
while (--i > -1) {
p = _colorProps[i];
if (s[p] !== e[p]) {
pg._addTween(s, p, s[p], e[p], "easel_colorFilter");
}
}
pg._overwriteProps.push("easel_colorFilter");
if (!t.cacheID) {
throw("EaselPlugin warning: for filters to display in EaselJS, you must call the object's cache() method first. " + t);
}
},
_idMatrix = [1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],
_lumR = 0.212671,
_lumG = 0.715160,
_lumB = 0.072169,
_applyMatrix = function(m, m2) {
if (!(m instanceof Array) || !(m2 instanceof Array)) {
return m2;
}
var temp = [],
i = 0,
z = 0,
y, x;
for (y = 0; y < 4; y++) {
for (x = 0; x < 5; x++) {
z = (x === 4) ? m[i + 4] : 0;
temp[i + x] = m[i] * m2[x] + m[i+1] * m2[x + 5] + m[i+2] * m2[x + 10] + m[i+3] * m2[x + 15] + z;
}
i += 5;
}
return temp;
},
_setSaturation = function(m, n) {
if (isNaN(n)) {
return m;
}
var inv = 1 - n,
r = inv * _lumR,
g = inv * _lumG,
b = inv * _lumB;
return _applyMatrix([r + n, g, b, 0, 0, r, g + n, b, 0, 0, r, g, b + n, 0, 0, 0, 0, 0, 1, 0], m);
},
_colorize = function(m, color, amount) {
if (isNaN(amount)) {
amount = 1;
}
var c = _parseColor(color),
r = c[0] / 255,
g = c[1] / 255,
b = c[2] / 255,
inv = 1 - amount;
return _applyMatrix([inv + amount * r * _lumR, amount * r * _lumG, amount * r * _lumB, 0, 0, amount * g * _lumR, inv + amount * g * _lumG, amount * g * _lumB, 0, 0, amount * b * _lumR, amount * b * _lumG, inv + amount * b * _lumB, 0, 0, 0, 0, 0, 1, 0], m);
},
_setHue = function(m, n) {
if (isNaN(n)) {
return m;
}
n *= Math.PI / 180;
var c = Math.cos(n),
s = Math.sin(n);
return _applyMatrix([(_lumR + (c * (1 - _lumR))) + (s * (-_lumR)), (_lumG + (c * (-_lumG))) + (s * (-_lumG)), (_lumB + (c * (-_lumB))) + (s * (1 - _lumB)), 0, 0, (_lumR + (c * (-_lumR))) + (s * 0.143), (_lumG + (c * (1 - _lumG))) + (s * 0.14), (_lumB + (c * (-_lumB))) + (s * -0.283), 0, 0, (_lumR + (c * (-_lumR))) + (s * (-(1 - _lumR))), (_lumG + (c * (-_lumG))) + (s * _lumG), (_lumB + (c * (1 - _lumB))) + (s * _lumB), 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1], m);
},
_setContrast = function(m, n) {
if (isNaN(n)) {
return m;
}
n += 0.01;
return _applyMatrix([n,0,0,0,128 * (1 - n), 0,n,0,0,128 * (1 - n), 0,0,n,0,128 * (1 - n), 0,0,0,1,0], m);
},
_parseColorMatrixFilter = function(t, v, pg) {
if (!_ColorMatrixFilter) {
_ColorMatrixFilter = (_gsScope.ColorMatrixFilter || _gsScope.createjs.ColorMatrixFilter);
if (!_ColorMatrixFilter) {
throw("EaselPlugin error: The EaselJS ColorMatrixFilter JavaScript file wasn't loaded.");
}
}
var filters = t.filters || [],
i = filters.length,
matrix, startMatrix, s;
while (--i > -1) {
if (filters[i] instanceof _ColorMatrixFilter) {
s = filters[i];
break;
}
}
if (!s) {
s = new _ColorMatrixFilter(_idMatrix.slice());
filters.push(s);
t.filters = filters;
}
startMatrix = s.matrix;
matrix = _idMatrix.slice();
if (v.colorize != null) {
matrix = _colorize(matrix, v.colorize, Number(v.colorizeAmount));
}
if (v.contrast != null) {
matrix = _setContrast(matrix, Number(v.contrast));
}
if (v.hue != null) {
matrix = _setHue(matrix, Number(v.hue));
}
if (v.saturation != null) {
matrix = _setSaturation(matrix, Number(v.saturation));
}
i = matrix.length;
while (--i > -1) {
if (matrix[i] !== startMatrix[i]) {
pg._addTween(startMatrix, i, startMatrix[i], matrix[i], "easel_colorMatrixFilter");
}
}
pg._overwriteProps.push("easel_colorMatrixFilter");
if (!t.cacheID) {
throw("EaselPlugin warning: for filters to display in EaselJS, you must call the object's cache() method first. " + t);
}
pg._matrix = startMatrix;
};
var EaselPlugin = _gsScope._gsDefine.plugin({
propName: "easel",
priority: -1,
version: "0.2.2",
API: 2,
//called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
init: function(target, value, tween, index) {
this._target = target;
var p, pt, tint, colorMatrix, end, labels, i;
for (p in value) {
end = value[p];
if (typeof(end) === "function") {
end = end(index, target);
}
if (p === "colorFilter" || p === "tint" || p === "tintAmount" || p === "exposure" || p === "brightness") {
if (!tint) {
_parseColorFilter(target, value.colorFilter || value, this);
tint = true;
}
} else if (p === "saturation" || p === "contrast" || p === "hue" || p === "colorize" || p === "colorizeAmount") {
if (!colorMatrix) {
_parseColorMatrixFilter(target, value.colorMatrixFilter || value, this);
colorMatrix = true;
}
} else if (p === "frame") {
this._firstPT = pt = {_next:this._firstPT, t:target, p:"gotoAndStop", s:target.currentFrame, f:true, n:"frame", pr:0, type:0, m:Math.round};
if (typeof(end) === "string" && end.charAt(1) !== "=" && (labels = target.labels)) {
for (i = 0; i < labels.length; i++) {
if (labels[i].label === end) {
end = labels[i].position;
}
}
}
pt.c = (typeof(end) === "number") ? end - pt.s : parseFloat((end+"").split("=").join(""));
if (pt._next) {
pt._next._prev = pt;
}
} else if (target[p] != null) {
this._firstPT = pt = {_next:this._firstPT, t:target, p:p, f:(typeof(target[p]) === "function"), n:p, pr:0, type:0};
pt.s = (!pt.f) ? parseFloat(target[p]) : target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]();
pt.c = (typeof(end) === "number") ? end - pt.s : (typeof(end) === "string") ? parseFloat(end.split("=").join("")) : 0;
if (pt._next) {
pt._next._prev = pt;
}
}
}
return true;
},
//called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.)
set: function(v) {
var pt = this._firstPT,
min = 0.000001,
val;
while (pt) {
val = pt.c * v + pt.s;
if (pt.m) {
val = pt.m(val, pt.t);
} else if (val < min && val > -min) {
val = 0;
}
if (pt.f) {
pt.t[pt.p](val);
} else {
pt.t[pt.p] = val;
}
pt = pt._next;
}
if (this._target.cacheID) {
this._target.updateCache();
}
}
});
}); if (_gsScope._gsDefine) { _gsScope._gsQueue.pop()(); }
//export to AMD/RequireJS and CommonJS/Node (precursor to full modular build system coming at a later date)
(function(name) {
"use strict";
var getGlobal = function() {
return (_gsScope.GreenSockGlobals || _gsScope)[name];
};
if (typeof(module) !== "undefined" && module.exports) { //node
require("../TweenLite.js");
module.exports = getGlobal();
} else if (typeof(define) === "function" && define.amd) { //AMD
define(["TweenLite"], getGlobal);
}
}("EaselPlugin"));

View File

@ -0,0 +1,72 @@
/*!
* VERSION: 0.1.3
* DATE: 2018-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || window; //helps ensure compatibility with AMD/RequireJS and CommonJS/Node
(_gsScope._gsQueue || (_gsScope._gsQueue = [])).push( function() {
"use strict";
_gsScope._gsDefine.plugin({
propName: "endArray",
API: 2,
version: "0.1.3",
//called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
init: function(target, value, tween) {
var i = value.length,
a = this.a = [],
start, end;
this.target = target;
this._mod = 0;
if (!i) {
return false;
}
while (--i > -1) {
start = target[i];
end = value[i];
if (start !== end) {
a.push({i:i, s:start, c:end - start});
}
}
return true;
},
mod: function(lookup) {
if (typeof(lookup.endArray) === "function") {
this._mod = lookup.endArray;
}
},
//called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.)
set: function(ratio) {
var target = this.target,
a = this.a,
i = a.length,
mod = this._mod,
e, val;
if (mod) {
while (--i > -1) {
e = a[i];
target[e.i] = mod(e.s + e.c * ratio, target);
}
} else {
while (--i > -1) {
e = a[i];
val = e.s + e.c * ratio;
target[e.i] = (val < 0.000001 && val > -0.000001) ? 0 : val;
}
}
}
});
}); if (_gsScope._gsDefine) { _gsScope._gsQueue.pop()(); }

View File

@ -0,0 +1,186 @@
/*!
* VERSION: 0.0.4
* DATE: 2018-05-21
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || window; //helps ensure compatibility with AMD/RequireJS and CommonJS/Node
(_gsScope._gsQueue || (_gsScope._gsQueue = [])).push( function() {
"use strict";
var _cssRatioSetter = function(pt, cssp, mod) { //Takes an individual CSSPropTween and converts it into a type:2 that has a setRatio that does everything the regular CSSPlugin.setRatio() method does but applying the mod() too. We do this to keep the main CSSPlugin.setRatio() as fast as possible (the vast majority of times, no mod() will be necessary)
var type = pt.type,
oldSetRatio = pt.setRatio,
tween = cssp._tween,
target = cssp._target;
pt.type = 2;
pt.m = mod;
pt.setRatio = function(v) {
var min = 0.000001,
val, str, i;
if (v === 1 && (tween._time === tween._duration || tween._time === 0)) {
if (type !== 2) {
if (pt.r && type !== -1) {
val = Math.round(pt.s + pt.c);
if (!type) {
pt.t[pt.p] = mod.call(tween, val + pt.xs0, target, tween);
} else if (type === 1) {
str = pt.xs0 + val + pt.xs1;
for (i = 1; i < pt.l; i++) {
str += pt["xn"+i] + pt["xs"+(i+1)];
}
pt.t[pt.p] = mod.call(tween, str, target, tween);
}
} else {
pt.t[pt.p] = mod.call(tween, pt.e, target, tween);
}
} else {
oldSetRatio.call(pt, v);
}
} else if (v || !(tween._time === tween._duration || tween._time === 0) || tween._rawPrevTime === -0.000001) {
val = pt.c * v + pt.s;
if (pt.r) {
val = Math.round(val);
} else if (val < min) if (val > -min) {
val = 0;
}
if (!type) {
pt.t[pt.p] = mod.call(tween, val + pt.xs0, target, tween);
} else if (type === 1) {
str = pt.xs0 + val + pt.xs1;
for (i = 1; i < pt.l; i++) {
str += pt["xn"+i] + pt["xs"+(i+1)];
}
pt.t[pt.p] = mod.call(tween, str, target, tween);
} else if (type === -1) { //non-tweening value
pt.t[pt.p] = mod.call(tween, pt.xs0, target, tween);
} else if (oldSetRatio) {
oldSetRatio.call(pt, v);
}
} else {
if (type !== 2) {
pt.t[pt.p] = mod.call(tween, pt.b, target, tween);
} else {
oldSetRatio.call(pt, v);
}
}
};
},
_modCSS = function(lookup, cssp) {
var pt = cssp._firstPT,
hasBezier = (lookup.rotation && cssp._overwriteProps.join("").indexOf("bezier") !== -1); //when a Bezier tween is applying autoRotation, it's a very special case we need to handle differently.
if (lookup.scale) {
lookup.scaleX = lookup.scaleY = lookup.scale;
} else if (lookup.rotationZ) {
lookup.rotation = lookup.rotationZ;
}
while (pt) {
if (typeof(lookup[pt.p]) === "function") {
_cssRatioSetter(pt, cssp, lookup[pt.p]);
} else if (hasBezier && pt.n === "bezier" && pt.plugin._overwriteProps.join("").indexOf("rotation") !== -1) {
pt.data.mod = lookup.rotation;
}
pt = pt._next;
}
},
ModifiersPlugin = _gsScope._gsDefine.plugin({
propName: "modifiers",
version: "0.0.4",
API: 2,
//called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
init: function(target, value, tween) {
this._tween = tween;
this._vars = value;
return true;
},
initAll: function() {
var tween = this._tween,
lookup = this._vars,
mpt = this,
pt = tween._firstPT,
val, next;
//initAll() gets called for each and every ModifiersPlugin instance in a tween, so if there are multiple targets, there will be multiple instances. Since we're ripping through the whole tween (and all the PropTweens), we only need to run this code ONCE. So we're setting a toggle on the first PropTween that just tells us if we've done it already. We don't set it on the tween instance because if it gets invalidated, we don't want to have to track this property and reset it. PropTweens get blown away when a tween is invalidated.
if (pt._modInitted) {
return false;
} else {
pt._modInitted = 1;
}
while (pt) {
next = pt._next; //record here, because it may get removed
val = lookup[pt.n];
if (pt.pg) {
if (pt.t._propName === "css") { //handle CSSPlugin uniquely (for performance, due to the fact that the values almost always are a concatenation of numbers and strings, like suffixes, and we don't want to slow down the regular CSSPlugin setRatio() performance with conditional checks for if the value needs to be modded, so we pull any modding prop out and change it to a type:2 one that simply calls a setRatio() method where we encapsulate the modding and update all together. That way, it says in the main CSSProp linked list and just has some custom logic applied to it inside its setRatio())
_modCSS(lookup, pt.t);
} else if (pt.t !== mpt) { //don't run modProps on modProps :)
val = lookup[pt.t._propName];
pt.t._tween = tween;
pt.t._mod((typeof(val) === "object") ? val : lookup);
}
} else if (typeof(val) === "function") {
if (pt.f === 2 && pt.t) { //a blob (text containing multiple numeric values)
pt.t._applyPT.m = val;
pt.t._tween = tween;
} else {
this._add(pt.t, pt.p, pt.s, pt.c, val);
//remove from linked list
if (next) {
next._prev = pt._prev;
}
if (pt._prev) {
pt._prev._next = next;
} else if (tween._firstPT === pt) {
tween._firstPT = next;
}
pt._next = pt._prev = null;
tween._propLookup[pt.n] = mpt;
}
}
pt = next;
}
return false;
}
}),
p = ModifiersPlugin.prototype;
p._add = function(target, p, s, c, mod) {
this._addTween(target, p, s, s + c, p, mod);
this._overwriteProps.push(p);
};
p = _gsScope._gsDefine.globals.TweenLite.version.split(".");
if (Number(p[0]) <= 1 && Number(p[1]) < 19 && _gsScope.console) {
console.log("ModifiersPlugin requires GSAP 1.19.0 or later.");
}
}); if (_gsScope._gsDefine) { _gsScope._gsQueue.pop()(); }
//export to AMD/RequireJS and CommonJS/Node (precursor to full modular build system coming at a later date)
(function(name) {
"use strict";
var getGlobal = function() {
return (_gsScope.GreenSockGlobals || _gsScope)[name];
};
if (typeof(module) !== "undefined" && module.exports) { //node
require("../TweenLite.js");
module.exports = getGlobal();
} else if (typeof(define) === "function" && define.amd) { //AMD
define(["TweenLite"], getGlobal);
}
}("ModifiersPlugin"));

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,207 @@
/*!
* VERSION: 0.2.1
* DATE: 2018-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* Physics2DPlugin is a Club GreenSock membership benefit; You must have a valid membership to use
* this code without violating the terms of use. Visit http://greensock.com/club/ to sign up or get more details.
* This work is subject to the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || window; //helps ensure compatibility with AMD/RequireJS and CommonJS/Node
(_gsScope._gsQueue || (_gsScope._gsQueue = [])).push( function() {
"use strict";
var _DEG2RAD = Math.PI / 180,
Physics2DProp = function(target, p, velocity, acceleration, stepsPerTimeUnit) {
this.p = p;
this.f = (typeof(target[p]) === "function");
this.start = this.value = (!this.f) ? parseFloat(target[p]) : target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]();
this.velocity = velocity || 0;
this.v = this.velocity / stepsPerTimeUnit;
if (acceleration || acceleration === 0) {
this.acceleration = acceleration;
this.a = this.acceleration / (stepsPerTimeUnit * stepsPerTimeUnit);
} else {
this.acceleration = this.a = 0;
}
},
_random = Math.random(),
_globals = _gsScope._gsDefine.globals,
_rootFramesTimeline = _globals.com.greensock.core.Animation._rootFramesTimeline,
Physics2DPlugin = _gsScope._gsDefine.plugin({
propName: "physics2D",
version: "0.2.1",
API: 2,
//called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
init: function(target, value, tween, index) {
if (typeof(value) === "function") {
value = value(index, target);
}
this._target = target;
this._tween = tween;
this._runBackwards = (tween.vars.runBackwards === true);
this._step = 0;
var tl = tween._timeline,
angle = Number(value.angle) || 0,
velocity = Number(value.velocity) || 0,
acceleration = Number(value.acceleration) || 0,
xProp = value.xProp || "x",
yProp = value.yProp || "y",
aAngle = (value.accelerationAngle || value.accelerationAngle === 0) ? Number(value.accelerationAngle) : angle,
stepsPerTimeUnit;
while (tl._timeline) {
tl = tl._timeline;
}
this._stepsPerTimeUnit = stepsPerTimeUnit = (tl === _rootFramesTimeline) ? 1 : 30;
if (value.gravity) {
acceleration = Number(value.gravity);
aAngle = 90;
}
angle *= _DEG2RAD;
aAngle *= _DEG2RAD;
this._friction = 1 - Number(value.friction || 0);
this._overwriteProps.push(xProp);
this._overwriteProps.push(yProp);
this._x = new Physics2DProp(target, xProp, Math.cos(angle) * velocity, Math.cos(aAngle) * acceleration, stepsPerTimeUnit);
this._y = new Physics2DProp(target, yProp, Math.sin(angle) * velocity, Math.sin(aAngle) * acceleration, stepsPerTimeUnit);
this._skipX = this._skipY = false;
return true;
},
//called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.)
set: function(ratio) {
var time = this._tween._time,
xp = this._x,
yp = this._y,
x, y, tt, steps, remainder, i;
if (this._runBackwards === true) {
time = this._tween._duration - time;
}
if (this._friction === 1) {
tt = time * time * 0.5;
x = xp.start + ((xp.velocity * time) + (xp.acceleration * tt));
y = yp.start + ((yp.velocity * time) + (yp.acceleration * tt));
} else {
time *= this._stepsPerTimeUnit;
steps = i = (time | 0) - this._step;
remainder = (time % 1);
if (i >= 0) { //going forward
while (--i > -1) {
xp.v += xp.a;
yp.v += yp.a;
xp.v *= this._friction;
yp.v *= this._friction;
xp.value += xp.v;
yp.value += yp.v;
}
} else { //going backwards
i = -i;
while (--i > -1) {
xp.value -= xp.v;
yp.value -= yp.v;
xp.v /= this._friction;
yp.v /= this._friction;
xp.v -= xp.a;
yp.v -= yp.a;
}
}
x = xp.value + (xp.v * remainder);
y = yp.value + (yp.v * remainder);
this._step += steps;
}
if (!this._skipX) {
if (xp.m) {
x = xp.m(x, this._target);
}
if (xp.f) {
this._target[xp.p](x);
} else {
this._target[xp.p] = x;
}
}
if (!this._skipY) {
if (yp.m) {
y = yp.m(y, this._target);
}
if (yp.f) {
this._target[yp.p](y);
} else {
this._target[yp.p] = y;
}
}
}
}),
p = Physics2DPlugin.prototype;
p._kill = function(lookup) {
if (lookup[this._x.p] != null) {
this._skipX = true;
}
if (lookup[this._y.p] != null) {
this._skipY = true;
}
return this._super._kill.call(this, lookup);
};
p._mod = function(lookup) {
var val = lookup[this._x.p] || lookup.physics2D;
if (val && typeof(val) === "function") {
this._x.m = val;
}
val = lookup[this._y.p] || lookup.physics2D;
if (val && typeof(val) === "function") {
this._y.m = val;
}
};
Physics2DPlugin._autoCSS = true; //indicates that this plugin can be inserted into the "css" object using the autoCSS feature of TweenLite
Physics2DPlugin._cssRegister = function() {
var CSSPlugin = _globals.CSSPlugin;
if (!CSSPlugin) {
return;
}
var _internals = CSSPlugin._internals,
_parseToProxy = _internals._parseToProxy,
_setPluginRatio = _internals._setPluginRatio,
CSSPropTween = _internals.CSSPropTween;
_internals._registerComplexSpecialProp("physics2D", {parser:function(t, e, prop, cssp, pt, plugin) {
plugin = new Physics2DPlugin();
var xProp = e.xProp || "x",
yProp = e.yProp || "y",
vars = {},
data;
vars[xProp] = vars[yProp] = _random++; //doesn't really matter what values we put here because the plugin will determine end values, but it'd be best of the values don't match the current ones so that CSSPlugin doesn't skip creating a CSSPropTween.
data = _parseToProxy(t, vars, cssp, pt, plugin);
pt = new CSSPropTween(t, "physics2D", 0, 0, data.pt, 2);
pt.data = data;
pt.plugin = plugin;
pt.setRatio = _setPluginRatio;
plugin._onInitTween(data.proxy, e, cssp._tween);
return pt;
}});
};
}); if (_gsScope._gsDefine) { _gsScope._gsQueue.pop()(); }
//export to AMD/RequireJS and CommonJS/Node (precursor to full modular build system coming at a later date)
(function(name) {
"use strict";
var getGlobal = function() {
return (_gsScope.GreenSockGlobals || _gsScope)[name];
};
if (typeof(module) !== "undefined" && module.exports) { //node
require("../TweenLite.js");
module.exports = getGlobal();
} else if (typeof(define) === "function" && define.amd) { //AMD
define(["TweenLite"], getGlobal);
}
}("Physics2DPlugin"));

View File

@ -0,0 +1,215 @@
/*!
* VERSION: 0.2.1
* DATE: 2018-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* PhysicsPropsPlugin is a Club GreenSock membership benefit; You must have a valid membership to use
* this code without violating the terms of use. Visit http://greensock.com/club/ to sign up or get more details.
* This work is subject to the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || window; //helps ensure compatibility with AMD/RequireJS and CommonJS/Node
(_gsScope._gsQueue || (_gsScope._gsQueue = [])).push( function() {
"use strict";
var PhysicsProp = function(target, p, velocity, acceleration, friction, stepsPerTimeUnit) {
this.p = p;
this.f = (typeof(target[p]) === "function");
this.start = this.value = (!this.f) ? parseFloat(target[p]) : target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]();
this.velocity = velocity || 0;
this.v = this.velocity / stepsPerTimeUnit;
if (acceleration || acceleration == 0) {
this.acceleration = acceleration;
this.a = this.acceleration / (stepsPerTimeUnit * stepsPerTimeUnit);
} else {
this.acceleration = this.a = 0;
}
this.friction = 1 - (friction || 0) ;
},
_random = Math.random(),
_globals = _gsScope._gsDefine.globals,
_rootFramesTimeline = _globals.com.greensock.core.Animation._rootFramesTimeline,
PhysicsPropsPlugin = _gsScope._gsDefine.plugin({
propName: "physicsProps",
version: "0.2.1",
API: 2,
//called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
init: function(target, value, tween, index) {
if (typeof(value) === "function") {
value = value(target);
}
this._target = target;
this._tween = tween;
this._runBackwards = (tween.vars.runBackwards === true);
this._step = 0;
var tl = tween._timeline,
cnt = 0,
p, curProp;
while (tl._timeline) {
tl = tl._timeline;
}
this._stepsPerTimeUnit = (tl === _rootFramesTimeline) ? 1 : 30;
this._props = [];
for (p in value) {
curProp = value[p];
if (typeof(curProp) === "function") {
curProp = curProp(index, target);
}
if (curProp.velocity || curProp.acceleration) {
this._props[cnt++] = new PhysicsProp(target, p, curProp.velocity, curProp.acceleration, curProp.friction, this._stepsPerTimeUnit);
this._overwriteProps[cnt] = p;
if (curProp.friction) {
this._hasFriction = true;
}
}
}
return true;
},
//called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.)
set: function(ratio) {
var i = this._props.length,
time = this._tween._time,
target = this._target,
curProp, val, steps, remainder, j, tt;
if (this._runBackwards) {
time = this._tween._duration - time;
}
if (this._hasFriction) {
time *= this._stepsPerTimeUnit;
steps = (time | 0) - this._step;
remainder = time % 1;
if (steps >= 0) { //going forward
while (--i > -1) {
curProp = this._props[i];
j = steps;
while (--j > -1) {
curProp.v += curProp.a;
curProp.v *= curProp.friction;
curProp.value += curProp.v;
}
val = curProp.value + (curProp.v * remainder);
if (curProp.m) {
val = curProp.m(val, target);
}
if (curProp.f) {
target[curProp.p](val);
} else {
target[curProp.p] = val;
}
}
} else { //going backwards
while (--i > -1) {
curProp = this._props[i];
j = -steps;
while (--j > -1) {
curProp.value -= curProp.v;
curProp.v /= curProp.friction;
curProp.v -= curProp.a;
}
val = curProp.value + (curProp.v * remainder);
if (curProp.m) {
val = curProp.m(val, target);
}
if (curProp.f) {
target[curProp.p](val);
} else {
target[curProp.p] = val;
}
}
}
this._step += steps;
} else {
tt = time * time * 0.5;
while (--i > -1) {
curProp = this._props[i];
val = curProp.start + ((curProp.velocity * time) + (curProp.acceleration * tt));
if (curProp.m) {
val = curProp.m(val, target);
}
if (curProp.f) {
target[curProp.p](val);
} else {
target[curProp.p] = val;
}
}
}
}
}),
p = PhysicsPropsPlugin.prototype;
p._kill = function(lookup) {
var i = this._props.length;
while (--i > -1) {
if (this._props[i].p in lookup) {
this._props.splice(i, 1);
}
}
return this._super._kill.call(this, lookup);
};
p._mod = function(lookup) {
var i = this._props.length,
val;
while (--i > -1) {
val = lookup[this._props[i].p] || lookup.physicsProps;
if (typeof(val) === "function") {
this._props[i].m = val;
}
}
};
PhysicsPropsPlugin._autoCSS = true; //indicates that this plugin can be inserted into the "css" object using the autoCSS feature of TweenLite
PhysicsPropsPlugin._cssRegister = function() {
var CSSPlugin = _globals.CSSPlugin;
if (!CSSPlugin) {
return;
}
var _internals = CSSPlugin._internals,
_parseToProxy = _internals._parseToProxy,
_setPluginRatio = _internals._setPluginRatio,
CSSPropTween = _internals.CSSPropTween;
_internals._registerComplexSpecialProp("physicsProps", {parser:function(t, e, prop, cssp, pt, plugin) {
plugin = new PhysicsPropsPlugin();
var vars = {},
p, data;
if (e.scale) {
e.scaleX = e.scaleY = e.scale;
delete e.scale;
}
for (p in e) {
vars[p] = _random++; //doesn't really matter what values we put here because the plugin will determine end values, but it'd be best of the values don't match the current ones so that CSSPlugin doesn't skip creating a CSSPropTween.
}
data = _parseToProxy(t, vars, cssp, pt, plugin);
pt = new CSSPropTween(t, "physicsProps", 0, 0, data.pt, 2);
pt.data = data;
pt.plugin = plugin;
pt.setRatio = _setPluginRatio;
plugin._onInitTween(data.proxy, e, cssp._tween);
return pt;
}});
};
}); if (_gsScope._gsDefine) { _gsScope._gsQueue.pop()(); }
//export to AMD/RequireJS and CommonJS/Node (precursor to full modular build system coming at a later date)
(function(name) {
"use strict";
var getGlobal = function() {
return (_gsScope.GreenSockGlobals || _gsScope)[name];
};
if (typeof(module) !== "undefined" && module.exports) { //node
require("../TweenLite.js");
module.exports = getGlobal();
} else if (typeof(define) === "function" && define.amd) { //AMD
define(["TweenLite"], getGlobal);
}
}("PhysicsPropsPlugin"));

View File

@ -0,0 +1,479 @@
/*!
* VERSION: 0.2.1
* DATE: 2018-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* PixiPlugin is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
var _gsScope = (typeof module !== "undefined" && module.exports && typeof global !== "undefined") ? global : this || window;
(_gsScope._gsQueue || (_gsScope._gsQueue = [])).push(function () {
"use strict";
var _numExp = /(\d|\.)+/g,
_relNumExp = /(?:\d|\-\d|\.\d|\-\.\d|\+=\d|\-=\d|\+=.\d|\-=\.\d)+/g,
_colorLookup = {aqua:[0,255,255],
lime:[0,255,0],
silver:[192,192,192],
black:[0,0,0],
maroon:[128,0,0],
teal:[0,128,128],
blue:[0,0,255],
navy:[0,0,128],
white:[255,255,255],
fuchsia:[255,0,255],
olive:[128,128,0],
yellow:[255,255,0],
orange:[255,165,0],
gray:[128,128,128],
purple:[128,0,128],
green:[0,128,0],
red:[255,0,0],
pink:[255,192,203],
cyan:[0,255,255],
transparent:[255,255,255,0]},
_hue = function(h, m1, m2) {
h = (h < 0) ? h + 1 : (h > 1) ? h - 1 : h;
return ((((h * 6 < 1) ? m1 + (m2 - m1) * h * 6 : (h < 0.5) ? m2 : (h * 3 < 2) ? m1 + (m2 - m1) * (2 / 3 - h) * 6 : m1) * 255) + 0.5) | 0;
},
/**
* @private Parses a color (like #9F0, #FF9900, rgb(255,51,153) or hsl(108, 50%, 10%)) into an array with 3 elements for red, green, and blue or if "format" parameter is "hsl", it will populate the array with hue, saturation, and lightness values. Or if "format" is "number", it'll return a number like 0xFF0000 instead of an array. If a relative value is found in an hsl() or hsla() string, it will preserve those relative prefixes and all the values in the array will be strings instead of numbers (in all other cases it will be populated with numbers).
* @param {(string|number)} v The value the should be parsed which could be a string like #9F0 or rgb(255,102,51) or rgba(255,0,0,0.5) or it could be a number like 0xFF00CC or even a named color like red, blue, purple, etc.
* @param {(string)} format If "hsl", an hsl() or hsla() value will be returned instead of rgb() or rgba(). Or if "number", then a numeric value will be returned, like 0xFF0000. Default is rgb.
* @return {(array|number)} An array containing red, green, and blue (and optionally alpha) in that order, or if the format parameter was "hsl", the array will contain hue, saturation and lightness (and optionally alpha) in that order. Or if "format" is defined as "number", it'll return a number like 0xFF0000. Always numbers unless there's a relative prefix found in an hsl() or hsla() string and "format" is "hsl".
*/
_parseColor = function(v, format) {
var toHSL = (format === "hsl"),
a, r, g, b, h, s, l, max, min, d, wasHSL;
if (!v) {
a = _colorLookup.black;
} else if (typeof(v) === "number") {
a = [v >> 16, (v >> 8) & 255, v & 255];
} else {
if (v.charAt(v.length - 1) === ",") { //sometimes a trailing comma is included and we should chop it off (typically from a comma-delimited list of values like a textShadow:"2px 2px 2px blue, 5px 5px 5px rgb(255,0,0)" - in this example "blue," has a trailing comma. We could strip it out inside parseComplex() but we'd need to do it to the beginning and ending values plus it wouldn't provide protection from other potential scenarios like if the user passes in a similar value.
v = v.substr(0, v.length - 1);
}
if (_colorLookup[v]) {
a = _colorLookup[v];
} else if (v.charAt(0) === "#") {
if (v.length === 4) { //for shorthand like #9F0
r = v.charAt(1);
g = v.charAt(2);
b = v.charAt(3);
v = "#" + r + r + g + g + b + b;
}
v = parseInt(v.substr(1), 16);
a = [v >> 16, (v >> 8) & 255, v & 255];
} else if (v.substr(0, 3) === "hsl") {
a = wasHSL = v.match(_numExp);
if (!toHSL) {
h = (Number(a[0]) % 360) / 360;
s = Number(a[1]) / 100;
l = Number(a[2]) / 100;
g = (l <= 0.5) ? l * (s + 1) : l + s - l * s;
r = l * 2 - g;
if (a.length > 3) {
a[3] = Number(v[3]);
}
a[0] = _hue(h + 1 / 3, r, g);
a[1] = _hue(h, r, g);
a[2] = _hue(h - 1 / 3, r, g);
} else if (v.indexOf("=") !== -1) { //if relative values are found, just return the raw strings with the relative prefixes in place.
return v.match(_relNumExp);
}
} else {
a = v.match(_numExp) || _colorLookup.transparent;
}
a[0] = Number(a[0]);
a[1] = Number(a[1]);
a[2] = Number(a[2]);
if (a.length > 3) {
a[3] = Number(a[3]);
}
}
if (toHSL && !wasHSL) {
r = a[0] / 255;
g = a[1] / 255;
b = a[2] / 255;
max = Math.max(r, g, b);
min = Math.min(r, g, b);
l = (max + min) / 2;
if (max === min) {
h = s = 0;
} else {
d = max - min;
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
h = (max === r) ? (g - b) / d + (g < b ? 6 : 0) : (max === g) ? (b - r) / d + 2 : (r - g) / d + 4;
h *= 60;
}
a[0] = (h + 0.5) | 0;
a[1] = (s * 100 + 0.5) | 0;
a[2] = (l * 100 + 0.5) | 0;
}
return (format === "number") ? (a[0] << 16 | a[1] << 8 | a[2]) : a;
},
_formatColors = function(s, toHSL) {
var colors = (s + "").match(_colorExp) || [],
charIndex = 0,
parsed = "",
i, color, temp;
if (!colors.length) {
return s;
}
for (i = 0; i < colors.length; i++) {
color = colors[i];
temp = s.substr(charIndex, s.indexOf(color, charIndex)-charIndex);
charIndex += temp.length + color.length;
color = _parseColor(color, (toHSL ? "hsl" : "rgb"));
if (color.length === 3) {
color.push(1);
}
parsed += temp + (toHSL ? "hsla(" + color[0] + "," + color[1] + "%," + color[2] + "%," + color[3] : "rgba(" + color.join(",")) + ")";
}
return parsed + s.substr(charIndex);
}, _colorStringFilter,
TweenLite = (_gsScope.GreenSockGlobals || _gsScope).TweenLite,
_colorExp = "(?:\\b(?:(?:rgb|rgba|hsl|hsla)\\(.+?\\))|\\B#(?:[0-9a-f]{3}){1,2}\\b", //we'll dynamically build this Regular Expression to conserve file size. After building it, it will be able to find rgb(), rgba(), # (hexadecimal), and named color values like red, blue, purple, etc.
_idMatrix = [1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],
_lumR = 0.212671,
_lumG = 0.715160,
_lumB = 0.072169,
_applyMatrix = function(m, m2) {
var temp = [],
i = 0,
z = 0,
y, x;
for (y = 0; y < 4; y++) {
for (x = 0; x < 5; x++) {
z = (x === 4) ? m[i + 4] : 0;
temp[i + x] = m[i] * m2[x] + m[i+1] * m2[x + 5] + m[i+2] * m2[x + 10] + m[i+3] * m2[x + 15] + z;
}
i += 5;
}
return temp;
},
_setSaturation = function(m, n) {
var inv = 1 - n,
r = inv * _lumR,
g = inv * _lumG,
b = inv * _lumB;
return _applyMatrix([r + n, g, b, 0, 0, r, g + n, b, 0, 0, r, g, b + n, 0, 0, 0, 0, 0, 1, 0], m);
},
_colorize = function(m, color, amount) {
var c = _parseColor(color),
r = c[0] / 255,
g = c[1] / 255,
b = c[2] / 255,
inv = 1 - amount;
return _applyMatrix([inv + amount * r * _lumR, amount * r * _lumG, amount * r * _lumB, 0, 0, amount * g * _lumR, inv + amount * g * _lumG, amount * g * _lumB, 0, 0, amount * b * _lumR, amount * b * _lumG, inv + amount * b * _lumB, 0, 0, 0, 0, 0, 1, 0], m);
},
_setHue = function(m, n) {
n *= Math.PI / 180;
var c = Math.cos(n),
s = Math.sin(n);
return _applyMatrix([(_lumR + (c * (1 - _lumR))) + (s * (-_lumR)), (_lumG + (c * (-_lumG))) + (s * (-_lumG)), (_lumB + (c * (-_lumB))) + (s * (1 - _lumB)), 0, 0, (_lumR + (c * (-_lumR))) + (s * 0.143), (_lumG + (c * (1 - _lumG))) + (s * 0.14), (_lumB + (c * (-_lumB))) + (s * -0.283), 0, 0, (_lumR + (c * (-_lumR))) + (s * (-(1 - _lumR))), (_lumG + (c * (-_lumG))) + (s * _lumG), (_lumB + (c * (1 - _lumB))) + (s * _lumB), 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1], m);
},
_setContrast = function(m, n) {
return _applyMatrix([n,0,0,0,0.5 * (1 - n), 0,n,0,0,0.5 * (1 - n), 0,0,n,0,0.5 * (1 - n), 0,0,0,1,0], m);
},
_getFilter = function(t, type) {
var filterClass = _gsScope.PIXI.filters[type],
filters = t.filters || [],
i = filters.length,
filter;
if (!filterClass) {
throw("PixiPlugin error: " + type + " isn't present.");
}
while (--i > -1) {
if (filters[i] instanceof filterClass) {
return filters[i];
}
}
filter = new filterClass();
if (type === "BlurFilter") {
filter.blur = 0;
}
filters.push(filter);
t.filters = filters;
return filter;
},
_addColorMatrixFilterCacheTween = function(p, pg, cache, vars) { //we cache the ColorMatrixFilter components in a _gsColorMatrixFilter object attached to the target object so that it's easy to grab the current value at any time.
pg._addTween(cache, p, cache[p], vars[p], p);
pg._overwriteProps.push(p);
},
_applyBrightnessToMatrix = function(brightness, matrix) {
var temp = new _gsScope.PIXI.filters.ColorMatrixFilter();
temp.matrix = matrix;
temp.brightness(brightness, true);
return temp.matrix;
},
_CMFdefaults = {contrast:1, saturation:1, colorizeAmount:0, colorize:"rgb(255,255,255)", hue:0, brightness:1},
_parseColorMatrixFilter = function(t, v, pg) {
var filter = _getFilter(t, "ColorMatrixFilter"),
cache = t._gsColorMatrixFilter = t._gsColorMatrixFilter || {contrast:1, saturation:1, colorizeAmount:0, colorize:"rgb(255,255,255)", hue:0, brightness:1},
combine = v.combineCMF && !("colorMatrixFilter" in v && !v.colorMatrixFilter),
i, matrix, startMatrix;
startMatrix = filter.matrix;
if (v.resolution) {
filter.resolution = v.resolution;
}
if (v.matrix && v.matrix.length === startMatrix.length) {
matrix = v.matrix;
if (cache.contrast !== 1) {
_addColorMatrixFilterCacheTween("contrast", pg, cache, _CMFdefaults);
}
if (cache.hue) {
_addColorMatrixFilterCacheTween("hue", pg, cache, _CMFdefaults);
}
if (cache.brightness !== 1) {
_addColorMatrixFilterCacheTween("brightness", pg, cache, _CMFdefaults);
}
if (cache.colorizeAmount) {
_addColorMatrixFilterCacheTween("colorize", pg, cache, _CMFdefaults);
_addColorMatrixFilterCacheTween("colorizeAmount", pg, cache, _CMFdefaults);
}
if (cache.saturation !== 1) {
_addColorMatrixFilterCacheTween("saturation", pg, cache, _CMFdefaults);
}
} else {
matrix = _idMatrix.slice();
if (v.contrast != null) {
matrix = _setContrast(matrix, Number(v.contrast));
_addColorMatrixFilterCacheTween("contrast", pg, cache, v);
} else if (cache.contrast !== 1) {
if (combine) {
matrix = _setContrast(matrix, cache.contrast);
} else {
_addColorMatrixFilterCacheTween("contrast", pg, cache, _CMFdefaults);
}
}
if (v.hue != null) {
matrix = _setHue(matrix, Number(v.hue));
_addColorMatrixFilterCacheTween("hue", pg, cache, v);
} else if (cache.hue) {
if (combine) {
matrix = _setHue(matrix, cache.hue);
} else {
_addColorMatrixFilterCacheTween("hue", pg, cache, _CMFdefaults);
}
}
if (v.brightness != null) {
matrix = _applyBrightnessToMatrix(Number(v.brightness), matrix);
_addColorMatrixFilterCacheTween("brightness", pg, cache, v);
} else if (cache.brightness !== 1) {
if (combine) {
matrix = _applyBrightnessToMatrix(cache.brightness, matrix);
} else {
_addColorMatrixFilterCacheTween("brightness", pg, cache, _CMFdefaults);
}
}
if (v.colorize != null) {
v.colorizeAmount = ("colorizeAmount" in v) ? Number(v.colorizeAmount) : 1;
matrix = _colorize(matrix, v.colorize, v.colorizeAmount);
_addColorMatrixFilterCacheTween("colorize", pg, cache, v);
_addColorMatrixFilterCacheTween("colorizeAmount", pg, cache, v);
} else if (cache.colorizeAmount) {
if (combine) {
matrix = _colorize(matrix, cache.colorize, cache.colorizeAmount);
} else {
_addColorMatrixFilterCacheTween("colorize", pg, cache, _CMFdefaults);
_addColorMatrixFilterCacheTween("colorizeAmount", pg, cache, _CMFdefaults);
}
}
if (v.saturation != null) {
matrix = _setSaturation(matrix, Number(v.saturation));
_addColorMatrixFilterCacheTween("saturation", pg, cache, v);
} else if (cache.saturation !== 1) {
if (combine) {
matrix = _setSaturation(matrix, cache.saturation);
} else {
_addColorMatrixFilterCacheTween("saturation", pg, cache, _CMFdefaults);
}
}
}
i = matrix.length;
while (--i > -1) {
if (matrix[i] !== startMatrix[i]) {
pg._addTween(startMatrix, i, startMatrix[i], matrix[i], "colorMatrixFilter");
}
}
pg._overwriteProps.push("colorMatrixFilter");
},
_addColorTween = function(target, p, value, colorSetter, plugin) {
var pt = colorSetter._firstPT = {_next:colorSetter._firstPT, t:target, p:p, proxy:{}, f:(typeof(target[p]) === "function")};
pt.proxy[p] = "rgb(" + _parseColor(!pt.f ? target[p] : target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]()).join(",") + ")";
plugin._addTween(pt.proxy, p, "get", ((typeof(value) === "number") ? "rgb(" + _parseColor(value, false).join(",") + ")" : value), p, null, null, _colorStringFilter);
},
//to improve performance, when a color is sensed, we hijack the setRatio() method of the plugin instance with a new function that this method spits back. This is a special method that handles parsing color values on-the-fly and turns them into numeric values which PixiJS requires. In other words, instead of "rgb(255, 0, 0)", PixiJS wants 0xFF0000. This also works with hsl() values.
_buildColorSetter = function(tween, plugin) {
var setRatio = plugin.setRatio, //save the original (super) setRatio() function
func = function(v) {
var pt = func._firstPT,
val;
setRatio.call(plugin, v);
while (pt) {
val = _parseColor(pt.proxy[pt.p], "number");
if (pt.f) {
pt.t[pt.p](val);
} else {
pt.t[pt.p] = val;
}
pt = pt._next;
}
if (func.graphics) { //in order for PixiJS to actually redraw GraphicsData, we've gotta increment the "dirty" and "clearDirty" values. If we don't do this, the values will be tween properly, but not rendered.
func.graphics.dirty++;
func.graphics.clearDirty++;
}
};
plugin.setRatio = func;
return func;
},
_colorProps = {tint:1, lineColor:1, fillColor:1},
_xyContexts = "position,scale,skew,pivot,anchor,tilePosition,tileScale".split(","),
_contexts = {x:"position", y:"position", tileX:"tilePosition", tileY:"tilePosition"},
_colorMatrixFilterProps = {colorMatrixFilter:1, saturation:1, contrast:1, hue:1, colorize:1, colorizeAmount:1, brightness:1, combineCMF:1},
_DEG2RAD = Math.PI / 180,
_degreesToRadians = function(value) {
return (typeof(value) === "string" && value.charAt(1) === "=") ? value.substr(0, 2) + (parseFloat(value.substr(2)) * _DEG2RAD) : value * _DEG2RAD;
}, i, p;
//context setup...
for (i = 0; i < _xyContexts.length; i++) {
p = _xyContexts[i];
_contexts[p + "X"] = p;
_contexts[p + "Y"] = p;
}
//color parsing setup...
for (p in _colorLookup) {
_colorExp += "|" + p + "\\b";
}
_colorExp = new RegExp(_colorExp+")", "gi");
_colorStringFilter = function(a) {
var combined = a[0] + " " + a[1],
toHSL;
_colorExp.lastIndex = 0;
if (_colorExp.test(combined)) {
toHSL = (combined.indexOf("hsl(") !== -1 || combined.indexOf("hsla(") !== -1);
a[0] = _formatColors(a[0], toHSL);
a[1] = _formatColors(a[1], toHSL);
}
};
if (!TweenLite.defaultStringFilter) {
TweenLite.defaultStringFilter = _colorStringFilter;
}
var PixiPlugin = _gsScope._gsDefine.plugin({
propName: "pixi",
priority: 0,
API: 2,
global: true,
version: "0.2.1",
init: function (target, values, tween, index) {
if (!target instanceof _gsScope.PIXI.DisplayObject) {
return false;
}
var context, axis, value, colorMatrix, filter, p, padding, colorSetter, i, data, pt;
for (p in values) {
context = _contexts[p];
value = values[p];
if (typeof(value) === "function") {
value = value(index || 0, target);
}
if (context) {
axis = (p.charAt(p.length-1).toLowerCase().indexOf("x") !== -1) ? "x" : "y";
this._addTween(target[context], axis, target[context][axis], (context === "skew") ? _degreesToRadians(value) : value, p);
} else if (p === "scale" || p === "anchor" || p === "pivot" || p === "tileScale") {
this._addTween(target[p], "x", target[p].x, value, p + "X");
this._addTween(target[p], "y", target[p].y, value, p + "Y");
} else if (p === "rotation") { //PIXI expects rotation in radians, but as a convenience we let folks define it in degrees and we do the conversion.
this._addTween(target, p, target.rotation, _degreesToRadians(value), p);
} else if (_colorMatrixFilterProps[p]) {
if (!colorMatrix) {
_parseColorMatrixFilter(target, values.colorMatrixFilter || values, this);
colorMatrix = true;
}
} else if (p === "blur" || p === "blurX" || p === "blurY" || p === "blurPadding") {
filter = _getFilter(target, "BlurFilter");
this._addTween(filter, p, filter[p], value, p);
if (values.blurPadding !== 0) {
padding = values.blurPadding || Math.max(filter[p], value) * 2;
i = target.filters.length;
while (--i > -1) {
target.filters[i].padding = Math.max(target.filters[i].padding, padding); //if we don't expand the padding on all the filters, it can look clipped.
}
}
} else if (_colorProps[p]) {
if (!colorSetter) {
colorSetter = _buildColorSetter(tween, this);
}
if ((p === "lineColor" || p === "fillColor") && target instanceof _gsScope.PIXI.Graphics) {
data = target.graphicsData;
i = data.length;
while (--i > -1) {
_addColorTween(data[i], p, value, colorSetter, this);
}
colorSetter.graphics = target;
} else {
_addColorTween(target, p, value, colorSetter, this);
}
} else if (p === "autoAlpha") {
this._firstPT = pt = {t: {setRatio:function() { target.visible = !!target.alpha; }}, p: "setRatio", s: 0, c: 1, f: 1, pg: 0, n: "visible", pr: 0, m: 0, _next:this._firstPT};
if (pt._next) {
pt._next._prev = pt;
}
this._addTween(target, "alpha", target.alpha, value, "alpha");
this._overwriteProps.push("alpha", "visible");
} else {
this._addTween(target, p, target[p], value, p);
}
this._overwriteProps.push(p);
}
return true;
}
});
PixiPlugin.colorProps = _colorProps;
PixiPlugin.parseColor = _parseColor;
PixiPlugin.formatColors = _formatColors;
PixiPlugin.colorStringFilter = _colorStringFilter;
}); if (_gsScope._gsDefine) { _gsScope._gsQueue.pop()(); }
//export to AMD/RequireJS and CommonJS/Node (precursor to full modular build system coming at a later date)
(function(name) {
"use strict";
var getGlobal = function() {
return (_gsScope.GreenSockGlobals || _gsScope)[name];
};
if (typeof(module) !== "undefined" && module.exports) { //node
require("../TweenLite.js");
module.exports = getGlobal();
} else if (typeof(define) === "function" && define.amd) { //AMD
define(["TweenLite"], getGlobal);
}
}("PixiPlugin"));

View File

@ -0,0 +1,370 @@
/*!
* VERSION: 0.2.2
* DATE: 2018-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || window; //helps ensure compatibility with AMD/RequireJS and CommonJS/Node
(_gsScope._gsQueue || (_gsScope._gsQueue = [])).push( function() {
"use strict";
var _NaNExp = /[^\d\-\.]/g,
_DEG2RAD = Math.PI / 180,
_numExp = /(\d|\.)+/g,
_colorLookup = {aqua:[0,255,255],
lime:[0,255,0],
silver:[192,192,192],
black:[0,0,0],
maroon:[128,0,0],
teal:[0,128,128],
blue:[0,0,255],
navy:[0,0,128],
white:[255,255,255],
fuchsia:[255,0,255],
olive:[128,128,0],
yellow:[255,255,0],
orange:[255,165,0],
gray:[128,128,128],
purple:[128,0,128],
green:[0,128,0],
red:[255,0,0],
pink:[255,192,203],
cyan:[0,255,255],
transparent:[255,255,255,0]},
//parses a color (like #9F0, #FF9900, or rgb(255,51,153)) into an array with 3 elements for red, green, and blue. Also handles rgba() values (splits into array of 4 elements of course)
_parseColor = function(color) {
if (typeof(color) === "number") {
return [color >> 16, (color >> 8) & 255, color & 255];
} else if (color === "" || color == null || color === "none" || typeof(color) !== "string") {
return _colorLookup.transparent;
} else if (_colorLookup[color]) {
return _colorLookup[color];
} else if (color.charAt(0) === "#") {
if (color.length === 4) { //for shorthand like #9F0
color = "#" + color.charAt(1) + color.charAt(1) + color.charAt(2) + color.charAt(2) + color.charAt(3) + color.charAt(3);
}
color = parseInt(color.substr(1), 16);
return [color >> 16, (color >> 8) & 255, color & 255];
}
return color.match(_numExp) || _colorLookup.transparent;
},
_transformMap = {scaleX:1, scaleY:1, tx:1, ty:1, rotation:1, shortRotation:1, skewX:1, skewY:1, scale:1},
//parses the transform values for an element, returning an object with x, y, scaleX, scaleY, rotation, skewX, and skewY properties. Note: by default (for performance reasons), all skewing is combined into skewX and rotation but skewY still has a place in the transform object so that we can record how much of the skew is attributed to skewX vs skewY. Remember, a skewY of 10 looks the same as a rotation of 10 and skewX of -10.
_getTransform = function(t, rec) {
var s = t.matrix,
min = 0.000001,
a = s.a,
b = s.b,
c = s.c,
d = s.d,
m = rec ? t._gsTransform || {skewY:0} : {skewY:0},
invX = (m.scaleX < 0); //in order to interpret things properly, we need to know if the user applied a negative scaleX previously so that we can adjust the rotation and skewX accordingly. Otherwise, if we always interpret a flipped matrix as affecting scaleY and the user only wants to tween the scaleX on multiple sequential tweens, it would keep the negative scaleY without that being the user's intent.
m.tx = s.e - (m.ox || 0); //ox is the offset x that we record in setRatio() whenever we apply a custom transform that might use a pivot point. Remember, s.e and s.f get affected by things like scale. For example, imagine an object whose top left corner is at 100,100 and then we scale it up to 300% using the center as the pivot point - that corner would now be very different even though to the user, they didn't intend to change/tween the x/y position per se. Therefore, we record whatever offsets we make so that we can compensate when reading the values back.
m.ty = s.f - (m.oy || 0); //oy is the offset y (see note above)
m.scaleX = Math.sqrt(a * a + b * b);
m.scaleY = Math.sqrt(d * d + c * c);
m.rotation = (a || b) ? Math.atan2(b, a) : m.rotation || 0; //note: if scaleX is 0, we cannot accurately measure rotation. Same for skewX with a scaleY of 0. Therefore, we default to the previously recorded value (or zero if that doesn't exist).
m.skewX = (c || d) ? Math.atan2(c, d) + m.rotation : m.skewX || 0;
if (Math.abs(m.skewX) > Math.PI / 2) {
if (invX) {
m.scaleX *= -1;
m.skewX += (m.rotation <= 0) ? Math.PI : -Math.PI;
m.rotation += (m.rotation <= 0) ? Math.PI : -Math.PI;
} else {
m.scaleY *= -1;
m.skewX += (m.skewX <= 0) ? Math.PI : -Math.PI;
}
}
//some browsers have a hard time with very small values like 2.4492935982947064e-16 (notice the "e-" towards the end) and would render the object slightly off. So we round to 0 in these cases. The conditional logic here is faster than calling Math.abs().
if (m.rotation < min) if (m.rotation > -min) if (a || b) {
m.rotation = 0;
}
if (m.skewX < min) if (m.skewX > -min) if (b || c) {
m.skewX = 0;
}
if (rec) {
t._gsTransform = m; //record to the object's _gsTransform which we use so that tweens can control individual properties independently (we need all the properties to accurately recompose the matrix in the setRatio() method)
}
return m;
},
//takes a value and a default number, checks if the value is relative, null, or numeric and spits back a normalized number accordingly. Primarily used in the _parseTransform() function.
_parseVal = function(v, d) {
return (v == null) ? d : (typeof(v) === "string" && v.indexOf("=") === 1) ? parseInt(v.charAt(0)+"1", 10) * Number(v.substr(2)) + d : Number(v);
},
//translates strings like "40deg" or "40" or 40rad" or "+=40deg" to a numeric radian angle, optionally relative to a default value (if "+=" or "-=" prefix is found)
_parseAngle = function(v, d) {
var m = (v.indexOf("rad") === -1) ? _DEG2RAD : 1,
r = (v.indexOf("=") === 1);
v = Number(v.replace(_NaNExp, "")) * m;
return r ? v + d : v;
},
RaphaelPlugin = _gsScope._gsDefine.plugin({
propName: "raphael",
version: "0.2.2",
API: 2,
//called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
init: function(target, value, tween) {
if (!target.attr) { //raphael must have attr() method
return false;
}
this._target = target;
this._tween = tween;
this._props = target._gsProps = target._gsProps || {};
var p, s, v, pt, clr1, clr2, rel;
for (p in value) {
v = value[p];
if (p === "transform") {
this._parseTransform(target, v);
continue;
} else if (_transformMap[p] || p === "pivot") {
this._parseTransform(target, value);
continue;
}
s = target.attr(p);
//Some of these properties are in place in order to conform with the standard PropTweens in TweenPlugins so that overwriting and roundProps occur properly. For example, f and r may seem unnecessary here, but they enable other functionality.
//_next:* next linked list node [object]
//t: * target [object]
//p: * property (camelCase) [string]
//s: * starting value [number]
//c: * change value [number]
//f: * is function [boolean]
//n: * name (for overwriting) [string]
//b: beginning value [string]
//i: intermediate value [string]
//e: ending value [string]
//r: * round [boolean]
//type: 0=normal, 1=color, 2=rgba, -1=non-tweening prop [number]
this._firstPT = pt = {_next:this._firstPT,
t:this._props,
p:p,
b:s,
f:false,
n:"raphael_" + p,
r:false,
type:0};
//color values must be split apart into their R, G, B (and sometimes alpha) values and tweened independently.
if (p === "fill" || p === "stroke") {
clr1 = _parseColor(s);
clr2 = _parseColor(v);
pt.e = v;
pt.s = Number(clr1[0]); //red starting value
pt.c = Number(clr2[0]) - pt.s; //red change
pt.gs = Number(clr1[1]); //green starting value
pt.gc = Number(clr2[1]) - pt.gs; //green change
pt.bs = Number(clr1[2]); //blue starting value
pt.bc = Number(clr2[2]) - pt.bs; //blue change
if (clr1.length > 3 || clr2.length > 3) { //detect an rgba() value
pt.as = (clr1.length < 4) ? 1 : Number(clr1[3]);
pt.ac = ((clr2.length < 4) ? 1 : Number(clr2[3])) - pt.as;
pt.type = 2; //2 = rgba() tween
} else {
pt.type = 1; //1 = color tween, -1 = no tween, just set the value at the end because there's no changes
}
} else {
s = (typeof(s) === "string") ? parseFloat(s.replace(_NaNExp, "")) : Number(s);
if (typeof(v) === "string") {
rel = (v.charAt(1) === "=");
v = parseFloat(v.replace(_NaNExp, ""));
} else {
rel = false;
}
pt.e = (v || v === 0) ? (rel ? v + s : v) : value[p]; //ensures that any += or -= prefixes are taken care of.
if ((s || s === 0) && (v || v === 0) && (pt.c = (rel ? v : v - s))) { //faster than isNaN(). Also, we set pt.c (change) here because if it's 0, we'll just treat it like a non-tweening value. can't do (v !== start) because if it's a relative value and the CHANGE is identical to the START, the condition will fail unnecessarily.
pt.s = s;
} else {
pt.type = -1;
pt.i = value[p]; //intermediate value is typically the same as the end value.
pt.s = pt.c = 0;
}
}
this._overwriteProps.push("raphael_" + p);
if (pt._next) {
pt._next._prev = pt;
}
}
return true;
},
//called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.)
set: function(v) {
var pt = this._firstPT, val;
while (pt) {
val = pt.c * v + pt.s;
if (pt.r) {
val = Math.round(val);
}
if (!pt.type) {
pt.t[pt.p] = val;
} else if (pt.type === 1) { //rgb()
pt.t[pt.p] = "rgb(" + (val >> 0) + ", " + ((pt.gs + (v * pt.gc)) >> 0) + ", " + ((pt.bs + (v * pt.bc)) >> 0) + ")";
} else if (pt.type === 2) { //rgba()
pt.t[pt.p] = "rgba(" + (val >> 0) + ", " + ((pt.gs + (v * pt.gc)) >> 0) + ", " + ((pt.bs + (v * pt.bc)) >> 0) + ", " + (pt.as + (v * pt.ac)) + ")";
} else if (pt.type === -1) { //non-tweening
pt.t[pt.p] = pt.i;
}
pt = pt._next;
}
this._target.attr(this._props);
//apply transform values like x, y, scaleX, scaleY, rotation, skewX, or skewY. We do these after looping through all the PropTweens because those are where the changes are made to scaleX/scaleY/rotation/skewX/skewY/x/y.
if (this._transform) {
pt = this._transform; //to improve speed and reduce size, reuse the pt variable as an alias to the _transform property
var ang = pt.rotation,
skew = ang - pt.skewX,
a = Math.cos(ang) * pt.scaleX,
b = Math.sin(ang) * pt.scaleX,
c = Math.sin(skew) * -pt.scaleY,
d = Math.cos(skew) * pt.scaleY,
min = 0.000001,
pxl = this._pxl,
pyl = this._pyl;
//some browsers have a hard time with very small values like 2.4492935982947064e-16 (notice the "e-" towards the end) and would render the object slightly off. So we round to 0 in these cases for both b and c. The conditional logic here is faster than calling Math.abs().
if (b < min) if (b > -min) {
b = 0;
}
if (c < min) if (c > -min) {
c = 0;
}
pt.ox = this._pxg - (pxl * a + pyl * c); //we must record the offset x/y that we're making from the regular tx/ty (matrix.e and f) so that we can correctly interpret positional data in _getTransform(). See note there on tx and ox.
pt.oy = this._pyg - (pxl * b + pyl * d);
this._target.transform("m" + a + "," + b + "," + c + "," + d + "," + (pt.tx + pt.ox) + "," + (pt.ty + pt.oy));
}
}
}),
p = RaphaelPlugin.prototype;
//compares the beginning x, y, scaleX, scaleY, rotation, and skewX properties with the ending ones and adds PropTweens accordingly wherever necessary. We must tween them individually (rather than just tweening the matrix values) so that elgant overwriting can occur, like if one tween is controlling scaleX, scaleY, and rotation and then another one starts mid-tween that is trying to control the scaleX only - this tween should continue tweening scaleY and rotation.
p._parseTransform = function(t, v) {
if (this._transform) { return; } //only need to parse the transform once, and only if the browser supports it.
var m1 = this._transform = _getTransform(t, true),
min = 0.000001,
m2, skewY, p, pt, copy, dx, dy, mtx, pivot;
if (typeof(v) === "object") { //for values like scaleX, scaleY, rotation, x, y, skewX, and skewY or transform:{...} (object)
m2 = {scaleX:_parseVal((v.scaleX != null) ? v.scaleX : v.scale, m1.scaleX),
scaleY:_parseVal((v.scaleY != null) ? v.scaleY : v.scale, m1.scaleY),
tx:_parseVal(v.tx, m1.tx),
ty:_parseVal(v.ty, m1.ty)};
if (v.shortRotation != null) {
m2.rotation = (typeof(v.shortRotation) === "number") ? v.shortRotation * _DEG2RAD : _parseAngle(v.shortRotation, m1.rotation);
var dif = (m2.rotation - m1.rotation) % (Math.PI * 2);
if (dif !== dif % Math.PI) {
dif += Math.PI * ((dif < 0) ? 2 : -2);
}
m2.rotation = m1.rotation + dif;
} else {
m2.rotation = (v.rotation == null) ? m1.rotation : (typeof(v.rotation) === "number") ? v.rotation * _DEG2RAD : _parseAngle(v.rotation, m1.rotation);
}
m2.skewX = (v.skewX == null) ? m1.skewX : (typeof(v.skewX) === "number") ? v.skewX * _DEG2RAD : _parseAngle(v.skewX, m1.skewX);
//note: for performance reasons, we combine all skewing into the skewX and rotation values, ignoring skewY but we must still record it so that we can discern how much of the overall skew is attributed to skewX vs. skewY. Otherwise, if the skewY would always act relative (tween skewY to 10deg, for example, multiple times and if we always combine things into skewX, we can't remember that skewY was 10 from last time). Remember, a skewY of 10 degrees looks the same as a rotation of 10 degrees plus a skewX of -10 degrees.
m2.skewY = (v.skewY == null) ? m1.skewY : (typeof(v.skewY) === "number") ? v.skewY * _DEG2RAD : _parseAngle(v.skewY, m1.skewY);
if ((skewY = m2.skewY - m1.skewY)) {
m2.skewX += skewY;
m2.rotation += skewY;
}
//don't allow rotation/skew values to be a SUPER small decimal because when they're translated back to strings for setting the css property, the browser reports them in a funky way, like 1-e7. Of course we could use toFixed() to resolve that issue but that hurts performance quite a bit with all those function calls on every frame, plus it is virtually impossible to discern values that small visually (nobody will notice changing a rotation of 0.0000001 to 0, so the performance improvement is well worth it).
if (m2.skewY < min) if (m2.skewY > -min) {
m2.skewY = 0;
}
if (m2.skewX < min) if (m2.skewX > -min) {
m2.skewX = 0;
}
if (m2.rotation < min) if (m2.rotation > -min) {
m2.rotation = 0;
}
pivot = v.localPivot || v.globalPivot;
if (typeof(pivot) === "string") {
copy = pivot.split(",");
dx = Number(copy[0]);
dy = Number(copy[1]);
} else if (typeof(pivot) === "object") {
dx = Number(pivot.x);
dy = Number(pivot.y);
} else if (v.localPivot) {
copy = t.getBBox(true);
dx = copy.width / 2;
dy = copy.height / 2;
} else {
copy = t.getBBox();
dx = copy.x + copy.width / 2;
dy = copy.y + copy.height / 2;
}
if (v.localPivot) {
mtx = t.matrix;
dx += t.attr("x");
dy += t.attr("y");
this._pxl = dx;
this._pyl = dy;
this._pxg = dx * mtx.a + dy * mtx.c + mtx.e - m1.tx;
this._pyg = dx * mtx.b + dy * mtx.d + mtx.f - m1.ty;
} else {
mtx = t.matrix.invert();
this._pxl = dx * mtx.a + dy * mtx.c + mtx.e;
this._pyl = dx * mtx.b + dy * mtx.d + mtx.f;
this._pxg = dx - m1.tx;
this._pyg = dy - m1.ty;
}
} else if (typeof(v) === "string") { //for values like transform:"rotate(60deg) scale(0.5, 0.8)"
copy = this._target.transform();
t.transform(v);
m2 = _getTransform(t, false);
t.transform(copy);
} else {
return;
}
for (p in _transformMap) {
if (m1[p] !== m2[p]) if (p !== "shortRotation") if (p !== "scale") {
this._firstPT = pt = {_next:this._firstPT, t:m1, p:p, s:m1[p], c:m2[p] - m1[p], n:p, f:false, r:false, b:m1[p], e:m2[p], type:0};
if (pt._next) {
pt._next._prev = pt;
}
this._overwriteProps.push("raphael_" + p);
}
}
};
}); if (_gsScope._gsDefine) { _gsScope._gsQueue.pop()(); }

View File

@ -0,0 +1,102 @@
/*!
* VERSION: 1.7.0
* DATE: 2018-05-21
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
/* eslint-disable */
var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || window; //helps ensure compatibility with AMD/RequireJS and CommonJS/Node
(_gsScope._gsQueue || (_gsScope._gsQueue = [])).push( function() {
"use strict";
var RoundPropsPlugin = _gsScope._gsDefine.plugin({
propName: "roundProps",
version: "1.7.0",
priority: -1,
API: 2,
//called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
init: function(target, value, tween) {
this._tween = tween;
return true;
}
}),
_getRoundFunc = function(v) { //pass in 0.1 get a function that'll round to the nearest tenth, or 5 to round to the closest 5, or 0.001 to the closest 1000th, etc.
var p = v < 1 ? Math.pow(10, (v + "").length - 2) : 1; //to avoid floating point math errors (like 24 * 0.1 == 2.4000000000000004), we chop off at a specific number of decimal places (much faster than toFixed()
return function(n) {
return ((Math.round(n / v) * v * p) | 0) / p;
};
},
_roundLinkedList = function(node, mod) {
while (node) {
if (!node.f && !node.blob) {
node.m = mod || Math.round;
}
node = node._next;
}
},
p = RoundPropsPlugin.prototype;
p._onInitAllProps = function() {
var tween = this._tween,
rp = tween.vars.roundProps,
lookup = {},
rpt = tween._propLookup.roundProps,
pt, next, i, p;
if (typeof(rp) === "object" && !rp.push) {
for (p in rp) {
lookup[p] = _getRoundFunc(rp[p]);
}
} else {
if (typeof(rp) === "string") {
rp = rp.split(",");
}
i = rp.length;
while (--i > -1) {
lookup[rp[i]] = Math.round;
}
}
for (p in lookup) {
pt = tween._firstPT;
while (pt) {
next = pt._next; //record here, because it may get removed
if (pt.pg) {
pt.t._mod(lookup);
} else if (pt.n === p) {
if (pt.f === 2 && pt.t) { //a blob (text containing multiple numeric values)
_roundLinkedList(pt.t._firstPT, lookup[p]);
} else {
this._add(pt.t, p, pt.s, pt.c, lookup[p]);
//remove from linked list
if (next) {
next._prev = pt._prev;
}
if (pt._prev) {
pt._prev._next = next;
} else if (tween._firstPT === pt) {
tween._firstPT = next;
}
pt._next = pt._prev = null;
tween._propLookup[p] = rpt;
}
}
pt = next;
}
}
return false;
};
p._add = function(target, p, s, c, mod) {
this._addTween(target, p, s, s + c, p, mod || Math.round);
this._overwriteProps.push(p);
};
}); if (_gsScope._gsDefine) { _gsScope._gsQueue.pop()(); }

View File

@ -0,0 +1,231 @@
/*!
* VERSION: 0.5.2
* DATE: 2019-02-07
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* ScrambleTextPlugin is a Club GreenSock membership benefit; You must have a valid membership to use
* this code without violating the terms of use. Visit http://greensock.com/club/ to sign up or get more details.
* This work is subject to the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || window; //helps ensure compatibility with AMD/RequireJS and CommonJS/Node
(_gsScope._gsQueue || (_gsScope._gsQueue = [])).push( function() {
"use strict";
var _trimExp = /(^\s+|\s+$)/g,
_spacesExp = /\s+/g,
_getText = function(e) {
var type = e.nodeType,
result = "";
if (type === 1 || type === 9 || type === 11) {
if (typeof(e.textContent) === "string") {
return e.textContent;
} else {
for (e = e.firstChild; e; e = e.nextSibling ) {
result += _getText(e);
}
}
} else if (type === 3 || type === 4) {
return e.nodeValue;
}
return result;
},
_scrambleText = function(length, chars) {
var l = chars.length,
s = "";
while (--length > -1) {
s += chars[ ((Math.random() * l) | 0) ];
}
return s;
},
CharSet = function(chars) {
this.chars = _emojiSafeSplit(chars);
this.sets = [];
this.length = 50;
var i;
for (i = 0; i < 20; i++) {
this.sets[i] = _scrambleText(80, this.chars); //we create 20 strings that are 80 characters long, randomly chosen and pack them into an array. We then randomly choose the scrambled text from this array in order to greatly improve efficiency compared to creating new randomized text from scratch each and every time it's needed. This is a simple lookup whereas the other technique requires looping through as many times as there are characters needed, and calling Math.random() each time through the loop, building the string, etc.
}
this.grow = function(newLength) { //if we encounter a tween that has more than 80 characters, we'll need to add to the character sets accordingly. Once it's cached, it'll only need to grow again if we exceed that new length. Again, this is an efficiency tactic.
for (i = 0; i < 20; i++) {
this.sets[i] += _scrambleText(newLength - this.length, this.chars);
}
this.length = newLength;
};
},
_emoji = "[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2694-\u2697]|\uD83E[\uDD10-\uDD5D]|[\uD800-\uDBFF][\uDC00-\uDFFF]",
_emojiExp = new RegExp(_emoji),
_emojiAndCharsExp = new RegExp(_emoji + "|.", "g"),
_emojiSafeSplit = function(text, delimiter, trim) {
if (trim) {
text = text.replace(_trimExp, "");
}
return ((delimiter === "" || !delimiter) && _emojiExp.test(text)) ? text.match(_emojiAndCharsExp) : text.split(delimiter || "");
},
_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
_lower = _upper.toLowerCase(),
_charsLookup = {
upperCase: new CharSet(_upper),
lowerCase: new CharSet(_lower),
upperAndLowerCase: new CharSet(_upper + _lower)
},
ScrambleTextPlugin = _gsScope._gsDefine.plugin({
propName: "scrambleText",
version: "0.5.2",
API: 2,
overwriteProps:["scrambleText","text"],
//called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
init: function(target, value, tween, index) {
this._prop = ("innerHTML" in target) ? "innerHTML" : ("textContent" in target) ? "textContent" : 0; // SVG text in IE doesn't have innerHTML, but it does have textContent.
if (!this._prop) {
return false;
}
if (typeof(value) === "function") {
value = value(index, target);
}
this._target = target;
if (typeof(value) !== "object") {
value = {text:value};
}
var text = value.text || value.value,
trim = (value.trim !== false),
delim, maxLength, charset, splitByChars;
this._delimiter = delim = value.delimiter || "";
this._original = _emojiSafeSplit(_getText(target).replace(_spacesExp, " ").split("&nbsp;").join(""), delim, trim);
if (text === "{original}" || text === true || text == null) {
text = this._original.join(delim);
}
this._text = _emojiSafeSplit((text || "").replace(_spacesExp, " "), delim, trim);
this._hasClass = false;
if (typeof(value.newClass) === "string") {
this._newClass = value.newClass;
this._hasClass = true;
}
if (typeof(value.oldClass) === "string") {
this._oldClass = value.oldClass;
this._hasClass = true;
}
splitByChars = (delim === "");
this._textHasEmoji = (_emojiExp.test(this._text.join(delim)) && splitByChars);
this._charsHaveEmoji = !!value.chars && _emojiExp.test(value.chars);
this._length = splitByChars ? this._original.length : this._original.join(delim).length;
this._lengthDif = (splitByChars ? this._text.length : this._text.join(delim).length) - this._length;
this._fillChar = value.fillChar || (value.chars && value.chars.indexOf(" ") !== -1) ? "&nbsp;" : "";
this._charSet = charset = _charsLookup[(value.chars || "upperCase")] || new CharSet(value.chars);
this._speed = 0.016 / (value.speed || 1);
this._prevScrambleTime = 0;
this._setIndex = (Math.random() * 20) | 0;
maxLength = this._length + Math.max(this._lengthDif, 0);
if (maxLength > charset.length) {
charset.grow(maxLength);
}
this._chars = charset.sets[this._setIndex];
this._revealDelay = value.revealDelay || 0;
this._tweenLength = (value.tweenLength !== false);
this._tween = tween;
this._rightToLeft = !!value.rightToLeft;
return true;
},
//called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.)
set: function(ratio) {
var l = this._text.length,
delim = this._delimiter,
time = this._tween._time,
timeDif = time - this._prevScrambleTime,
i, i2, startText, endText, applyNew, applyOld, str, startClass, endClass;
if (this._revealDelay) {
if (this._tween.vars.runBackwards) {
time = this._tween._duration - time; //invert the time for from() tweens
}
ratio = (time === 0) ? 0 : (time < this._revealDelay) ? 0.000001 : (time === this._tween._duration) ? 1 : this._tween._ease.getRatio((time - this._revealDelay) / (this._tween._duration - this._revealDelay));
}
if (ratio < 0) {
ratio = 0;
} else if (ratio > 1) {
ratio = 1;
}
if (this._rightToLeft) {
ratio = 1 - ratio;
}
i = (ratio * l + 0.5) | 0;
if (ratio) {
if (timeDif > this._speed || timeDif < -this._speed) {
this._setIndex = (this._setIndex + ((Math.random() * 19) | 0)) % 20;
this._chars = this._charSet.sets[this._setIndex];
this._prevScrambleTime += timeDif;
}
endText = this._chars;
} else {
endText = this._original.join(delim);
}
if (this._rightToLeft) {
if (ratio === 1 && (this._tween.vars.runBackwards || this._tween.data === "isFromStart")) { //special case for from() tweens
startText = "";
endText = this._original.join(delim);
} else {
str = this._text.slice(i).join(delim);
if (this._charsHaveEmoji) {
startText = _emojiSafeSplit(endText).slice(0, ((this._length + (this._tweenLength ? 1 - (ratio * ratio * ratio) : 1) * this._lengthDif) - ((this._textHasEmoji ? _emojiSafeSplit(str) : str).length) + 0.5) | 0).join("");
} else {
startText = endText.substr(0, ((this._length + (this._tweenLength ? 1 - (ratio * ratio * ratio) : 1) * this._lengthDif) - ((this._textHasEmoji ? _emojiSafeSplit(str) : str).length) + 0.5) | 0);
}
endText = str;
}
} else {
startText = this._text.slice(0, i).join(delim);
i2 = (this._textHasEmoji ? _emojiSafeSplit(startText) : startText).length;
if (this._charsHaveEmoji) {
endText = _emojiSafeSplit(endText).slice(i2, ((this._length + (this._tweenLength ? 1 - ((ratio = 1 - ratio) * ratio * ratio * ratio) : 1) * this._lengthDif) + 0.5) | 0).join("");
} else {
endText = endText.substr(i2, ((this._length + (this._tweenLength ? 1 - ((ratio = 1 - ratio) * ratio * ratio * ratio) : 1) * this._lengthDif) - i2 + 0.5) | 0);
}
}
if (this._hasClass) {
startClass = this._rightToLeft ? this._oldClass : this._newClass;
endClass = this._rightToLeft ? this._newClass : this._oldClass;
applyNew = (startClass && i !== 0);
applyOld = (endClass && i !== l);
str = (applyNew ? "<span class='" + startClass + "'>" : "") + startText + (applyNew ? "</span>" : "") + (applyOld ? "<span class='" + endClass + "'>" : "") + delim + endText + (applyOld ? "</span>" : "");
} else {
str = startText + delim + endText;
}
this._target[this._prop] = (this._fillChar === "&nbsp;" && str.indexOf(" ") !== -1) ? str.split(" ").join("&nbsp;&nbsp;") : str;
}
}),
p = ScrambleTextPlugin.prototype;
p._newClass = p._oldClass = "";
for (p in _charsLookup) {
_charsLookup[p.toLowerCase()] = _charsLookup[p];
_charsLookup[p.toUpperCase()] = _charsLookup[p];
}
}); if (_gsScope._gsDefine) { _gsScope._gsQueue.pop()(); }
//export to AMD/RequireJS and CommonJS/Node (precursor to full modular build system coming at a later date)
(function(name) {
"use strict";
var getGlobal = function() {
return (_gsScope.GreenSockGlobals || _gsScope)[name];
};
if (typeof(module) !== "undefined" && module.exports) { //node
require("../TweenLite.js");
module.exports = getGlobal();
} else if (typeof(define) === "function" && define.amd) { //AMD
define(["TweenLite"], getGlobal);
}
}("ScrambleTextPlugin"));

View File

@ -0,0 +1,196 @@
/*!
* VERSION: 1.9.2
* DATE: 2019-02-07
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
/* eslint-disable */
var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || window; //helps ensure compatibility with AMD/RequireJS and CommonJS/Node
(_gsScope._gsQueue || (_gsScope._gsQueue = [])).push( function() {
"use strict";
var _doc = (_gsScope.document || {}).documentElement,
_window = _gsScope,
_max = function(element, axis) {
var dim = (axis === "x") ? "Width" : "Height",
scroll = "scroll" + dim,
client = "client" + dim,
body = document.body;
return (element === _window || element === _doc || element === body) ? Math.max(_doc[scroll], body[scroll]) - (_window["inner" + dim] || _doc[client] || body[client]) : element[scroll] - element["offset" + dim];
},
_unwrapElement = function(value) {
if (typeof(value) === "string") {
value = TweenLite.selector(value);
}
if (value.length && value !== _window && value[0] && value[0].style && !value.nodeType) {
value = value[0];
}
return (value === _window || (value.nodeType && value.style)) ? value : null;
},
_buildGetter = function(e, axis) { //pass in an element and an axis ("x" or "y") and it'll return a getter function for the scroll position of that element (like scrollTop or scrollLeft, although if the element is the window, it'll use the pageXOffset/pageYOffset or the documentElement's scrollTop/scrollLeft or document.body's. Basically this streamlines things and makes a very fast getter across browsers.
var p = "scroll" + ((axis === "x") ? "Left" : "Top");
if (e === _window) {
if (e.pageXOffset != null) {
p = "page" + axis.toUpperCase() + "Offset";
} else if (_doc[p] != null) {
e = _doc;
} else {
e = document.body;
}
}
return function() {
return e[p];
};
},
_getOffset = function(element, container) {
var rect = _unwrapElement(element).getBoundingClientRect(),
b = document.body,
isRoot = (!container || container === _window || container === b),
cRect = isRoot ? {top:_doc.clientTop - (window.pageYOffset || _doc.scrollTop || b.scrollTop || 0), left:_doc.clientLeft - (window.pageXOffset || _doc.scrollLeft || b.scrollLeft || 0)} : container.getBoundingClientRect(),
offsets = {x: rect.left - cRect.left, y: rect.top - cRect.top};
if (!isRoot && container) { //only add the current scroll position if it's not the window/body.
offsets.x += _buildGetter(container, "x")();
offsets.y += _buildGetter(container, "y")();
}
return offsets;
/* PREVIOUS
var rect = _unwrapElement(element).getBoundingClientRect(),
isRoot = (!container || container === _window || container === document.body),
cRect = (isRoot ? _doc : container).getBoundingClientRect(),
offsets = {x: rect.left - cRect.left, y: rect.top - cRect.top};
if (!isRoot && container) { //only add the current scroll position if it's not the window/body.
offsets.x += _buildGetter(container, "x")();
offsets.y += _buildGetter(container, "y")();
}
return offsets;
*/
},
_parseVal = function(value, target, axis, currentVal) {
var type = typeof(value);
return !isNaN(value) ? parseFloat(value) : (type === "string" && value.charAt(1) === "=") ? parseInt(value.charAt(0) + "1", 10) * parseFloat(value.substr(2)) + currentVal : (value === "max") ? _max(target, axis) : Math.min(_max(target, axis), _getOffset(value, target)[axis]);
},
ScrollToPlugin = _gsScope._gsDefine.plugin({
propName: "scrollTo",
API: 2,
global: true,
version:"1.9.2",
//called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
init: function(target, value, tween) {
this._wdw = (target === _window);
this._target = target;
this._tween = tween;
if (typeof(value) !== "object") {
value = {y:value}; //if we don't receive an object as the parameter, assume the user intends "y".
if (typeof(value.y) === "string" && value.y !== "max" && value.y.charAt(1) !== "=") {
value.x = value.y;
}
} else if (value.nodeType) {
value = {y:value, x:value};
}
this.vars = value;
this._autoKill = (value.autoKill !== false);
this.getX = _buildGetter(target, "x");
this.getY = _buildGetter(target, "y");
this.x = this.xPrev = this.getX();
this.y = this.yPrev = this.getY();
if (value.x != null) {
this._addTween(this, "x", this.x, _parseVal(value.x, target, "x", this.x) - (value.offsetX || 0), "scrollTo_x", true);
this._overwriteProps.push("scrollTo_x");
} else {
this.skipX = true;
}
if (value.y != null) {
this._addTween(this, "y", this.y, _parseVal(value.y, target, "y", this.y) - (value.offsetY || 0), "scrollTo_y", true);
this._overwriteProps.push("scrollTo_y");
} else {
this.skipY = true;
}
return true;
},
//called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.)
set: function(v) {
this._super.setRatio.call(this, v);
var x = (this._wdw || !this.skipX) ? this.getX() : this.xPrev,
y = (this._wdw || !this.skipY) ? this.getY() : this.yPrev,
yDif = y - this.yPrev,
xDif = x - this.xPrev,
threshold = ScrollToPlugin.autoKillThreshold;
if (this.x < 0) { //can't scroll to a position less than 0! Might happen if someone uses a Back.easeOut or Elastic.easeOut when scrolling back to the top of the page (for example)
this.x = 0;
}
if (this.y < 0) {
this.y = 0;
}
if (this._autoKill) {
//note: iOS has a bug that throws off the scroll by several pixels, so we need to check if it's within 7 pixels of the previous one that we set instead of just looking for an exact match.
if (!this.skipX && (xDif > threshold || xDif < -threshold) && x < _max(this._target, "x")) {
this.skipX = true; //if the user scrolls separately, we should stop tweening!
}
if (!this.skipY && (yDif > threshold || yDif < -threshold) && y < _max(this._target, "y")) {
this.skipY = true; //if the user scrolls separately, we should stop tweening!
}
if (this.skipX && this.skipY) {
this._tween.kill();
if (this.vars.onAutoKill) {
this.vars.onAutoKill.apply(this.vars.onAutoKillScope || this._tween, this.vars.onAutoKillParams || []);
}
}
}
if (this._wdw) {
_window.scrollTo((!this.skipX) ? this.x : x, (!this.skipY) ? this.y : y);
} else {
if (!this.skipY) {
this._target.scrollTop = this.y;
}
if (!this.skipX) {
this._target.scrollLeft = this.x;
}
}
this.xPrev = this.x;
this.yPrev = this.y;
}
}),
p = ScrollToPlugin.prototype;
ScrollToPlugin.max = _max;
ScrollToPlugin.getOffset = _getOffset;
ScrollToPlugin.buildGetter = _buildGetter;
ScrollToPlugin.autoKillThreshold = 7;
p._kill = function(lookup) {
if (lookup.scrollTo_x) {
this.skipX = true;
}
if (lookup.scrollTo_y) {
this.skipY = true;
}
return this._super._kill.call(this, lookup);
};
}); if (_gsScope._gsDefine) { _gsScope._gsQueue.pop()(); }
//export to AMD/RequireJS and CommonJS/Node (precursor to full modular build system coming at a later date)
(function(name) {
"use strict";
var getGlobal = function() {
return (_gsScope.GreenSockGlobals || _gsScope)[name];
};
if (typeof(module) !== "undefined" && module.exports) { //node
require("../TweenLite.js");
module.exports = getGlobal();
} else if (typeof(define) === "function" && define.amd) { //AMD
define(["TweenLite"], getGlobal);
}
}("ScrollToPlugin"));

View File

@ -0,0 +1,77 @@
/*!
* VERSION: 1.2.0
* DATE: 2018-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* This file is to be used as a simple template for writing your own plugin. See the
* TweenPlugin docs for more details.
*
* You can start by doing a search for "yourCustomProperty" and replace it with whatever the name
* of your property is. This way of defining a plugin was introduced in version 1.9.0 - previous versions
* of TweenLite won't work with this.
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
/* eslint-disable */
var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || window; //helps ensure compatibility with AMD/RequireJS and CommonJS/Node
(_gsScope._gsQueue || (_gsScope._gsQueue = [])).push( function() {
//ignore the line above this and at the very end - those are for ensuring things load in the proper order
"use strict";
_gsScope._gsDefine.plugin({
propName: "yourCustomProperty", //the name of the property that will get intercepted and handled by this plugin (obviously change it to whatever you want, typically it is camelCase starting with lowercase).
priority: 0, //the priority in the rendering pipeline (0 by default). A priority of -1 would mean this plugin will run after all those with 0 or greater. A priority of 1 would get run before 0, etc. This only matters when a plugin relies on other plugins finishing their work before it runs (or visa-versa)
API: 2, //the API should stay 2 - it just gives us a way to know the method/property structure so that if in the future we change to a different TweenPlugin architecture, we can identify this plugin's structure.
version: "1.0.0", //your plugin's version number
overwriteProps: ["yourCustomProperty"], //an array of property names whose tweens should be overwritten by this plugin. For example, if you create a "scale" plugin that handles both "scaleX" and "scaleY", the overwriteProps would be ["scaleX","scaleY"] so that if there's a scaleX or scaleY tween in-progress when a new "scale" tween starts (using this plugin), it would overwrite the scaleX or scaleY tween.
/*
* The init function is called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run. It receives 3 parameters:
* 1) target [object] - the target of the tween. In cases where the tween's original target is an array (or jQuery object), this target will be the individual object inside that array (a new plugin instance is created for each target in the array). For example, TweenLite.to([obj1, obj2, obj3], 1, {x:100}) the target will be obj1 or obj2 or obj3 rather than the array containing them.
* 2) value [*] - whatever value is passed as the special property value. For example, TweenLite.to(element, 1, {yourCustomProperty:3}) the value would be 3. Or for TweenLite.to(element, 1, {yourCustomProperty:{subProp1:3, subProp2:"whatever"}});, value would be {subProp1:3, subProp2:"whatever"}.
* 3) tween [TweenLite] - the TweenLite (or TweenMax) instance that is managing this plugin instance. This can be useful if you need to check certain state-related properties on the tween (maybe in the set method) like its duration or time. Most of the time, however, you don't need to do anything with the tween. It is provided just in case you want to reference it.
* 4) index [integer] - the index number of the target in the tween. For example, if an array is passed in as the target (or selector text), this would be 0 for the first one, 1 for the second, 2 for the third, etc. This was introduced in GSAP 1.19.0
*
* This function should return true unless you want to have TweenLite/Max skip the plugin altogether and instead treat the property/value like a normal tween (as if the plugin wasn't activated). This is rarely useful, so you should almost always return true.
*/
init: function(target, value, tween, index) {
this._target = target; //we record the target so that we can refer to it in the set method when doing updates.
/* Next, we create a property tween for "scaleX" and "scaleY" properties of our target
* (we're just using them as a examples of how to set up a property tween with a name, start, and end value).
* the _addTween() method accepts the following parameters:
* 1) target [object] - target object whose property this tween will control.
* 2) property [string] - the name of the property, like "scaleX" or "scaleY"
* 3) start [number] - The starting value of the property. For example, if you're tweening from 0 to 100, start would be 0.
* 4) end [number] - the ending value of the property. For example, if you're tweening from 0 to 100, end would be 100.
* 5) overwriteProperty [string] - the name that gets registered as the overwrite property so that if another concurrent tween of the same target gets created and it is tweening a property with this name, this one will be overwritten. Typically this is the same as "property".
* 6) round [boolean] - if true, the updated value on each update will be rounded to the nearest integer. [false by default]
* You do NOT need to use _addTween() at all. It is merely a convenience. You can record your own values internally or whatever you want.
*/
this._addTween(target, "scaleX", target.scaleX, value, "scaleX", false);
this._addTween(target, "scaleY", target.scaleY, value, "scaleY", false);
//now, just for kicks, we'll record the starting "alpha" value and amount of change so that we can manage this manually rather than _addTween() (again, totally fictitious, just for an example)
this._alphaStart = target.alpha;
this._alphaChange = value.alpha - target.alpha;
//always return true unless we want to scrap the plugin and have the value treated as a normal property tween (very uncommon)
return true;
},
//[optional] - called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.). If you're using this._super._addTween() for all your tweens and you don't need to do anything special on each frame besides updating those values, you can omit this "set" function altogether.
set: function(ratio) {
//since we used _addTween() inside init function, it created some property tweens that we'll update by calling the parent prototype's setRatio() (otherwise, the property tweens wouldn't get their values updated). this._super refers to the TweenPlugin prototype from which the plugin inherits (not that you need to worry about that).
this._super.setRatio.call(this, ratio);
//now manually set the alpha
this._target.alpha = this._alphaStart + this._alphaChange * ratio;
}
});
}); if (_gsScope._gsDefine) { _gsScope._gsQueue.pop()(); }

View File

@ -0,0 +1,172 @@
/*!
* VERSION: 0.6.2
* DATE: 2018-02-15
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || window; //helps ensure compatibility with AMD/RequireJS and CommonJS/Node
(_gsScope._gsQueue || (_gsScope._gsQueue = [])).push( function() {
"use strict";
var _getText = function(e) {
var type = e.nodeType,
result = "";
if (type === 1 || type === 9 || type === 11) {
if (typeof(e.textContent) === "string") {
return e.textContent;
} else {
for ( e = e.firstChild; e; e = e.nextSibling ) {
result += _getText(e);
}
}
} else if (type === 3 || type === 4) {
return e.nodeValue;
}
return result;
},
_emoji = "[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2694-\u2697]|\uD83E[\uDD10-\uDD5D]|[\uD800-\uDBFF][\uDC00-\uDFFF]",
_emojiExp = new RegExp(_emoji),
_emojiAndCharsExp = new RegExp(_emoji + "|.", "g"),
_emojiSafeSplit = function(text, delimiter) {
return ((delimiter === "" || !delimiter) && _emojiExp.test(text)) ? text.match(_emojiAndCharsExp) : text.split(delimiter || "");
},
/* //previous emoji-related splitting. New method above is faster and more concise.
_emojiStart = 0xD800,
_emojiEnd = 0xDBFF,
_emojiLowStart = 0xDC00,
_emojiRegionStart = 0x1F1E6,
_emojiRegionEnd = 0x1F1FF,
_emojiModStart = 0x1f3fb,
_emojiModEnd = 0x1f3ff,
_emojiPairCode = function(s) {
return ((s.charCodeAt(0) - _emojiStart) << 10) + (s.charCodeAt(1) - _emojiLowStart) + 0x10000;
},
_emojiSafeSplit = function(text, delimiter) { //like calling String.split(delimiter) except that it keeps emoji characters together.
if (delimiter !== "") {
return text.split(delimiter);
}
var l = text.length,
a = [],
character, i, emojiPair1, emojiPair2, j;
for (i = 0; i < l; i++) {
character = text.charAt(i);
if ((character.charCodeAt(0) >= _emojiStart && character.charCodeAt(0) <= _emojiEnd) || (text.charCodeAt(i+1) >= 0xFE00 && text.charCodeAt(i+1) <= 0xFE0F)) { //special emoji characters use 2 or 4 unicode characters that we must keep together.
emojiPair1 = _emojiPairCode(text.substr(i, 2));
emojiPair2 = _emojiPairCode(text.substr(i + 2, 2));
j = ((emojiPair1 >= _emojiRegionStart && emojiPair1 <= _emojiRegionEnd && emojiPair2 >= _emojiRegionStart && emojiPair2 <= _emojiRegionEnd) || (emojiPair2 >= _emojiModStart && emojiPair2 <= _emojiModEnd)) ? 4 : 2;
a.push(text.substr(i, j));
i += j - 1;
} else {
a.push(character);
}
}
return a;
},
*/
TextPlugin = _gsScope._gsDefine.plugin({
propName: "text",
API: 2,
version:"0.6.2",
//called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
init: function(target, value, tween, index) {
var i = target.nodeName.toUpperCase(),
shrt;
if (typeof(value) === "function") {
value = value(index, target);
}
this._svg = (target.getBBox && (i === "TEXT" || i === "TSPAN"));
if (!("innerHTML" in target) && !this._svg) {
return false;
}
this._target = target;
if (typeof(value) !== "object") {
value = {value:value};
}
if (value.value === undefined) {
this._text = this._original = [""];
return true;
}
this._delimiter = value.delimiter || "";
this._original = _emojiSafeSplit(_getText(target).replace(/\s+/g, " "), this._delimiter);
this._text = _emojiSafeSplit(value.value.replace(/\s+/g, " "), this._delimiter);
this._runBackwards = (tween.vars.runBackwards === true);
if (this._runBackwards) {
i = this._original;
this._original = this._text;
this._text = i;
}
if (typeof(value.newClass) === "string") {
this._newClass = value.newClass;
this._hasClass = true;
}
if (typeof(value.oldClass) === "string") {
this._oldClass = value.oldClass;
this._hasClass = true;
}
i = this._original.length - this._text.length;
shrt = (i < 0) ? this._original : this._text;
this._fillChar = value.fillChar || (value.padSpace ? "&nbsp;" : "");
if (i < 0) {
i = -i;
}
while (--i > -1) {
shrt.push(this._fillChar);
}
return true;
},
//called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.)
set: function(ratio) {
if (ratio > 1) {
ratio = 1;
} else if (ratio < 0) {
ratio = 0;
}
if (this._runBackwards) {
ratio = 1 - ratio;
}
var l = this._text.length,
i = (ratio * l + 0.5) | 0,
applyNew, applyOld, str;
if (this._hasClass) {
applyNew = (this._newClass && i !== 0);
applyOld = (this._oldClass && i !== l);
str = (applyNew ? "<span class='" + this._newClass + "'>" : "") + this._text.slice(0, i).join(this._delimiter) + (applyNew ? "</span>" : "") + (applyOld ? "<span class='" + this._oldClass + "'>" : "") + this._delimiter + this._original.slice(i).join(this._delimiter) + (applyOld ? "</span>" : "");
} else {
str = this._text.slice(0, i).join(this._delimiter) + this._delimiter + this._original.slice(i).join(this._delimiter);
}
if (this._svg) { //SVG text elements don't have an "innerHTML" in Microsoft browsers.
this._target.textContent = str;
} else {
this._target.innerHTML = (this._fillChar === "&nbsp;" && str.indexOf(" ") !== -1) ? str.split(" ").join("&nbsp;&nbsp;") : str;
}
}
}),
p = TextPlugin.prototype;
p._newClass = p._oldClass = p._delimiter = "";
}); if (_gsScope._gsDefine) { _gsScope._gsQueue.pop()(); }
//export to AMD/RequireJS and CommonJS/Node (precursor to full modular build system coming at a later date)
(function(name) {
"use strict";
var getGlobal = function() {
return (_gsScope.GreenSockGlobals || _gsScope)[name];
};
if (typeof(module) !== "undefined" && module.exports) { //node
require("../TweenLite.js");
module.exports = getGlobal();
} else if (typeof(define) === "function" && define.amd) { //AMD
define(["TweenLite"], getGlobal);
}
}("TextPlugin"));

View File

@ -0,0 +1,740 @@
/*!
* VERSION: 0.11.2
* DATE: 2019-02-07
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* ThrowPropsPlugin is a Club GreenSock membership benefit; You must have a valid membership to use
* this code without violating the terms of use. Visit http://greensock.com/club/ to sign up or get more details.
* This work is subject to the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || window; //helps ensure compatibility with AMD/RequireJS and CommonJS/Node
(_gsScope._gsQueue || (_gsScope._gsQueue = [])).push( function() {
"use strict";
_gsScope._gsDefine("plugins.ThrowPropsPlugin", ["plugins.TweenPlugin", "TweenLite", "easing.Ease", "utils.VelocityTracker"], function(TweenPlugin, TweenLite, Ease, VelocityTracker) {
var ThrowPropsPlugin = function(props, priority) {
TweenPlugin.call(this, "throwProps");
this._overwriteProps.length = 0;
},
_max = 999999999999999,
_min = 0.0000000001,
_globals = _gsScope._gsDefine.globals,
_recordEndMode = false,//in a typical throwProps css tween that has an "end" defined as a function, it grabs that value initially when the tween is rendered, then again when we calculate the necessary duration, and then a 3rd time after we invalidate() the tween, so we toggle _recordEndMode to true when we're about to begin such a tween which tells the engine to grab the end value(s) once and record them as "max" and "min" on the throwProps object, thus we can skip those extra calls. Then we set it back to false when we're done with our fancy initialization routine.
_transforms = {x:1,y:1,z:2,scale:1,scaleX:1,scaleY:1,rotation:1,rotationZ:1,rotationX:2,rotationY:2,skewX:1,skewY:1,xPercent:1,yPercent:1},
_getClosest = function(n, values, max, min, radius) {
var i = values.length,
closest = 0,
absDif = _max,
val, dif, p, dist;
if (typeof(n) === "object") {
while (--i > -1) {
val = values[i];
dif = 0;
for (p in n) {
dist = val[p] - n[p];
dif += dist * dist;
}
if (dif < absDif) {
closest = i;
absDif = dif;
}
}
if ((radius || _max) < _max && radius < Math.sqrt(absDif)) {
return n;
}
} else {
while (--i > -1) {
val = values[i];
dif = val - n;
if (dif < 0) {
dif = -dif;
}
if (dif < absDif && val >= min && val <= max) {
closest = i;
absDif = dif;
}
}
}
return values[closest];
},
_parseEnd = function(curProp, end, max, min, name, radius) {
if (curProp.end === "auto") {
return curProp;
}
var endVar = curProp.end,
adjustedEnd, p;
max = isNaN(max) ? _max : max;
min = isNaN(min) ? -_max : min;
if (typeof(end) === "object") { //for objects, like {x, y} where they're linked and we must pass an object to the function or find the closest value in an array.
adjustedEnd = end.calculated ? end : ((typeof(endVar) === "function") ? endVar(end) : _getClosest(end, endVar, max, min, radius)) || end;
if (!end.calculated) {
for (p in adjustedEnd) {
end[p] = adjustedEnd[p];
}
end.calculated = true;
}
adjustedEnd = adjustedEnd[name];
} else {
adjustedEnd = (typeof(endVar) === "function") ? endVar(end) : (endVar instanceof Array) ? _getClosest(end, endVar, max, min, radius) : Number(endVar);
}
if (adjustedEnd > max) {
adjustedEnd = max;
} else if (adjustedEnd < min) {
adjustedEnd = min;
}
return {max:adjustedEnd, min:adjustedEnd, unitFactor:curProp.unitFactor};
},
_extend = function(decoratee, extras, exclude) {
for (var p in extras) {
if (decoratee[p] === undefined && p !== exclude) {
decoratee[p] = extras[p];
}
}
return decoratee;
},
_calculateChange = ThrowPropsPlugin.calculateChange = function(velocity, ease, duration, checkpoint) {
if (checkpoint == null) {
checkpoint = 0.05;
}
var e = (ease instanceof Ease) ? ease : (!ease) ? TweenLite.defaultEase : new Ease(ease);
return (duration * checkpoint * velocity) / e.getRatio(checkpoint);
},
_calculateDuration = ThrowPropsPlugin.calculateDuration = function(start, end, velocity, ease, checkpoint) {
checkpoint = checkpoint || 0.05;
var e = (ease instanceof Ease) ? ease : (!ease) ? TweenLite.defaultEase : new Ease(ease);
return Math.abs( (end - start) * e.getRatio(checkpoint) / velocity / checkpoint );
},
_calculateTweenDuration = ThrowPropsPlugin.calculateTweenDuration = function(target, vars, maxDuration, minDuration, overshootTolerance, recordEnd) {
if (typeof(target) === "string") {
target = TweenLite.selector(target);
}
if (!target) {
return 0;
}
if (maxDuration == null) {
maxDuration = 10;
}
if (minDuration == null) {
minDuration = 0.2;
}
if (overshootTolerance == null) {
overshootTolerance = 1;
}
if (target.length) {
target = target[0] || target;
}
var duration = 0,
clippedDuration = 9999999999,
throwPropsVars = vars.throwProps || vars,
ease = (vars.ease instanceof Ease) ? vars.ease : (!vars.ease) ? TweenLite.defaultEase : new Ease(vars.ease),
checkpoint = isNaN(throwPropsVars.checkpoint) ? 0.05 : Number(throwPropsVars.checkpoint),
resistance = isNaN(throwPropsVars.resistance) ? ThrowPropsPlugin.defaultResistance : Number(throwPropsVars.resistance),
p, curProp, curDuration, curVelocity, curResistance, curVal, end, curClippedDuration, tracker, unitFactor,
linkedProps, linkedPropNames, i;
if (throwPropsVars.linkedProps) { //when there are linkedProps (typically "x,y" where snapping has to factor in multiple properties, we must first populate an object with all of those end values, then feed it to the function that make any necessary alterations. So the point of this first loop is to simply build an object (like {x:100, y:204.5}) for feeding into that function which we'll do later in the "real" loop.
linkedPropNames = throwPropsVars.linkedProps.split(",");
linkedProps = {};
for (i = 0; i < linkedPropNames.length; i++) {
p = linkedPropNames[i];
curProp = throwPropsVars[p];
if (curProp) {
if (curProp.velocity !== undefined && typeof(curProp.velocity) === "number") {
curVelocity = Number(curProp.velocity) || 0;
} else {
tracker = tracker || VelocityTracker.getByTarget(target);
curVelocity = (tracker && tracker.isTrackingProp(p)) ? tracker.getVelocity(p) : 0;
}
curResistance = isNaN(curProp.resistance) ? resistance : Number(curProp.resistance);
curDuration = (curVelocity * curResistance > 0) ? curVelocity / curResistance : curVelocity / -curResistance;
curVal = (typeof(target[p]) === "function") ? target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]() : target[p] || 0;
linkedProps[p] = curVal + _calculateChange(curVelocity, ease, curDuration, checkpoint);
}
}
}
for (p in throwPropsVars) {
if (p !== "resistance" && p !== "checkpoint" && p !== "preventOvershoot" && p !== "linkedProps" && p !== "radius") {
curProp = throwPropsVars[p];
if (typeof(curProp) !== "object") {
tracker = tracker || VelocityTracker.getByTarget(target);
if (tracker && tracker.isTrackingProp(p)) {
curProp = (typeof(curProp) === "number") ? {velocity:curProp} : {velocity:tracker.getVelocity(p)}; //if we're tracking this property, we should use the tracking velocity and then use the numeric value that was passed in as the min and max so that it tweens exactly there.
} else {
curVelocity = Number(curProp) || 0;
curDuration = (curVelocity * resistance > 0) ? curVelocity / resistance : curVelocity / -resistance;
}
}
if (typeof(curProp) === "object") {
if (curProp.velocity !== undefined && typeof(curProp.velocity) === "number") {
curVelocity = Number(curProp.velocity) || 0;
} else {
tracker = tracker || VelocityTracker.getByTarget(target);
curVelocity = (tracker && tracker.isTrackingProp(p)) ? tracker.getVelocity(p) : 0;
}
curResistance = isNaN(curProp.resistance) ? resistance : Number(curProp.resistance);
curDuration = (curVelocity * curResistance > 0) ? curVelocity / curResistance : curVelocity / -curResistance;
curVal = (typeof(target[p]) === "function") ? target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]() : target[p] || 0;
end = curVal + _calculateChange(curVelocity, ease, curDuration, checkpoint);
if (curProp.end !== undefined) {
curProp = _parseEnd(curProp, (linkedProps && p in linkedProps) ? linkedProps : end, curProp.max, curProp.min, p, throwPropsVars.radius);
if (recordEnd || _recordEndMode) {
throwPropsVars[p] = _extend(curProp, throwPropsVars[p], "end");
}
}
if (curProp.max !== undefined && end > Number(curProp.max) + _min) {
unitFactor = curProp.unitFactor || ThrowPropsPlugin.defaultUnitFactors[p] || 1; //some values are measured in special units like radians in which case our thresholds need to be adjusted accordingly.
//if the value is already exceeding the max or the velocity is too low, the duration can end up being uncomfortably long but in most situations, users want the snapping to occur relatively quickly (0.75 seconds), so we implement a cap here to make things more intuitive. If the max and min match, it means we're animating to a particular value and we don't want to shorten the time unless the velocity is really slow. Example: a rotation where the start and natural end value are less than the snapping spot, but the natural end is pretty close to the snap.
curClippedDuration = ((curVal > curProp.max && curProp.min !== curProp.max) || (curVelocity * unitFactor > -15 && curVelocity * unitFactor < 45)) ? (minDuration + (maxDuration - minDuration) * 0.1) : _calculateDuration(curVal, curProp.max, curVelocity, ease, checkpoint);
if (curClippedDuration + overshootTolerance < clippedDuration) {
clippedDuration = curClippedDuration + overshootTolerance;
}
} else if (curProp.min !== undefined && end < Number(curProp.min) - _min) {
unitFactor = curProp.unitFactor || ThrowPropsPlugin.defaultUnitFactors[p] || 1; //some values are measured in special units like radians in which case our thresholds need to be adjusted accordingly.
//if the value is already exceeding the min or if the velocity is too low, the duration can end up being uncomfortably long but in most situations, users want the snapping to occur relatively quickly (0.75 seconds), so we implement a cap here to make things more intuitive.
curClippedDuration = ((curVal < curProp.min && curProp.min !== curProp.max) || (curVelocity * unitFactor > -45 && curVelocity * unitFactor < 15)) ? (minDuration + (maxDuration - minDuration) * 0.1) : _calculateDuration(curVal, curProp.min, curVelocity, ease, checkpoint);
if (curClippedDuration + overshootTolerance < clippedDuration) {
clippedDuration = curClippedDuration + overshootTolerance;
}
}
if (curClippedDuration > duration) {
duration = curClippedDuration;
}
}
if (curDuration > duration) {
duration = curDuration;
}
}
}
if (duration > clippedDuration) {
duration = clippedDuration;
}
if (duration > maxDuration) {
return maxDuration;
} else if (duration < minDuration) {
return minDuration;
}
return duration;
},
p = ThrowPropsPlugin.prototype = new TweenPlugin("throwProps"),
_cssProxy, _cssVars, _last, _lastValue; //these serve as a cache of sorts, recording the last css-related proxy and the throwProps vars that get calculated in the _cssRegister() method. This allows us to grab them in the ThrowPropsPlugin.to() function and calculate the duration. Of course we could have structured things in a more "clean" fashion, but performance is of paramount importance.
p.constructor = ThrowPropsPlugin;
ThrowPropsPlugin.version = "0.11.2";
ThrowPropsPlugin.API = 2;
ThrowPropsPlugin._autoCSS = true; //indicates that this plugin can be inserted into the "css" object using the autoCSS feature of TweenLite
ThrowPropsPlugin.defaultResistance = 100;
ThrowPropsPlugin.defaultUnitFactors = {time:1000, totalTime:1000}; //setting the unitFactor to a higher value (default is 1) reduces the chance of the auto-accelerating behavior kicking in when determining durations when the initial velocity is adequately low - imagine dragging something past a boundary and then letting go - snapping back relatively quickly should be prioritized over matching the initial velocity (at least that's the behavior most people consider intuitive). But in some situations when the units are very low (like "time" of a timeline or rotation when using radians), it can kick in too frequently so this allows tweaking.
ThrowPropsPlugin.track = function(target, props, types) {
return VelocityTracker.track(target, props, types);
};
ThrowPropsPlugin.untrack = function(target, props) {
VelocityTracker.untrack(target, props);
};
ThrowPropsPlugin.isTracking = function(target, prop) {
return VelocityTracker.isTracking(target, prop);
};
ThrowPropsPlugin.getVelocity = function(target, prop) {
var vt = VelocityTracker.getByTarget(target);
return vt ? vt.getVelocity(prop) : NaN;
};
ThrowPropsPlugin._cssRegister = function() {
var CSSPlugin = _globals.com.greensock.plugins.CSSPlugin;
if (!CSSPlugin) {
return;
}
var _internals = CSSPlugin._internals,
_parseToProxy = _internals._parseToProxy,
_setPluginRatio = _internals._setPluginRatio,
CSSPropTween = _internals.CSSPropTween;
_internals._registerComplexSpecialProp("throwProps", {parser:function(t, e, prop, cssp, pt, plugin) {
plugin = new ThrowPropsPlugin();
var velocities = {},
min = {},
max = {},
end = {},
res = {},
preventOvershoot = {},
hasResistance, val, p, data, tracker;
_cssVars = {};
for (p in e) {
if (p !== "resistance" && p !== "preventOvershoot" && p !== "linkedProps" && p !== "radius") {
val = e[p];
if (typeof(val) === "object") {
if (val.velocity !== undefined && typeof(val.velocity) === "number") {
velocities[p] = Number(val.velocity) || 0;
} else {
tracker = tracker || VelocityTracker.getByTarget(t);
velocities[p] = (tracker && tracker.isTrackingProp(p)) ? tracker.getVelocity(p) : 0; //rotational values are actually converted to radians in CSSPlugin, but our tracking velocity is in radians already, so make it into degrees to avoid a funky conversion
}
if (val.end !== undefined) {
end[p] = val.end;
}
if (val.min !== undefined) {
min[p] = val.min;
}
if (val.max !== undefined) {
max[p] = val.max;
}
if (val.preventOvershoot) {
preventOvershoot[p] = true;
}
if (val.resistance !== undefined) {
hasResistance = true;
res[p] = val.resistance;
}
} else if (typeof(val) === "number") {
velocities[p] = val;
} else {
tracker = tracker || VelocityTracker.getByTarget(t);
if (tracker && tracker.isTrackingProp(p)) {
velocities[p] = tracker.getVelocity(p);
} else {
velocities[p] = val || 0;
}
}
if (_transforms[p]) {
cssp._enableTransforms((_transforms[p] === 2));
}
}
}
data = _parseToProxy(t, velocities, cssp, pt, plugin);
_cssProxy = data.proxy;
velocities = data.end;
for (p in _cssProxy) {
_cssVars[p] = {velocity:velocities[p], min:min[p], max:max[p], end:end[p], resistance:res[p], preventOvershoot:preventOvershoot[p]};
}
if (e.resistance != null) {
_cssVars.resistance = e.resistance;
}
if (e.linkedProps != null) {
_cssVars.linkedProps = e.linkedProps;
}
if (e.radius != null) {
_cssVars.radius = e.radius;
}
if (e.preventOvershoot) {
_cssVars.preventOvershoot = true;
}
pt = new CSSPropTween(t, "throwProps", 0, 0, data.pt, 2);
cssp._overwriteProps.pop(); //don't overwrite all other throwProps tweens. In the CSSPropTween constructor, we add the property to the _overwriteProps, so remove it here.
pt.plugin = plugin;
pt.setRatio = _setPluginRatio;
pt.data = data;
plugin._onInitTween(_cssProxy, _cssVars, cssp._tween);
return pt;
}});
};
ThrowPropsPlugin.to = function(target, vars, maxDuration, minDuration, overshootTolerance) {
if (!vars.throwProps) {
vars = {throwProps:vars};
}
if (overshootTolerance === 0) {
vars.throwProps.preventOvershoot = true;
}
_recordEndMode = true; //if we encounter a function-based "end" value, ThrowPropsPlugin will record it as "max" and "min" properties, replacing "end" (this is an optimization so that the function only gets called once)
var tween = new TweenLite(target, minDuration || 1, vars);
tween.render(0, true, true); //we force a render so that the CSSPlugin instantiates and populates the _cssProxy and _cssVars which we need in order to calculate the tween duration. Remember, we can't use the regular target for calculating the duration because the current values wouldn't be able to be grabbed like target["propertyName"], as css properties can be complex like boxShadow:"10px 10px 20px 30px red" or backgroundPosition:"25px 50px". The proxy is the result of breaking all that complex data down and finding just the numeric values and assigning them to a generic proxy object with unique names. THAT is what the _calculateTweenDuration() can look at. We also needed to do the same break down of any min or max or velocity data
if (tween.vars.css) {
tween.duration(_calculateTweenDuration(_cssProxy, {throwProps:_cssVars, ease:vars.ease}, maxDuration, minDuration, overshootTolerance));
if (tween._delay && !tween.vars.immediateRender) {
tween.invalidate(); //if there's a delay, the starting values could be off, so invalidate() to force reinstantiation when the tween actually starts.
} else {
_last._onInitTween(_cssProxy, _lastValue, tween);
}
_recordEndMode = false;
return tween;
} else {
tween.kill();
tween = new TweenLite(target, _calculateTweenDuration(target, vars, maxDuration, minDuration, overshootTolerance), vars);
_recordEndMode = false;
return tween;
}
};
p._onInitTween = function(target, value, tween, index) {
this.target = target;
this._props = [];
_last = this;
_lastValue = value;
var ease = tween._ease,
checkpoint = isNaN(value.checkpoint) ? 0.05 : Number(value.checkpoint),
duration = tween._duration,
preventOvershoot = value.preventOvershoot,
cnt = 0,
p, curProp, curVal, isFunc, velocity, change1, end, change2, tracker,
linkedProps, linkedPropNames, i;
if (value.linkedProps) { //when there are linkedProps (typically "x,y" where snapping has to factor in multiple properties, we must first populate an object with all of those end values, then feed it to the function that make any necessary alterations. So the point of this first loop is to simply build an object (like {x:100, y:204.5}) for feeding into that function which we'll do later in the "real" loop.
linkedPropNames = value.linkedProps.split(",");
linkedProps = {};
for (i = 0; i < linkedPropNames.length; i++) {
p = linkedPropNames[i];
curProp = value[p];
if (curProp) {
if (curProp.velocity !== undefined && typeof(curProp.velocity) === "number") {
velocity = Number(curProp.velocity) || 0;
} else {
tracker = tracker || VelocityTracker.getByTarget(target);
velocity = (tracker && tracker.isTrackingProp(p)) ? tracker.getVelocity(p) : 0;
}
curVal = (typeof(target[p]) === "function") ? target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]() : target[p] || 0;
linkedProps[p] = curVal + _calculateChange(velocity, ease, duration, checkpoint);
}
}
}
for (p in value) {
if (p !== "resistance" && p !== "checkpoint" && p !== "preventOvershoot" && p !== "linkedProps" && p !== "radius") {
curProp = value[p];
if (typeof(curProp) === "function") {
curProp = curProp(index, target);
}
if (typeof(curProp) === "number") {
velocity = Number(curProp) || 0;
} else if (typeof(curProp) === "object" && !isNaN(curProp.velocity)) {
velocity = Number(curProp.velocity);
} else {
tracker = tracker || VelocityTracker.getByTarget(target);
if (tracker && tracker.isTrackingProp(p)) {
velocity = tracker.getVelocity(p);
} else {
throw("ERROR: No velocity was defined in the throwProps tween of " + target + " property: " + p);
}
}
change1 = _calculateChange(velocity, ease, duration, checkpoint);
change2 = 0;
isFunc = (typeof(target[p]) === "function");
curVal = (isFunc) ? target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]() : target[p];
if (typeof(curProp) === "object") {
end = curVal + change1;
if (curProp.end !== undefined) {
curProp = _parseEnd(curProp, (linkedProps && p in linkedProps) ? linkedProps : end, curProp.max, curProp.min, p, value.radius);
if (_recordEndMode) {
value[p] = _extend(curProp, value[p], "end");
}
}
if (curProp.max !== undefined && Number(curProp.max) < end) {
if (preventOvershoot || curProp.preventOvershoot) {
change1 = curProp.max - curVal;
} else {
change2 = (curProp.max - curVal) - change1;
}
} else if (curProp.min !== undefined && Number(curProp.min) > end) {
if (preventOvershoot || curProp.preventOvershoot) {
change1 = curProp.min - curVal;
} else {
change2 = (curProp.min - curVal) - change1;
}
}
}
this._overwriteProps[cnt] = p;
this._props[cnt++] = {p:p, s:curVal, c1:change1, c2:change2, f:isFunc, r:false};
}
}
return true;
};
p._kill = function(lookup) {
var i = this._props.length;
while (--i > -1) {
if (lookup[this._props[i].p] != null) {
this._props.splice(i, 1);
}
}
return TweenPlugin.prototype._kill.call(this, lookup);
};
p._mod = function(lookup) {
var p = this._props,
i = p.length,
val;
while (--i > -1) {
val = lookup[p[i].p] || lookup.throwProps;
if (typeof(val) === "function") {
p[i].m = val;
}
}
};
p.setRatio = function(v) {
var i = this._props.length,
cp, val;
while (--i > -1) {
cp = this._props[i];
val = cp.s + cp.c1 * v + cp.c2 * v * v;
if (cp.m) {
val = cp.m(val, this.target);
} else if (v === 1) {
val = ((val * 10000 + (val < 0 ? -0.5 : 0.5)) | 0) / 10000; //if we don't round things at the very end, binary math issues can creep in and cause snapping not to be exact (like landing on 20.000000000001 instead of 20).
}
if (cp.f) {
this.target[cp.p](val);
} else {
this.target[cp.p] = val;
}
}
};
TweenPlugin.activate([ThrowPropsPlugin]);
return ThrowPropsPlugin;
}, true);
/*
* ----------------------------------------------------------------
* VelocityTracker
* ----------------------------------------------------------------
*/
_gsScope._gsDefine("utils.VelocityTracker", ["TweenLite"], function(TweenLite) {
var _first, _initted, _time1, _time2,
_capsExp = /([A-Z])/g,
_empty = {},
_doc = _gsScope.document,
_transforms = {x:1,y:1,z:2,scale:1,scaleX:1,scaleY:1,rotation:1,rotationZ:1,rotationX:2,rotationY:2,skewX:1,skewY:1,xPercent:1,yPercent:1},
_computedStyleScope = (typeof(window) !== "undefined" ? window : _doc.defaultView || {getComputedStyle:function() {}}),
_getComputedStyle = function(e) {
return _computedStyleScope.getComputedStyle(e); //to avoid errors in Microsoft Edge, we need to call getComputedStyle() from a specific scope, typically window.
},
_getStyle = function(t, p, cs) {
var rv = (t._gsTransform || _empty)[p];
if (rv || rv === 0) {
return rv;
} else if (t.style[p]) {
rv = t.style[p];
} else if ((cs = cs || _getComputedStyle(t, null))) {
rv = cs[p] || cs.getPropertyValue(p) || cs.getPropertyValue(p.replace(_capsExp, "-$1").toLowerCase());
} else if (t.currentStyle) {
rv = t.currentStyle[p];
}
return parseFloat(rv) || 0;
},
_ticker = TweenLite.ticker,
VelocityProp = function(p, isFunc, next) {
this.p = p;
this.f = isFunc;
this.v1 = this.v2 = 0;
this.t1 = this.t2 = _ticker.time;
this.css = false;
this.type = "";
this._prev = null;
if (next) {
this._next = next;
next._prev = this;
}
},
_update = function() {
var vt = _first,
t = _ticker.time,
val, vp;
//if the frame rate is too high, we won't be able to track the velocity as well, so only update the values about 33 times per second
if (t - _time1 >= 0.03) {
_time2 = _time1;
_time1 = t;
while (vt) {
vp = vt._firstVP;
while (vp) {
val = vp.css ? _getStyle(vt.target, vp.p) : vp.f ? vt.target[vp.p]() : vt.target[vp.p];
if (val !== vp.v1 || t - vp.t1 > 0.15) { //use a threshold of 0.15 seconds for zeroing-out velocity. If we only use 0.03 and things update slightly slower, like some Android devices dispatch "touchmove" events sluggishly so 2 or 3 ticks of the TweenLite.ticker may elapse inbetween, thus it may appear like the object is not moving but it actually is but it's not updating as frequently. A threshold of 0.15 seconds seems to be a good balance. We want to update things frequently (0.03 seconds) when they're moving so that we can respond to fast motions accurately, but we want to be more resistant to go back to a zero velocity.
vp.v2 = vp.v1;
vp.v1 = val;
vp.t2 = vp.t1;
vp.t1 = t;
}
vp = vp._next;
}
vt = vt._next;
}
}
},
VelocityTracker = function(target) {
this._lookup = {};
this.target = target;
this.elem = (target.style && target.nodeType) ? true : false;
if (!_initted) {
_ticker.addEventListener("tick", _update, null, false, -100);
_time1 = _time2 = _ticker.time;
_initted = true;
}
if (_first) {
this._next = _first;
_first._prev = this;
}
_first = this;
},
getByTarget = VelocityTracker.getByTarget = function(target) {
var vt = _first;
while (vt) {
if (vt.target === target) {
return vt;
}
vt = vt._next;
}
},
p = VelocityTracker.prototype;
p.addProp = function(prop, type) {
if (!this._lookup[prop]) {
var t = this.target,
isFunc = (typeof(t[prop]) === "function"),
alt = isFunc ? this._altProp(prop) : prop,
vp = this._firstVP;
this._firstVP = this._lookup[prop] = this._lookup[alt] = vp = new VelocityProp((alt !== prop && prop.indexOf("set") === 0) ? alt : prop, isFunc, vp);
vp.css = (this.elem && (this.target.style[vp.p] !== undefined || _transforms[vp.p]));
if (vp.css && _transforms[vp.p] && !t._gsTransform) {
TweenLite.set(t, {x:"+=0", overwrite:false}); //just forces CSSPlugin to create a _gsTransform for the element if it doesn't exist
}
vp.type = type || (vp.css && prop.indexOf("rotation") === 0) ? "deg" : "";
vp.v1 = vp.v2 = vp.css ? _getStyle(t, vp.p) : isFunc ? t[vp.p]() : t[vp.p];
}
};
p.removeProp = function(prop) {
var vp = this._lookup[prop];
if (vp) {
if (vp._prev) {
vp._prev._next = vp._next;
} else if (vp === this._firstVP) {
this._firstVP = vp._next;
}
if (vp._next) {
vp._next._prev = vp._prev;
}
this._lookup[prop] = 0;
if (vp.f) {
this._lookup[this._altProp(prop)] = 0; //if it's a getter/setter, we should remove the matching counterpart (if one exists)
}
}
};
p.isTrackingProp = function(prop) {
return (this._lookup[prop] instanceof VelocityProp);
};
p.getVelocity = function(prop) {
var vp = this._lookup[prop],
target = this.target,
val, dif, rotationCap;
if (!vp) {
throw "The velocity of " + prop + " is not being tracked.";
}
val = vp.css ? _getStyle(target, vp.p) : vp.f ? target[vp.p]() : target[vp.p];
dif = (val - vp.v2);
if (vp.type === "rad" || vp.type === "deg") { //rotational values need special interpretation so that if, for example, they go from 179 to -178 degrees it is interpreted as a change of 3 instead of -357.
rotationCap = (vp.type === "rad") ? Math.PI * 2 : 360;
dif = dif % rotationCap;
if (dif !== dif % (rotationCap / 2)) {
dif = (dif < 0) ? dif + rotationCap : dif - rotationCap;
}
}
return dif / (_ticker.time - vp.t2);
};
p._altProp = function(p) { //for getters/setters like getCustomProp() and setCustomProp() - we should accommodate both
var pre = p.substr(0, 3),
alt = ((pre === "get") ? "set" : (pre === "set") ? "get" : pre) + p.substr(3);
return (typeof(this.target[alt]) === "function") ? alt : p;
};
VelocityTracker.getByTarget = function(target) {
var vt = _first;
if (typeof(target) === "string") {
target = TweenLite.selector(target);
}
if (target.length && target !== window && target[0] && target[0].style && !target.nodeType) {
target = target[0];
}
while (vt) {
if (vt.target === target) {
return vt;
}
vt = vt._next;
}
};
VelocityTracker.track = function(target, props, types) {
var vt = getByTarget(target),
a = props.split(","),
i = a.length;
types = (types || "").split(",");
if (!vt) {
vt = new VelocityTracker(target);
}
while (--i > -1) {
vt.addProp(a[i], types[i] || types[0]);
}
return vt;
};
VelocityTracker.untrack = function(target, props) {
var vt = getByTarget(target),
a = (props || "").split(","),
i = a.length;
if (!vt) {
return;
}
while (--i > -1) {
vt.removeProp(a[i]);
}
if (!vt._firstVP || !props) {
if (vt._prev) {
vt._prev._next = vt._next;
} else if (vt === _first) {
_first = vt._next;
}
if (vt._next) {
vt._next._prev = vt._prev;
}
}
};
VelocityTracker.isTracking = function(target, prop) {
var vt = getByTarget(target);
return (!vt) ? false : (!prop && vt._firstVP) ? true : vt.isTrackingProp(prop);
};
return VelocityTracker;
}, true);
}); if (_gsScope._gsDefine) { _gsScope._gsQueue.pop()(); }
//export to AMD/RequireJS and CommonJS/Node (precursor to full modular build system coming at a later date)
(function(name) {
"use strict";
var getGlobal = function() {
return (_gsScope.GreenSockGlobals || _gsScope)[name];
};
if (typeof(module) !== "undefined" && module.exports) { //node
require("../TweenLite.js");
module.exports = getGlobal();
} else if (typeof(define) === "function" && define.amd) { //AMD
define(["TweenLite"], getGlobal);
}
}("ThrowPropsPlugin"));

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,573 @@
/*!
* VERSION: 0.7.0
* DATE: 2019-02-07
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* SplitText is a Club GreenSock membership benefit; You must have a valid membership to use
* this code without violating the terms of use. Visit http://greensock.com/club/ to sign up or get more details.
* This work is subject to the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || window; //helps ensure compatibility with AMD/RequireJS and CommonJS/Node
(function(window) {
"use strict";
var _globals = window.GreenSockGlobals || window,
_namespace = function(ns) {
var a = ns.split("."),
p = _globals, i;
for (i = 0; i < a.length; i++) {
p[a[i]] = p = p[a[i]] || {};
}
return p;
},
pkg = _namespace("com.greensock.utils"),
_getText = function(e) {
var type = e.nodeType,
result = "";
if (type === 1 || type === 9 || type === 11) {
if (typeof(e.textContent) === "string") {
return e.textContent;
} else {
for ( e = e.firstChild; e; e = e.nextSibling ) {
result += _getText(e);
}
}
} else if (type === 3 || type === 4) {
return e.nodeValue;
}
return result;
},
_doc = _gsScope.document || {},
_computedStyleScope = (typeof(window) !== "undefined" ? window : _doc.defaultView || {getComputedStyle:function() {}}),
_getComputedStyle = function(e) {
return _computedStyleScope.getComputedStyle(e); //to avoid errors in Microsoft Edge, we need to call getComputedStyle() from a specific scope, typically window.
},
_capsExp = /([A-Z])/g,
_getStyle = function(t, p, cs, str) {
var result;
if ((cs = cs || _getComputedStyle(t, null))) {
t = cs.getPropertyValue(p.replace(_capsExp, "-$1").toLowerCase());
result = (t || cs.length) ? t : cs[p]; //Opera behaves VERY strangely - length is usually 0 and cs[p] is the only way to get accurate results EXCEPT when checking for -o-transform which only works with cs.getPropertyValue()!
} else if (t.currentStyle) {
cs = t.currentStyle;
result = cs[p];
}
return str ? result : parseInt(result, 10) || 0;
},
_isArrayLike = function(e) {
return (e.length && e[0] && ((e[0].nodeType && e[0].style && !e.nodeType) || (e[0].length && e[0][0]))) ? true : false; //could be an array of jQuery objects too, so accommodate that.
},
_flattenArray = function(a) {
var result = [],
l = a.length,
i, e, j;
for (i = 0; i < l; i++) {
e = a[i];
if (_isArrayLike(e)) {
j = e.length;
for (j = 0; j < e.length; j++) {
result.push(e[j]);
}
} else {
result.push(e);
}
}
return result;
},
//some characters are combining marks (think diacritics/accents in European languages) which involve 2 or 4 characters that combine in the browser to form a single character. Pass in the remaining text and an array of the special characters to search for and if the text starts with one of those special characters, it'll spit back the number of characters to retain (often 2 or 4). Used in the specialChars features that was introduced in 0.6.0.
_findSpecialChars = function(text, chars) {
var i = chars.length,
s;
while (--i > -1) {
s = chars[i];
if (text.substr(0, s.length) === s) {
return s.length;
}
}
},
_stripExp = /(?:\r|\n|\t\t)/g, //find carriage returns, new line feeds and double-tabs.
_multipleSpacesExp = /(?:\s\s+)/g,
_emojiStart = 0xD800,
_emojiEnd = 0xDBFF,
_emojiLowStart = 0xDC00,
_emojiRegionStart = 0x1F1E6,
_emojiRegionEnd = 0x1F1FF,
_emojiModStart = 0x1f3fb,
_emojiModEnd = 0x1f3ff,
_emojiPairCode = function(s) {
return ((s.charCodeAt(0) - _emojiStart) << 10) + (s.charCodeAt(1) - _emojiLowStart) + 0x10000;
},
_isOldIE = (_doc.all && !_doc.addEventListener),
_divStart = " style='position:relative;display:inline-block;" + (_isOldIE ? "*display:inline;*zoom:1;'" : "'"), //note: we must use both display:inline-block and *display:inline for IE8 and earlier, otherwise it won't flow correctly (and if we only use display:inline, IE won't render most of the property tweens - very odd).
_cssClassFunc = function(cssClass, tag) {
cssClass = cssClass || "";
var iterate = (cssClass.indexOf("++") !== -1),
num = 1;
if (iterate) {
cssClass = cssClass.split("++").join("");
}
return function() {
return "<" + tag + _divStart + (cssClass ? " class='" + cssClass + (iterate ? num++ : "") + "'>" : ">");
};
},
SplitText = pkg.SplitText = _globals.SplitText = function(element, vars) {
if (typeof(element) === "string") {
element = SplitText.selector(element);
}
if (!element) {
throw("cannot split a null element.");
}
this.elements = _isArrayLike(element) ? _flattenArray(element) : [element];
this.chars = [];
this.words = [];
this.lines = [];
this._originals = [];
this.vars = vars || {};
this.split(vars);
},
_swapText = function(element, oldText, newText) {
var type = element.nodeType;
if (type === 1 || type === 9 || type === 11) {
for (element = element.firstChild; element; element = element.nextSibling) {
_swapText(element, oldText, newText);
}
} else if (type === 3 || type === 4) {
element.nodeValue = element.nodeValue.split(oldText).join(newText);
}
},
_pushReversed = function(a, merge) {
var i = merge.length;
while (--i > -1) {
a.push(merge[i]);
}
},
_slice = function(a) { //don't use Array.prototype.slice.call(target, 0) because that doesn't work in IE8 with a NodeList that's returned by querySelectorAll()
var b = [],
l = a.length,
i;
for (i = 0; i !== l; b.push(a[i++])) {}
return b;
},
_isBeforeWordDelimiter = function(e, root, wordDelimiter) {
var next;
while (e && e !== root) {
next = e._next || e.nextSibling;
if (next) {
return next.textContent.charAt(0) === wordDelimiter;
}
e = e.parentNode || e._parent;
}
return false;
},
_deWordify = function(e) {
var children = _slice(e.childNodes),
l = children.length,
i, child;
for (i = 0; i < l; i++) {
child = children[i];
if (child._isSplit) {
_deWordify(child);
} else {
if (i && child.previousSibling.nodeType === 3) {
child.previousSibling.nodeValue += (child.nodeType === 3) ? child.nodeValue : child.firstChild.nodeValue;
} else if (child.nodeType !== 3) {
e.insertBefore(child.firstChild, child);
}
e.removeChild(child);
}
}
},
_setPositionsAfterSplit = function(element, vars, allChars, allWords, allLines, origWidth, origHeight) {
var cs = _getComputedStyle(element),
paddingLeft = _getStyle(element, "paddingLeft", cs),
lineOffsetY = -999,
borderTopAndBottom = _getStyle(element, "borderBottomWidth", cs) + _getStyle(element, "borderTopWidth", cs),
borderLeftAndRight = _getStyle(element, "borderLeftWidth", cs) + _getStyle(element, "borderRightWidth", cs),
padTopAndBottom = _getStyle(element, "paddingTop", cs) + _getStyle(element, "paddingBottom", cs),
padLeftAndRight = _getStyle(element, "paddingLeft", cs) + _getStyle(element, "paddingRight", cs),
lineThreshold = _getStyle(element, "fontSize") * 0.2,
textAlign = _getStyle(element, "textAlign", cs, true),
charArray = [],
wordArray = [],
lineArray = [],
wordDelimiter = vars.wordDelimiter || " ",
tag = vars.tag ? vars.tag : (vars.span ? "span" : "div"),
types = vars.type || vars.split || "chars,words,lines",
lines = (allLines && types.indexOf("lines") !== -1) ? [] : null,
words = (types.indexOf("words") !== -1),
chars = (types.indexOf("chars") !== -1),
absolute = (vars.position === "absolute" || vars.absolute === true),
linesClass = vars.linesClass,
iterateLine = ((linesClass || "").indexOf("++") !== -1),
spaceNodesToRemove = [],
i, j, l, node, nodes, isChild, curLine, addWordSpaces, style, lineNode, lineWidth, offset;
if (iterateLine) {
linesClass = linesClass.split("++").join("");
}
//copy all the descendant nodes into an array (we can't use a regular nodeList because it's live and we may need to renest things)
j = element.getElementsByTagName("*");
l = j.length;
nodes = [];
for (i = 0; i < l; i++) {
nodes[i] = j[i];
}
//for absolute positioning, we need to record the x/y offsets and width/height for every <div>. And even if we're not positioning things absolutely, in order to accommodate lines, we must figure out where the y offset changes so that we can sense where the lines break, and we populate the lines array.
if (lines || absolute) {
for (i = 0; i < l; i++) {
node = nodes[i];
isChild = (node.parentNode === element);
if (isChild || absolute || (chars && !words)) {
offset = node.offsetTop;
if (lines && isChild && Math.abs(offset - lineOffsetY) > lineThreshold && (node.nodeName !== "BR" || i === 0)) { //we found some rare occasions where a certain character like &#8209; could cause the offsetTop to be off by 1 pixel, so we build in a threshold.
curLine = [];
lines.push(curLine);
lineOffsetY = offset;
}
if (absolute) { //record offset x and y, as well as width and height so that we can access them later for positioning. Grabbing them at once ensures we don't trigger a browser paint & we maximize performance.
node._x = node.offsetLeft;
node._y = offset;
node._w = node.offsetWidth;
node._h = node.offsetHeight;
}
if (lines) {
if ((node._isSplit && isChild) || (!chars && isChild) || (words && isChild) || (!words && node.parentNode.parentNode === element && !node.parentNode._isSplit)) {
curLine.push(node);
node._x -= paddingLeft;
if (_isBeforeWordDelimiter(node, element, wordDelimiter)) {
node._wordEnd = true;
}
}
if (node.nodeName === "BR" && ((node.nextSibling && node.nextSibling.nodeName === "BR") || i === 0)) { //two consecutive <br> tags signify a new [empty] line. Also, if the entire block of content STARTS with a <br>, add a line.
lines.push([]);
}
}
}
}
}
for (i = 0; i < l; i++) {
node = nodes[i];
isChild = (node.parentNode === element);
if (node.nodeName === "BR") {
if (lines || absolute) {
if (node.parentNode) {
node.parentNode.removeChild(node);
}
nodes.splice(i--, 1);
l--;
} else if (!words) {
element.appendChild(node);
}
continue;
}
if (absolute) {
style = node.style;
if (!words && !isChild) {
node._x += node.parentNode._x;
node._y += node.parentNode._y;
}
style.left = node._x + "px";
style.top = node._y + "px";
style.position = "absolute";
style.display = "block";
//if we don't set the width/height, things collapse in older versions of IE and the origin for transforms is thrown off in all browsers.
style.width = (node._w + 1) + "px"; //IE is 1px short sometimes. Avoid wrapping
style.height = node._h + "px";
}
if (!words && chars) {
//we always start out wrapping words in their own <div> so that line breaks happen correctly, but here we'll remove those <div> tags if necessary and renest the characters directly into the element rather than inside the word <div>
if (node._isSplit) {
node._next = node.nextSibling;
node.parentNode.appendChild(node); //put it at the end to keep the order correct.
} else if (node.parentNode._isSplit) {
node._parent = node.parentNode;
if (!node.previousSibling && node.firstChild) {
node.firstChild._isFirst = true;
}
if (node.nextSibling && node.nextSibling.textContent === " " && !node.nextSibling.nextSibling) { //if the last node inside a nested element is just a space (like T<span>nested </span>), remove it otherwise it'll get placed in the wrong order. Don't remove it right away, though, because we need to sense when words/characters are before a space like _isBeforeWordDelimiter(). Removing it now would make that a false negative.
spaceNodesToRemove.push(node.nextSibling);
}
node._next = (node.nextSibling && node.nextSibling._isFirst) ? null : node.nextSibling;
node.parentNode.removeChild(node);
nodes.splice(i--, 1);
l--;
} else if (!isChild) {
offset = (!node.nextSibling && _isBeforeWordDelimiter(node.parentNode, element, wordDelimiter)); //if this is the last letter in the word (and we're not breaking by lines and not positioning things absolutely), we need to add a space afterwards so that the characters don't just mash together
if (node.parentNode._parent) {
node.parentNode._parent.appendChild(node);
}
if (offset) {
node.parentNode.appendChild(_doc.createTextNode(" "));
}
if (tag === "span") {
node.style.display = "inline"; //so that word breaks are honored properly.
}
charArray.push(node);
}
} else if (node.parentNode._isSplit && !node._isSplit && node.innerHTML !== "") {
wordArray.push(node);
} else if (chars && !node._isSplit) {
if (tag === "span") {
node.style.display = "inline";
}
charArray.push(node);
}
}
i = spaceNodesToRemove.length;
while (--i > -1) {
spaceNodesToRemove[i].parentNode.removeChild(spaceNodesToRemove[i]);
}
if (lines) {
//the next 7 lines just give us the line width in the most reliable way and figure out the left offset (if position isn't relative or absolute). We must set the width along with text-align to ensure everything works properly for various alignments.
if (absolute) {
lineNode = _doc.createElement(tag);
element.appendChild(lineNode);
lineWidth = lineNode.offsetWidth + "px";
offset = (lineNode.offsetParent === element) ? 0 : element.offsetLeft;
element.removeChild(lineNode);
}
style = element.style.cssText;
element.style.cssText = "display:none;"; //to improve performance, set display:none on the element so that the browser doesn't have to worry about reflowing or rendering while we're renesting things. We'll revert the cssText later.
//we can't use element.innerHTML = "" because that causes IE to literally delete all the nodes and their content even though we've stored them in an array! So we must loop through the children and remove them.
while (element.firstChild) {
element.removeChild(element.firstChild);
}
addWordSpaces = (wordDelimiter === " " && (!absolute || (!words && !chars)));
for (i = 0; i < lines.length; i++) {
curLine = lines[i];
lineNode = _doc.createElement(tag);
lineNode.style.cssText = "display:block;text-align:" + textAlign + ";position:" + (absolute ? "absolute;" : "relative;");
if (linesClass) {
lineNode.className = linesClass + (iterateLine ? i+1 : "");
}
lineArray.push(lineNode);
l = curLine.length;
for (j = 0; j < l; j++) {
if (curLine[j].nodeName !== "BR") {
node = curLine[j];
lineNode.appendChild(node);
if (addWordSpaces && node._wordEnd) {
lineNode.appendChild(_doc.createTextNode(" "));
}
if (absolute) {
if (j === 0) {
lineNode.style.top = (node._y) + "px";
lineNode.style.left = (paddingLeft + offset) + "px";
}
node.style.top = "0px";
if (offset) {
node.style.left = (node._x - offset) + "px";
}
}
}
}
if (l === 0) { //if there are no nodes in the line (typically meaning there were two consecutive <br> tags, just add a non-breaking space so that things display properly.
lineNode.innerHTML = "&nbsp;";
} else if (!words && !chars) {
_deWordify(lineNode);
_swapText(lineNode, String.fromCharCode(160), " ");
}
if (absolute) {
lineNode.style.width = lineWidth;
lineNode.style.height = node._h + "px";
}
element.appendChild(lineNode);
}
element.style.cssText = style;
}
//if everything shifts to being position:absolute, the container can collapse in terms of height or width, so fix that here.
if (absolute) {
if (origHeight > element.clientHeight) {
element.style.height = (origHeight - padTopAndBottom) + "px";
if (element.clientHeight < origHeight) { //IE8 and earlier use a different box model - we must include padding and borders
element.style.height = (origHeight + borderTopAndBottom)+ "px";
}
}
if (origWidth > element.clientWidth) {
element.style.width = (origWidth - padLeftAndRight) + "px";
if (element.clientWidth < origWidth) { //IE8 and earlier use a different box model - we must include padding and borders
element.style.width = (origWidth + borderLeftAndRight)+ "px";
}
}
}
_pushReversed(allChars, charArray);
if (words) {
_pushReversed(allWords, wordArray);
}
_pushReversed(allLines, lineArray);
},
_splitRawText = function(element, vars, wordStart, charStart) {
var tag = vars.tag ? vars.tag : (vars.span ? "span" : "div"),
types = vars.type || vars.split || "chars,words,lines",
//words = (types.indexOf("words") !== -1),
chars = (types.indexOf("chars") !== -1),
absolute = (vars.position === "absolute" || vars.absolute === true),
wordDelimiter = vars.wordDelimiter || " ",
space = wordDelimiter !== " " ? "" : (absolute ? "&#173; " : " "),
wordEnd = "</" + tag + ">",
wordIsOpen = true,
specialChars = vars.specialChars ? (typeof(vars.specialChars) === "function" ? vars.specialChars : _findSpecialChars) : null, //specialChars can be an array or a function. For performance reasons, we always set this local "specialChars" to a function to which we pass the remaining text and whatever the original vars.specialChars was so that if it's an array, it works with the _findSpecialChars() function.
text, splitText, i, j, l, character, hasTagStart, emojiPair1, emojiPair2, testResult,
container = _doc.createElement("div"),
parent = element.parentNode;
parent.insertBefore(container, element);
container.textContent = element.nodeValue;
parent.removeChild(element);
element = container;
text = _getText(element);
hasTagStart = text.indexOf("<") !== -1;
if (vars.reduceWhiteSpace !== false) {
text = text.replace(_multipleSpacesExp, " ").replace(_stripExp, "");
}
if (hasTagStart) {
text = text.split("<").join("{{LT}}"); //we can't leave "<" in the string, or when we set the innerHTML, it can be interpreted as a node
}
l = text.length;
splitText = ((text.charAt(0) === " ") ? space : "") + wordStart();
for (i = 0; i < l; i++) {
character = text.charAt(i);
if (specialChars && (testResult = specialChars(text.substr(i), vars.specialChars))) { // look for any specialChars that were declared. Remember, they can be passed in like {specialChars:["मी", "पा", "है"]} or a function could be defined instead. Either way, the function should return the number of characters that should be grouped together for this "character".
character = text.substr(i, testResult || 1);
splitText += (chars && character !== " ") ? charStart() + character + "</" + tag + ">" : character;
i += testResult - 1;
} else if (character === wordDelimiter && text.charAt(i-1) !== wordDelimiter && i) {
splitText += wordIsOpen ? wordEnd : "";
wordIsOpen = false;
while (text.charAt(i + 1) === wordDelimiter) { //skip over empty spaces (to avoid making them words)
splitText += space;
i++;
}
if (i === l-1) {
splitText += space;
} else if (text.charAt(i + 1) !== ")") {
splitText += space + wordStart();
wordIsOpen = true;
}
} else if (character === "{" && text.substr(i, 6) === "{{LT}}") {
splitText += chars ? charStart() + "{{LT}}" + "</" + tag + ">" : "{{LT}}";
i += 5;
} else if ((character.charCodeAt(0) >= _emojiStart && character.charCodeAt(0) <= _emojiEnd) || (text.charCodeAt(i+1) >= 0xFE00 && text.charCodeAt(i+1) <= 0xFE0F)) { //special emoji characters use 2 or 4 unicode characters that we must keep together.
emojiPair1 = _emojiPairCode(text.substr(i, 2));
emojiPair2 = _emojiPairCode(text.substr(i + 2, 2));
j = ((emojiPair1 >= _emojiRegionStart && emojiPair1 <= _emojiRegionEnd && emojiPair2 >= _emojiRegionStart && emojiPair2 <= _emojiRegionEnd) || (emojiPair2 >= _emojiModStart && emojiPair2 <= _emojiModEnd)) ? 4 : 2;
splitText += (chars && character !== " ") ? charStart() + text.substr(i, j) + "</" + tag + ">" : text.substr(i, j);
i += j - 1;
} else {
splitText += (chars && character !== " ") ? charStart() + character + "</" + tag + ">" : character;
}
}
element.outerHTML = splitText + (wordIsOpen ? wordEnd : "");
if (hasTagStart) {
_swapText(parent, "{{LT}}", "<"); //note: don't perform this on "element" because that gets replaced with all new elements when we set element.outerHTML.
}
},
_split = function(element, vars, wordStart, charStart) {
var children = _slice(element.childNodes),
l = children.length,
absolute = (vars.position === "absolute" || vars.absolute === true),
i, child;
if (element.nodeType !== 3 || l > 1) {
vars.absolute = false;
for (i = 0; i < l; i++) {
child = children[i];
if (child.nodeType !== 3 || /\S+/.test(child.nodeValue)) {
if (absolute && child.nodeType !== 3 && _getStyle(child, "display", null, true) === "inline") { //if there's a child node that's display:inline, switch it to inline-block so that absolute positioning works properly (most browsers don't report offsetTop/offsetLeft properly inside a <span> for example)
child.style.display = "inline-block";
child.style.position = "relative";
}
child._isSplit = true;
_split(child, vars, wordStart, charStart); //don't split lines on child elements
}
}
vars.absolute = absolute;
element._isSplit = true;
return;
}
_splitRawText(element, vars, wordStart, charStart);
},
p = SplitText.prototype;
p.split = function(vars) {
if (this.isSplit) {
this.revert();
}
this.vars = vars = vars || this.vars;
this._originals.length = this.chars.length = this.words.length = this.lines.length = 0;
var i = this.elements.length,
tag = vars.tag ? vars.tag : (vars.span ? "span" : "div"),
wordStart = _cssClassFunc(vars.wordsClass, tag),
charStart = _cssClassFunc(vars.charsClass, tag),
origHeight, origWidth, e;
//we split in reversed order so that if/when we position:absolute elements, they don't affect the position of the ones after them in the document flow (shifting them up as they're taken out of the document flow).
while (--i > -1) {
e = this.elements[i];
this._originals[i] = e.innerHTML;
origHeight = e.clientHeight;
origWidth = e.clientWidth;
_split(e, vars, wordStart, charStart);
_setPositionsAfterSplit(e, vars, this.chars, this.words, this.lines, origWidth, origHeight);
}
this.chars.reverse();
this.words.reverse();
this.lines.reverse();
this.isSplit = true;
return this;
};
p.revert = function() {
if (!this._originals) {
throw("revert() call wasn't scoped properly.");
}
var i = this._originals.length;
while (--i > -1) {
this.elements[i].innerHTML = this._originals[i];
}
this.chars = [];
this.words = [];
this.lines = [];
this.isSplit = false;
return this;
};
SplitText.selector = window.$ || window.jQuery || function(e) {
var selector = window.$ || window.jQuery;
if (selector) {
SplitText.selector = selector;
return selector(e);
}
return (typeof(document) === "undefined") ? e : (document.querySelectorAll ? document.querySelectorAll(e) : document.getElementById((e.charAt(0) === "#") ? e.substr(1) : e));
};
SplitText.version = "0.7.0";
})(_gsScope);
//export to AMD/RequireJS and CommonJS/Node (precursor to full modular build system coming at a later date)
(function(name) {
"use strict";
var getGlobal = function() {
return (_gsScope.GreenSockGlobals || _gsScope)[name];
};
if (typeof(module) !== "undefined" && module.exports) { //node
module.exports = getGlobal();
} else if (typeof(define) === "function" && define.amd) { //AMD
define([], getGlobal);
}
}("SplitText"));

View File

@ -10,6 +10,7 @@
<script src="../3rdparty/highlight/highlight.pack.js"></script> <script src="../3rdparty/highlight/highlight.pack.js"></script>
<script src="../../dist/iwmlib.3rdparty.js"></script> <script src="../../dist/iwmlib.3rdparty.js"></script>
<script src="../3rdparty/gsap/src/uncompressed/plugins/ThrowPropsPlugin.js"></script>
<script src="../../dist/iwmlib.pixi.js"></script> <script src="../../dist/iwmlib.pixi.js"></script>
<script src="../../dist/iwmlib.js"></script> <script src="../../dist/iwmlib.js"></script>
@ -75,7 +76,8 @@ app.loadTextures([
const bambooList = new List(bamboos, { const bambooList = new List(bamboos, {
orientation: 'horizontal', orientation: 'horizontal',
width: 300 width: 300,
app
}) })
bambooList.x = 200 bambooList.x = 200
bambooList.y = 10 bambooList.y = 10
@ -98,7 +100,8 @@ app.loadTextures([
const textList = new List(texts, { const textList = new List(texts, {
orientation: 'vertical', orientation: 'vertical',
height: 200, height: 200,
padding: 2 padding: 2,
app
}) })
textList.x = 200 textList.x = 200
textList.y = 200 textList.y = 200

View File

@ -39,6 +39,8 @@ export default class List extends PIXI.Container {
* left, center and right. * left, center and right.
* @param {string} [opts.verticalAlign=middle] - The vertical position of the items. Possible values are * @param {string} [opts.verticalAlign=middle] - The vertical position of the items. Possible values are
* top, middle and bottom. * top, middle and bottom.
* @param {PIXI.Application} [opts.app] - The PixiJS Application. Must be set if you want to use the mousewheel to
* scroll your list.
*/ */
constructor(items = [], opts = {}) { constructor(items = [], opts = {}) {
@ -51,7 +53,8 @@ export default class List extends PIXI.Container {
align: 'left', align: 'left',
verticalAlign: 'middle', verticalAlign: 'middle',
width: null, width: null,
height: null height: null,
app: null
}, opts) }, opts)
this.__items = items this.__items = items
@ -97,6 +100,22 @@ export default class List extends PIXI.Container {
this.on('pointercancel', this.onEnd.bind(this)) this.on('pointercancel', this.onEnd.bind(this))
this.on('pointerout', this.onEnd.bind(this)) this.on('pointerout', this.onEnd.bind(this))
this.on('pointerupoutside', this.onEnd.bind(this)) this.on('pointerupoutside', this.onEnd.bind(this))
this.on('scroll', this.onScroll.bind(this))
// mousewheel
//--------------------
if (this.opts.app) {
const app = this.opts.app
app.view.addEventListener('mousewheel', event => {
event.preventDefault()
const bounds = this.mask ? this.mask.getBounds() : this.getBounds()
const x = event.clientX - app.view.getBoundingClientRect().left
const y = event.clientY - app.view.getBoundingClientRect().top
if (bounds.contains(x, y)) {
this.emit('scroll', event)
}
})
}
this.layout() this.layout()
@ -324,12 +343,39 @@ export default class List extends PIXI.Container {
} }
} }
/**
*
* @private
* @param {*} event
*/
onScroll(event) {
this.capture(event)
if (this.opts.orientation === 'horizontal') {
this.container.position.x -= event.deltaX
if (this.container.position.x > 0) {
this.container.position.x = 0
} else if (this.container.position.x + this.innerWidth < this.opts.width) {
this.container.position.x = this.opts.width - this.innerWidth
}
} else {
this.container.position.y -= event.deltaY
if (this.container.position.y > 0) {
this.container.position.y = 0
} else if (this.container.position.y + this.innerHeight < this.opts.height) {
this.container.position.y = this.opts.height - this.innerHeight
}
}
}
/** /**
* Captures an event to inform InteractionMapper about processed events. * Captures an event to inform InteractionMapper about processed events.
* *
* @param {event|PIXI.InteractionEvent} event - The PIXI event to capture. * @param {event|PIXI.InteractionEvent} event - The PIXI event to capture.
*/ */
capture(event) { capture(event) {
Events.capturedBy(event.data.originalEvent, this) const originalEvent = event.data && event.data.originalEvent ? event.data.originalEvent : event
Events.capturedBy(originalEvent, this)
} }
} }