Initial commit.

This commit is contained in:
Sebastian Kupke 2019-03-21 09:57:27 +01:00
parent 9893d5de24
commit 80317c5026
1907 changed files with 502783 additions and 0 deletions

45
3rdparty/3rdparty.js vendored Normal file
View File

@ -0,0 +1,45 @@
/*
* Import often used libraries.
*/
import './jquery.js'
import './optimal-select.js'
import './hammer.js'
import './d3/d3.v4.js'
import './d3/d3.v4.selection-multi.js'
import './highlight/highlight.pack.js'
import './pixi/pixi.js'
import './pixi/pixi-filters.js'
import './pixi/pixi-particles.js'
import './pixi/pixi-compressed-textures.js'
import './greensock/src/uncompressed/jquery.gsap.js'
import './greensock/src/uncompressed/TweenLite.js'
import './greensock/src/uncompressed/TweenMax.js'
import './greensock/src/uncompressed/TimelineLite.js'
import './greensock/src/uncompressed/TimelineMax.js'
import './greensock/src/uncompressed/easing/CustomBounce.js'
import './greensock/src/uncompressed/easing/CustomEase.js'
import './greensock/src/uncompressed/easing/CustomWiggle.js'
import './greensock/src/uncompressed/easing/EasePack.js'
import './greensock/src/uncompressed/plugins/AttrPlugin.js'
import './greensock/src/uncompressed/plugins/BezierPlugin.js'
import './greensock/src/uncompressed/plugins/ColorPropsPlugin.js'
import './greensock/src/uncompressed/plugins/CSSPlugin.js'
import './greensock/src/uncompressed/plugins/CSSRulePlugin.js'
import './greensock/src/uncompressed/plugins/DirectionalRotationPlugin.js'
import './greensock/src/uncompressed/plugins/DrawSVGPlugin.js'
import './greensock/src/uncompressed/plugins/EaselPlugin.js'
import './greensock/src/uncompressed/plugins/EndArrayPlugin.js'
import './greensock/src/uncompressed/plugins/ModifiersPlugin.js'
import './greensock/src/uncompressed/plugins/MorphSVGPlugin.js'
import './greensock/src/uncompressed/plugins/Physics2DPlugin.js'
import './greensock/src/uncompressed/plugins/PhysicsPropsPlugin.js'
import './greensock/src/uncompressed/plugins/PixiPlugin.js'
import './greensock/src/uncompressed/plugins/RaphaelPlugin.js'
import './greensock/src/uncompressed/plugins/RoundPropsPlugin.js'
import './greensock/src/uncompressed/plugins/ScrambleTextPlugin.js'
import './greensock/src/uncompressed/plugins/ScrollToPlugin.js'
import './greensock/src/uncompressed/plugins/TEMPLATE_Plugin.js'
import './greensock/src/uncompressed/plugins/TextPlugin.js'
import './greensock/src/uncompressed/plugins/ThrowPropsPlugin.js'
import './greensock/src/uncompressed/utils/Draggable.js'
import './greensock/src/uncompressed/utils/SplitText.js'

44
3rdparty/LICENSES.txt vendored Normal file
View File

@ -0,0 +1,44 @@
convertPointFromPageToNode.js
https://gist.github.com/Yaffle/1145197
No Licence ==> All Rights Reserved
D3
https://github.com/d3/d3/blob/master/LICENSE
A permissive license similar to the BSD 2-Clause License, but with a 3rd clause that prohibits others from using the name of the project or its contributors to promote derived products without written consent.
Dexie
https://github.com/dfahlander/Dexie.js/blob/master/LICENSE
Apache License 2.0
Greensock
https://greensock.com/licensing
Standard No Charge license allows commercial one-off project. Multiple installations require the "Business Green" license.
Gun DB
https://github.com/amark/gun/blob/master/LICENSE.md
Apache License, Version 2.0
Pixie
https://github.com/usmanhalalit/pixie/blob/master/LICENSE
MIT License
jQuery
https://github.com/jquery/jquery/blob/master/LICENSE.txt
BSD style
PDF
Apache License, Version 2.0

28
3rdparty/PATCHES.md vendored Normal file
View File

@ -0,0 +1,28 @@
# Patches
A listing of all manual changes of 3rdparty files.
## PIXI.js
+ Ensure that a minimal compressed texture example is working and apply changes to deepzoom.js~~ => Patched in pixi.js (Line 5794). + Changed:
```javascript
if (status === STATUS_NONE && text.length > 0)) {`
```
to
```javascript
if (status === STATUS_NONE && (text.length > 0 || xhr.responseURL.endsWith
('.dds'))) { // PATCH: Kupke, 07.08.2017`
```
+ Loading SVG Textures from filesystem
+ Problem: In PIXI 4.7.0 the XHTTP Request of PIXI, when loading an SVG from the filesystem returned an error message and prevented the svg from being displayed.
+ Solution: Just suppress the error when on local filesystem.
+ Location: *BaseTexture.prototype._loadSvgSourceUsingXhr*
```javascript
if(window.location.protocol !== "file:"){ // This condition was added.
if (svgXhr.readyState !== svgXhr.DONE || svgXhr.status !== 200) {
throw new Error('Failed to load SVG using XHR.');
}
}
```

133700
3rdparty/all.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,66 @@
.CodeMirror-simplescroll-horizontal div, .CodeMirror-simplescroll-vertical div {
position: absolute;
background: #ccc;
-moz-box-sizing: border-box;
box-sizing: border-box;
border: 1px solid #bbb;
border-radius: 2px;
}
.CodeMirror-simplescroll-horizontal, .CodeMirror-simplescroll-vertical {
position: absolute;
z-index: 6;
background: #eee;
}
.CodeMirror-simplescroll-horizontal {
bottom: 0; left: 0;
height: 8px;
}
.CodeMirror-simplescroll-horizontal div {
bottom: 0;
height: 100%;
}
.CodeMirror-simplescroll-vertical {
right: 0; top: 0;
width: 8px;
}
.CodeMirror-simplescroll-vertical div {
right: 0;
width: 100%;
}
.CodeMirror-overlayscroll .CodeMirror-scrollbar-filler, .CodeMirror-overlayscroll .CodeMirror-gutter-filler {
display: none;
}
.CodeMirror-overlayscroll-horizontal div, .CodeMirror-overlayscroll-vertical div {
position: absolute;
background: #bcd;
border-radius: 3px;
}
.CodeMirror-overlayscroll-horizontal, .CodeMirror-overlayscroll-vertical {
position: absolute;
z-index: 6;
}
.CodeMirror-overlayscroll-horizontal {
bottom: 0; left: 0;
height: 6px;
}
.CodeMirror-overlayscroll-horizontal div {
bottom: 0;
height: 100%;
}
.CodeMirror-overlayscroll-vertical {
right: 0; top: 0;
width: 6px;
}
.CodeMirror-overlayscroll-vertical div {
right: 0;
width: 100%;
}

View File

@ -0,0 +1,152 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
"use strict";
function Bar(cls, orientation, scroll) {
this.orientation = orientation;
this.scroll = scroll;
this.screen = this.total = this.size = 1;
this.pos = 0;
this.node = document.createElement("div");
this.node.className = cls + "-" + orientation;
this.inner = this.node.appendChild(document.createElement("div"));
var self = this;
CodeMirror.on(this.inner, "mousedown", function(e) {
if (e.which != 1) return;
CodeMirror.e_preventDefault(e);
var axis = self.orientation == "horizontal" ? "pageX" : "pageY";
var start = e[axis], startpos = self.pos;
function done() {
CodeMirror.off(document, "mousemove", move);
CodeMirror.off(document, "mouseup", done);
}
function move(e) {
if (e.which != 1) return done();
self.moveTo(startpos + (e[axis] - start) * (self.total / self.size));
}
CodeMirror.on(document, "mousemove", move);
CodeMirror.on(document, "mouseup", done);
});
CodeMirror.on(this.node, "click", function(e) {
CodeMirror.e_preventDefault(e);
var innerBox = self.inner.getBoundingClientRect(), where;
if (self.orientation == "horizontal")
where = e.clientX < innerBox.left ? -1 : e.clientX > innerBox.right ? 1 : 0;
else
where = e.clientY < innerBox.top ? -1 : e.clientY > innerBox.bottom ? 1 : 0;
self.moveTo(self.pos + where * self.screen);
});
function onWheel(e) {
var moved = CodeMirror.wheelEventPixels(e)[self.orientation == "horizontal" ? "x" : "y"];
var oldPos = self.pos;
self.moveTo(self.pos + moved);
if (self.pos != oldPos) CodeMirror.e_preventDefault(e);
}
CodeMirror.on(this.node, "mousewheel", onWheel);
CodeMirror.on(this.node, "DOMMouseScroll", onWheel);
}
Bar.prototype.setPos = function(pos, force) {
if (pos < 0) pos = 0;
if (pos > this.total - this.screen) pos = this.total - this.screen;
if (!force && pos == this.pos) return false;
this.pos = pos;
this.inner.style[this.orientation == "horizontal" ? "left" : "top"] =
(pos * (this.size / this.total)) + "px";
return true
};
Bar.prototype.moveTo = function(pos) {
if (this.setPos(pos)) this.scroll(pos, this.orientation);
}
var minButtonSize = 10;
Bar.prototype.update = function(scrollSize, clientSize, barSize) {
var sizeChanged = this.screen != clientSize || this.total != scrollSize || this.size != barSize
if (sizeChanged) {
this.screen = clientSize;
this.total = scrollSize;
this.size = barSize;
}
var buttonSize = this.screen * (this.size / this.total);
if (buttonSize < minButtonSize) {
this.size -= minButtonSize - buttonSize;
buttonSize = minButtonSize;
}
this.inner.style[this.orientation == "horizontal" ? "width" : "height"] =
buttonSize + "px";
this.setPos(this.pos, sizeChanged);
};
function SimpleScrollbars(cls, place, scroll) {
this.addClass = cls;
this.horiz = new Bar(cls, "horizontal", scroll);
place(this.horiz.node);
this.vert = new Bar(cls, "vertical", scroll);
place(this.vert.node);
this.width = null;
}
SimpleScrollbars.prototype.update = function(measure) {
if (this.width == null) {
var style = window.getComputedStyle ? window.getComputedStyle(this.horiz.node) : this.horiz.node.currentStyle;
if (style) this.width = parseInt(style.height);
}
var width = this.width || 0;
var needsH = measure.scrollWidth > measure.clientWidth + 1;
var needsV = measure.scrollHeight > measure.clientHeight + 1;
this.vert.node.style.display = needsV ? "block" : "none";
this.horiz.node.style.display = needsH ? "block" : "none";
if (needsV) {
this.vert.update(measure.scrollHeight, measure.clientHeight,
measure.viewHeight - (needsH ? width : 0));
this.vert.node.style.bottom = needsH ? width + "px" : "0";
}
if (needsH) {
this.horiz.update(measure.scrollWidth, measure.clientWidth,
measure.viewWidth - (needsV ? width : 0) - measure.barLeft);
this.horiz.node.style.right = needsV ? width + "px" : "0";
this.horiz.node.style.left = measure.barLeft + "px";
}
return {right: needsV ? width : 0, bottom: needsH ? width : 0};
};
SimpleScrollbars.prototype.setScrollTop = function(pos) {
this.vert.setPos(pos);
};
SimpleScrollbars.prototype.setScrollLeft = function(pos) {
this.horiz.setPos(pos);
};
SimpleScrollbars.prototype.clear = function() {
var parent = this.horiz.node.parentNode;
parent.removeChild(this.horiz.node);
parent.removeChild(this.vert.node);
};
CodeMirror.scrollbarModel.simple = function(place, scroll) {
return new SimpleScrollbars("CodeMirror-simplescroll", place, scroll);
};
CodeMirror.scrollbarModel.overlay = function(place, scroll) {
return new SimpleScrollbars("CodeMirror-overlayscroll", place, scroll);
};
});

346
3rdparty/codemirror/codemirror.css vendored Normal file
View File

@ -0,0 +1,346 @@
/* BASICS */
.CodeMirror {
/* Set height, width, borders, and global font properties here */
font-family: monospace;
height: 300px;
color: black;
direction: ltr;
}
/* PADDING */
.CodeMirror-lines {
padding: 4px 0; /* Vertical padding around content */
}
.CodeMirror pre {
padding: 0 4px; /* Horizontal padding of content */
}
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
background-color: white; /* The little square between H and V scrollbars */
}
/* GUTTER */
.CodeMirror-gutters {
border-right: 1px solid #ddd;
background-color: #f7f7f7;
white-space: nowrap;
}
.CodeMirror-linenumbers {}
.CodeMirror-linenumber {
padding: 0 3px 0 5px;
min-width: 20px;
text-align: right;
color: #999;
white-space: nowrap;
}
.CodeMirror-guttermarker { color: black; }
.CodeMirror-guttermarker-subtle { color: #999; }
/* CURSOR */
.CodeMirror-cursor {
border-left: 1px solid black;
border-right: none;
width: 0;
}
/* Shown when moving in bi-directional text */
.CodeMirror div.CodeMirror-secondarycursor {
border-left: 1px solid silver;
}
.cm-fat-cursor .CodeMirror-cursor {
width: auto;
border: 0 !important;
background: #7e7;
}
.cm-fat-cursor div.CodeMirror-cursors {
z-index: 1;
}
.cm-fat-cursor-mark {
background-color: rgba(20, 255, 20, 0.5);
-webkit-animation: blink 1.06s steps(1) infinite;
-moz-animation: blink 1.06s steps(1) infinite;
animation: blink 1.06s steps(1) infinite;
}
.cm-animate-fat-cursor {
width: auto;
border: 0;
-webkit-animation: blink 1.06s steps(1) infinite;
-moz-animation: blink 1.06s steps(1) infinite;
animation: blink 1.06s steps(1) infinite;
background-color: #7e7;
}
@-moz-keyframes blink {
0% {}
50% { background-color: transparent; }
100% {}
}
@-webkit-keyframes blink {
0% {}
50% { background-color: transparent; }
100% {}
}
@keyframes blink {
0% {}
50% { background-color: transparent; }
100% {}
}
/* Can style cursor different in overwrite (non-insert) mode */
.CodeMirror-overwrite .CodeMirror-cursor {}
.cm-tab { display: inline-block; text-decoration: inherit; }
.CodeMirror-rulers {
position: absolute;
left: 0; right: 0; top: -50px; bottom: -20px;
overflow: hidden;
}
.CodeMirror-ruler {
border-left: 1px solid #ccc;
top: 0; bottom: 0;
position: absolute;
}
/* DEFAULT THEME */
.cm-s-default .cm-header {color: blue;}
.cm-s-default .cm-quote {color: #090;}
.cm-negative {color: #d44;}
.cm-positive {color: #292;}
.cm-header, .cm-strong {font-weight: bold;}
.cm-em {font-style: italic;}
.cm-link {text-decoration: underline;}
.cm-strikethrough {text-decoration: line-through;}
.cm-s-default .cm-keyword {color: #708;}
.cm-s-default .cm-atom {color: #219;}
.cm-s-default .cm-number {color: #164;}
.cm-s-default .cm-def {color: #00f;}
.cm-s-default .cm-variable,
.cm-s-default .cm-punctuation,
.cm-s-default .cm-property,
.cm-s-default .cm-operator {}
.cm-s-default .cm-variable-2 {color: #05a;}
.cm-s-default .cm-variable-3, .cm-s-default .cm-type {color: #085;}
.cm-s-default .cm-comment {color: #a50;}
.cm-s-default .cm-string {color: #a11;}
.cm-s-default .cm-string-2 {color: #f50;}
.cm-s-default .cm-meta {color: #555;}
.cm-s-default .cm-qualifier {color: #555;}
.cm-s-default .cm-builtin {color: #30a;}
.cm-s-default .cm-bracket {color: #997;}
.cm-s-default .cm-tag {color: #170;}
.cm-s-default .cm-attribute {color: #00c;}
.cm-s-default .cm-hr {color: #999;}
.cm-s-default .cm-link {color: #00c;}
.cm-s-default .cm-error {color: #f00;}
.cm-invalidchar {color: #f00;}
.CodeMirror-composing { border-bottom: 2px solid; }
/* Default styles for common addons */
div.CodeMirror span.CodeMirror-matchingbracket {color: #0b0;}
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}
.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }
.CodeMirror-activeline-background {background: #e8f2ff;}
/* STOP */
/* The rest of this file contains styles related to the mechanics of
the editor. You probably shouldn't touch them. */
.CodeMirror {
position: relative;
overflow: hidden;
background: white;
}
.CodeMirror-scroll {
overflow: scroll !important; /* Things will break if this is overridden */
/* 30px is the magic margin used to hide the element's real scrollbars */
/* See overflow: hidden in .CodeMirror */
margin-bottom: -30px; margin-right: -30px;
padding-bottom: 30px;
height: 100%;
outline: none; /* Prevent dragging from highlighting the element */
position: relative;
}
.CodeMirror-sizer {
position: relative;
border-right: 30px solid transparent;
}
/* The fake, visible scrollbars. Used to force redraw during scrolling
before actual scrolling happens, thus preventing shaking and
flickering artifacts. */
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
position: absolute;
z-index: 6;
display: none;
}
.CodeMirror-vscrollbar {
right: 0; top: 0;
overflow-x: hidden;
overflow-y: scroll;
}
.CodeMirror-hscrollbar {
bottom: 0; left: 0;
overflow-y: hidden;
overflow-x: scroll;
}
.CodeMirror-scrollbar-filler {
right: 0; bottom: 0;
}
.CodeMirror-gutter-filler {
left: 0; bottom: 0;
}
.CodeMirror-gutters {
position: absolute; left: 0; top: 0;
min-height: 100%;
z-index: 3;
}
.CodeMirror-gutter {
white-space: normal;
height: 100%;
display: inline-block;
vertical-align: top;
margin-bottom: -30px;
}
.CodeMirror-gutter-wrapper {
position: absolute;
z-index: 4;
background: none !important;
border: none !important;
}
.CodeMirror-gutter-background {
position: absolute;
top: 0; bottom: 0;
z-index: 4;
}
.CodeMirror-gutter-elt {
position: absolute;
cursor: default;
z-index: 4;
}
.CodeMirror-gutter-wrapper ::selection { background-color: transparent }
.CodeMirror-gutter-wrapper ::-moz-selection { background-color: transparent }
.CodeMirror-lines {
cursor: text;
min-height: 1px; /* prevents collapsing before first draw */
}
.CodeMirror pre {
/* Reset some styles that the rest of the page might have set */
-moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
border-width: 0;
background: transparent;
font-family: inherit;
font-size: inherit;
margin: 0;
white-space: pre;
word-wrap: normal;
line-height: inherit;
color: inherit;
z-index: 2;
position: relative;
overflow: visible;
-webkit-tap-highlight-color: transparent;
-webkit-font-variant-ligatures: contextual;
font-variant-ligatures: contextual;
}
.CodeMirror-wrap pre {
word-wrap: break-word;
white-space: pre-wrap;
word-break: normal;
}
.CodeMirror-linebackground {
position: absolute;
left: 0; right: 0; top: 0; bottom: 0;
z-index: 0;
}
.CodeMirror-linewidget {
position: relative;
z-index: 2;
padding: 0.1px; /* Force widget margins to stay inside of the container */
}
.CodeMirror-widget {}
.CodeMirror-rtl pre { direction: rtl; }
.CodeMirror-code {
outline: none;
}
/* Force content-box sizing for the elements where we expect it */
.CodeMirror-scroll,
.CodeMirror-sizer,
.CodeMirror-gutter,
.CodeMirror-gutters,
.CodeMirror-linenumber {
-moz-box-sizing: content-box;
box-sizing: content-box;
}
.CodeMirror-measure {
position: absolute;
width: 100%;
height: 0;
overflow: hidden;
visibility: hidden;
}
.CodeMirror-cursor {
position: absolute;
pointer-events: none;
}
.CodeMirror-measure pre { position: static; }
div.CodeMirror-cursors {
visibility: hidden;
position: relative;
z-index: 3;
}
div.CodeMirror-dragcursors {
visibility: visible;
}
.CodeMirror-focused div.CodeMirror-cursors {
visibility: visible;
}
.CodeMirror-selected { background: #d9d9d9; }
.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
.CodeMirror-crosshair { cursor: crosshair; }
.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }
.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }
.cm-searching {
background-color: #ffa;
background-color: rgba(255, 255, 0, .4);
}
/* Used to force a border model for a node */
.cm-force-border { padding-right: .1px; }
@media print {
/* Hide the cursor when printing */
.CodeMirror div.CodeMirror-cursors {
visibility: hidden;
}
}
/* See issue #2901 */
.cm-tab-wrap-hack:after { content: ''; }
/* Help users use markselection to safely style text background */
span.CodeMirror-selectedtext { background: none; }

9725
3rdparty/codemirror/codemirror.js vendored Normal file

File diff suppressed because it is too large Load Diff

831
3rdparty/codemirror/mode/css/css.js vendored Normal file
View File

@ -0,0 +1,831 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
"use strict";
CodeMirror.defineMode("css", function(config, parserConfig) {
var inline = parserConfig.inline
if (!parserConfig.propertyKeywords) parserConfig = CodeMirror.resolveMode("text/css");
var indentUnit = config.indentUnit,
tokenHooks = parserConfig.tokenHooks,
documentTypes = parserConfig.documentTypes || {},
mediaTypes = parserConfig.mediaTypes || {},
mediaFeatures = parserConfig.mediaFeatures || {},
mediaValueKeywords = parserConfig.mediaValueKeywords || {},
propertyKeywords = parserConfig.propertyKeywords || {},
nonStandardPropertyKeywords = parserConfig.nonStandardPropertyKeywords || {},
fontProperties = parserConfig.fontProperties || {},
counterDescriptors = parserConfig.counterDescriptors || {},
colorKeywords = parserConfig.colorKeywords || {},
valueKeywords = parserConfig.valueKeywords || {},
allowNested = parserConfig.allowNested,
lineComment = parserConfig.lineComment,
supportsAtComponent = parserConfig.supportsAtComponent === true;
var type, override;
function ret(style, tp) { type = tp; return style; }
// Tokenizers
function tokenBase(stream, state) {
var ch = stream.next();
if (tokenHooks[ch]) {
var result = tokenHooks[ch](stream, state);
if (result !== false) return result;
}
if (ch == "@") {
stream.eatWhile(/[\w\\\-]/);
return ret("def", stream.current());
} else if (ch == "=" || (ch == "~" || ch == "|") && stream.eat("=")) {
return ret(null, "compare");
} else if (ch == "\"" || ch == "'") {
state.tokenize = tokenString(ch);
return state.tokenize(stream, state);
} else if (ch == "#") {
stream.eatWhile(/[\w\\\-]/);
return ret("atom", "hash");
} else if (ch == "!") {
stream.match(/^\s*\w*/);
return ret("keyword", "important");
} else if (/\d/.test(ch) || ch == "." && stream.eat(/\d/)) {
stream.eatWhile(/[\w.%]/);
return ret("number", "unit");
} else if (ch === "-") {
if (/[\d.]/.test(stream.peek())) {
stream.eatWhile(/[\w.%]/);
return ret("number", "unit");
} else if (stream.match(/^-[\w\\\-]*/)) {
stream.eatWhile(/[\w\\\-]/);
if (stream.match(/^\s*:/, false))
return ret("variable-2", "variable-definition");
return ret("variable-2", "variable");
} else if (stream.match(/^\w+-/)) {
return ret("meta", "meta");
}
} else if (/[,+>*\/]/.test(ch)) {
return ret(null, "select-op");
} else if (ch == "." && stream.match(/^-?[_a-z][_a-z0-9-]*/i)) {
return ret("qualifier", "qualifier");
} else if (/[:;{}\[\]\(\)]/.test(ch)) {
return ret(null, ch);
} else if (stream.match(/[\w-.]+(?=\()/)) {
if (/^(url(-prefix)?|domain|regexp)$/.test(stream.current().toLowerCase())) {
state.tokenize = tokenParenthesized;
}
return ret("variable callee", "variable");
} else if (/[\w\\\-]/.test(ch)) {
stream.eatWhile(/[\w\\\-]/);
return ret("property", "word");
} else {
return ret(null, null);
}
}
function tokenString(quote) {
return function(stream, state) {
var escaped = false, ch;
while ((ch = stream.next()) != null) {
if (ch == quote && !escaped) {
if (quote == ")") stream.backUp(1);
break;
}
escaped = !escaped && ch == "\\";
}
if (ch == quote || !escaped && quote != ")") state.tokenize = null;
return ret("string", "string");
};
}
function tokenParenthesized(stream, state) {
stream.next(); // Must be '('
if (!stream.match(/\s*[\"\')]/, false))
state.tokenize = tokenString(")");
else
state.tokenize = null;
return ret(null, "(");
}
// Context management
function Context(type, indent, prev) {
this.type = type;
this.indent = indent;
this.prev = prev;
}
function pushContext(state, stream, type, indent) {
state.context = new Context(type, stream.indentation() + (indent === false ? 0 : indentUnit), state.context);
return type;
}
function popContext(state) {
if (state.context.prev)
state.context = state.context.prev;
return state.context.type;
}
function pass(type, stream, state) {
return states[state.context.type](type, stream, state);
}
function popAndPass(type, stream, state, n) {
for (var i = n || 1; i > 0; i--)
state.context = state.context.prev;
return pass(type, stream, state);
}
// Parser
function wordAsValue(stream) {
var word = stream.current().toLowerCase();
if (valueKeywords.hasOwnProperty(word))
override = "atom";
else if (colorKeywords.hasOwnProperty(word))
override = "keyword";
else
override = "variable";
}
var states = {};
states.top = function(type, stream, state) {
if (type == "{") {
return pushContext(state, stream, "block");
} else if (type == "}" && state.context.prev) {
return popContext(state);
} else if (supportsAtComponent && /@component/i.test(type)) {
return pushContext(state, stream, "atComponentBlock");
} else if (/^@(-moz-)?document$/i.test(type)) {
return pushContext(state, stream, "documentTypes");
} else if (/^@(media|supports|(-moz-)?document|import)$/i.test(type)) {
return pushContext(state, stream, "atBlock");
} else if (/^@(font-face|counter-style)/i.test(type)) {
state.stateArg = type;
return "restricted_atBlock_before";
} else if (/^@(-(moz|ms|o|webkit)-)?keyframes$/i.test(type)) {
return "keyframes";
} else if (type && type.charAt(0) == "@") {
return pushContext(state, stream, "at");
} else if (type == "hash") {
override = "builtin";
} else if (type == "word") {
override = "tag";
} else if (type == "variable-definition") {
return "maybeprop";
} else if (type == "interpolation") {
return pushContext(state, stream, "interpolation");
} else if (type == ":") {
return "pseudo";
} else if (allowNested && type == "(") {
return pushContext(state, stream, "parens");
}
return state.context.type;
};
states.block = function(type, stream, state) {
if (type == "word") {
var word = stream.current().toLowerCase();
if (propertyKeywords.hasOwnProperty(word)) {
override = "property";
return "maybeprop";
} else if (nonStandardPropertyKeywords.hasOwnProperty(word)) {
override = "string-2";
return "maybeprop";
} else if (allowNested) {
override = stream.match(/^\s*:(?:\s|$)/, false) ? "property" : "tag";
return "block";
} else {
override += " error";
return "maybeprop";
}
} else if (type == "meta") {
return "block";
} else if (!allowNested && (type == "hash" || type == "qualifier")) {
override = "error";
return "block";
} else {
return states.top(type, stream, state);
}
};
states.maybeprop = function(type, stream, state) {
if (type == ":") return pushContext(state, stream, "prop");
return pass(type, stream, state);
};
states.prop = function(type, stream, state) {
if (type == ";") return popContext(state);
if (type == "{" && allowNested) return pushContext(state, stream, "propBlock");
if (type == "}" || type == "{") return popAndPass(type, stream, state);
if (type == "(") return pushContext(state, stream, "parens");
if (type == "hash" && !/^#([0-9a-fA-f]{3,4}|[0-9a-fA-f]{6}|[0-9a-fA-f]{8})$/.test(stream.current())) {
override += " error";
} else if (type == "word") {
wordAsValue(stream);
} else if (type == "interpolation") {
return pushContext(state, stream, "interpolation");
}
return "prop";
};
states.propBlock = function(type, _stream, state) {
if (type == "}") return popContext(state);
if (type == "word") { override = "property"; return "maybeprop"; }
return state.context.type;
};
states.parens = function(type, stream, state) {
if (type == "{" || type == "}") return popAndPass(type, stream, state);
if (type == ")") return popContext(state);
if (type == "(") return pushContext(state, stream, "parens");
if (type == "interpolation") return pushContext(state, stream, "interpolation");
if (type == "word") wordAsValue(stream);
return "parens";
};
states.pseudo = function(type, stream, state) {
if (type == "meta") return "pseudo";
if (type == "word") {
override = "variable-3";
return state.context.type;
}
return pass(type, stream, state);
};
states.documentTypes = function(type, stream, state) {
if (type == "word" && documentTypes.hasOwnProperty(stream.current())) {
override = "tag";
return state.context.type;
} else {
return states.atBlock(type, stream, state);
}
};
states.atBlock = function(type, stream, state) {
if (type == "(") return pushContext(state, stream, "atBlock_parens");
if (type == "}" || type == ";") return popAndPass(type, stream, state);
if (type == "{") return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top");
if (type == "interpolation") return pushContext(state, stream, "interpolation");
if (type == "word") {
var word = stream.current().toLowerCase();
if (word == "only" || word == "not" || word == "and" || word == "or")
override = "keyword";
else if (mediaTypes.hasOwnProperty(word))
override = "attribute";
else if (mediaFeatures.hasOwnProperty(word))
override = "property";
else if (mediaValueKeywords.hasOwnProperty(word))
override = "keyword";
else if (propertyKeywords.hasOwnProperty(word))
override = "property";
else if (nonStandardPropertyKeywords.hasOwnProperty(word))
override = "string-2";
else if (valueKeywords.hasOwnProperty(word))
override = "atom";
else if (colorKeywords.hasOwnProperty(word))
override = "keyword";
else
override = "error";
}
return state.context.type;
};
states.atComponentBlock = function(type, stream, state) {
if (type == "}")
return popAndPass(type, stream, state);
if (type == "{")
return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top", false);
if (type == "word")
override = "error";
return state.context.type;
};
states.atBlock_parens = function(type, stream, state) {
if (type == ")") return popContext(state);
if (type == "{" || type == "}") return popAndPass(type, stream, state, 2);
return states.atBlock(type, stream, state);
};
states.restricted_atBlock_before = function(type, stream, state) {
if (type == "{")
return pushContext(state, stream, "restricted_atBlock");
if (type == "word" && state.stateArg == "@counter-style") {
override = "variable";
return "restricted_atBlock_before";
}
return pass(type, stream, state);
};
states.restricted_atBlock = function(type, stream, state) {
if (type == "}") {
state.stateArg = null;
return popContext(state);
}
if (type == "word") {
if ((state.stateArg == "@font-face" && !fontProperties.hasOwnProperty(stream.current().toLowerCase())) ||
(state.stateArg == "@counter-style" && !counterDescriptors.hasOwnProperty(stream.current().toLowerCase())))
override = "error";
else
override = "property";
return "maybeprop";
}
return "restricted_atBlock";
};
states.keyframes = function(type, stream, state) {
if (type == "word") { override = "variable"; return "keyframes"; }
if (type == "{") return pushContext(state, stream, "top");
return pass(type, stream, state);
};
states.at = function(type, stream, state) {
if (type == ";") return popContext(state);
if (type == "{" || type == "}") return popAndPass(type, stream, state);
if (type == "word") override = "tag";
else if (type == "hash") override = "builtin";
return "at";
};
states.interpolation = function(type, stream, state) {
if (type == "}") return popContext(state);
if (type == "{" || type == ";") return popAndPass(type, stream, state);
if (type == "word") override = "variable";
else if (type != "variable" && type != "(" && type != ")") override = "error";
return "interpolation";
};
return {
startState: function(base) {
return {tokenize: null,
state: inline ? "block" : "top",
stateArg: null,
context: new Context(inline ? "block" : "top", base || 0, null)};
},
token: function(stream, state) {
if (!state.tokenize && stream.eatSpace()) return null;
var style = (state.tokenize || tokenBase)(stream, state);
if (style && typeof style == "object") {
type = style[1];
style = style[0];
}
override = style;
if (type != "comment")
state.state = states[state.state](type, stream, state);
return override;
},
indent: function(state, textAfter) {
var cx = state.context, ch = textAfter && textAfter.charAt(0);
var indent = cx.indent;
if (cx.type == "prop" && (ch == "}" || ch == ")")) cx = cx.prev;
if (cx.prev) {
if (ch == "}" && (cx.type == "block" || cx.type == "top" ||
cx.type == "interpolation" || cx.type == "restricted_atBlock")) {
// Resume indentation from parent context.
cx = cx.prev;
indent = cx.indent;
} else if (ch == ")" && (cx.type == "parens" || cx.type == "atBlock_parens") ||
ch == "{" && (cx.type == "at" || cx.type == "atBlock")) {
// Dedent relative to current context.
indent = Math.max(0, cx.indent - indentUnit);
}
}
return indent;
},
electricChars: "}",
blockCommentStart: "/*",
blockCommentEnd: "*/",
blockCommentContinue: " * ",
lineComment: lineComment,
fold: "brace"
};
});
function keySet(array) {
var keys = {};
for (var i = 0; i < array.length; ++i) {
keys[array[i].toLowerCase()] = true;
}
return keys;
}
var documentTypes_ = [
"domain", "regexp", "url", "url-prefix"
], documentTypes = keySet(documentTypes_);
var mediaTypes_ = [
"all", "aural", "braille", "handheld", "print", "projection", "screen",
"tty", "tv", "embossed"
], mediaTypes = keySet(mediaTypes_);
var mediaFeatures_ = [
"width", "min-width", "max-width", "height", "min-height", "max-height",
"device-width", "min-device-width", "max-device-width", "device-height",
"min-device-height", "max-device-height", "aspect-ratio",
"min-aspect-ratio", "max-aspect-ratio", "device-aspect-ratio",
"min-device-aspect-ratio", "max-device-aspect-ratio", "color", "min-color",
"max-color", "color-index", "min-color-index", "max-color-index",
"monochrome", "min-monochrome", "max-monochrome", "resolution",
"min-resolution", "max-resolution", "scan", "grid", "orientation",
"device-pixel-ratio", "min-device-pixel-ratio", "max-device-pixel-ratio",
"pointer", "any-pointer", "hover", "any-hover"
], mediaFeatures = keySet(mediaFeatures_);
var mediaValueKeywords_ = [
"landscape", "portrait", "none", "coarse", "fine", "on-demand", "hover",
"interlace", "progressive"
], mediaValueKeywords = keySet(mediaValueKeywords_);
var propertyKeywords_ = [
"align-content", "align-items", "align-self", "alignment-adjust",
"alignment-baseline", "anchor-point", "animation", "animation-delay",
"animation-direction", "animation-duration", "animation-fill-mode",
"animation-iteration-count", "animation-name", "animation-play-state",
"animation-timing-function", "appearance", "azimuth", "backface-visibility",
"background", "background-attachment", "background-blend-mode", "background-clip",
"background-color", "background-image", "background-origin", "background-position",
"background-repeat", "background-size", "baseline-shift", "binding",
"bleed", "bookmark-label", "bookmark-level", "bookmark-state",
"bookmark-target", "border", "border-bottom", "border-bottom-color",
"border-bottom-left-radius", "border-bottom-right-radius",
"border-bottom-style", "border-bottom-width", "border-collapse",
"border-color", "border-image", "border-image-outset",
"border-image-repeat", "border-image-slice", "border-image-source",
"border-image-width", "border-left", "border-left-color",
"border-left-style", "border-left-width", "border-radius", "border-right",
"border-right-color", "border-right-style", "border-right-width",
"border-spacing", "border-style", "border-top", "border-top-color",
"border-top-left-radius", "border-top-right-radius", "border-top-style",
"border-top-width", "border-width", "bottom", "box-decoration-break",
"box-shadow", "box-sizing", "break-after", "break-before", "break-inside",
"caption-side", "caret-color", "clear", "clip", "color", "color-profile", "column-count",
"column-fill", "column-gap", "column-rule", "column-rule-color",
"column-rule-style", "column-rule-width", "column-span", "column-width",
"columns", "content", "counter-increment", "counter-reset", "crop", "cue",
"cue-after", "cue-before", "cursor", "direction", "display",
"dominant-baseline", "drop-initial-after-adjust",
"drop-initial-after-align", "drop-initial-before-adjust",
"drop-initial-before-align", "drop-initial-size", "drop-initial-value",
"elevation", "empty-cells", "fit", "fit-position", "flex", "flex-basis",
"flex-direction", "flex-flow", "flex-grow", "flex-shrink", "flex-wrap",
"float", "float-offset", "flow-from", "flow-into", "font", "font-feature-settings",
"font-family", "font-kerning", "font-language-override", "font-size", "font-size-adjust",
"font-stretch", "font-style", "font-synthesis", "font-variant",
"font-variant-alternates", "font-variant-caps", "font-variant-east-asian",
"font-variant-ligatures", "font-variant-numeric", "font-variant-position",
"font-weight", "grid", "grid-area", "grid-auto-columns", "grid-auto-flow",
"grid-auto-rows", "grid-column", "grid-column-end", "grid-column-gap",
"grid-column-start", "grid-gap", "grid-row", "grid-row-end", "grid-row-gap",
"grid-row-start", "grid-template", "grid-template-areas", "grid-template-columns",
"grid-template-rows", "hanging-punctuation", "height", "hyphens",
"icon", "image-orientation", "image-rendering", "image-resolution",
"inline-box-align", "justify-content", "justify-items", "justify-self", "left", "letter-spacing",
"line-break", "line-height", "line-stacking", "line-stacking-ruby",
"line-stacking-shift", "line-stacking-strategy", "list-style",
"list-style-image", "list-style-position", "list-style-type", "margin",
"margin-bottom", "margin-left", "margin-right", "margin-top",
"marks", "marquee-direction", "marquee-loop",
"marquee-play-count", "marquee-speed", "marquee-style", "max-height",
"max-width", "min-height", "min-width", "mix-blend-mode", "move-to", "nav-down", "nav-index",
"nav-left", "nav-right", "nav-up", "object-fit", "object-position",
"opacity", "order", "orphans", "outline",
"outline-color", "outline-offset", "outline-style", "outline-width",
"overflow", "overflow-style", "overflow-wrap", "overflow-x", "overflow-y",
"padding", "padding-bottom", "padding-left", "padding-right", "padding-top",
"page", "page-break-after", "page-break-before", "page-break-inside",
"page-policy", "pause", "pause-after", "pause-before", "perspective",
"perspective-origin", "pitch", "pitch-range", "place-content", "place-items", "place-self", "play-during", "position",
"presentation-level", "punctuation-trim", "quotes", "region-break-after",
"region-break-before", "region-break-inside", "region-fragment",
"rendering-intent", "resize", "rest", "rest-after", "rest-before", "richness",
"right", "rotation", "rotation-point", "ruby-align", "ruby-overhang",
"ruby-position", "ruby-span", "shape-image-threshold", "shape-inside", "shape-margin",
"shape-outside", "size", "speak", "speak-as", "speak-header",
"speak-numeral", "speak-punctuation", "speech-rate", "stress", "string-set",
"tab-size", "table-layout", "target", "target-name", "target-new",
"target-position", "text-align", "text-align-last", "text-decoration",
"text-decoration-color", "text-decoration-line", "text-decoration-skip",
"text-decoration-style", "text-emphasis", "text-emphasis-color",
"text-emphasis-position", "text-emphasis-style", "text-height",
"text-indent", "text-justify", "text-outline", "text-overflow", "text-shadow",
"text-size-adjust", "text-space-collapse", "text-transform", "text-underline-position",
"text-wrap", "top", "transform", "transform-origin", "transform-style",
"transition", "transition-delay", "transition-duration",
"transition-property", "transition-timing-function", "unicode-bidi",
"user-select", "vertical-align", "visibility", "voice-balance", "voice-duration",
"voice-family", "voice-pitch", "voice-range", "voice-rate", "voice-stress",
"voice-volume", "volume", "white-space", "widows", "width", "will-change", "word-break",
"word-spacing", "word-wrap", "z-index",
// SVG-specific
"clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-color",
"flood-opacity", "lighting-color", "stop-color", "stop-opacity", "pointer-events",
"color-interpolation", "color-interpolation-filters",
"color-rendering", "fill", "fill-opacity", "fill-rule", "image-rendering",
"marker", "marker-end", "marker-mid", "marker-start", "shape-rendering", "stroke",
"stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin",
"stroke-miterlimit", "stroke-opacity", "stroke-width", "text-rendering",
"baseline-shift", "dominant-baseline", "glyph-orientation-horizontal",
"glyph-orientation-vertical", "text-anchor", "writing-mode"
], propertyKeywords = keySet(propertyKeywords_);
var nonStandardPropertyKeywords_ = [
"scrollbar-arrow-color", "scrollbar-base-color", "scrollbar-dark-shadow-color",
"scrollbar-face-color", "scrollbar-highlight-color", "scrollbar-shadow-color",
"scrollbar-3d-light-color", "scrollbar-track-color", "shape-inside",
"searchfield-cancel-button", "searchfield-decoration", "searchfield-results-button",
"searchfield-results-decoration", "zoom"
], nonStandardPropertyKeywords = keySet(nonStandardPropertyKeywords_);
var fontProperties_ = [
"font-family", "src", "unicode-range", "font-variant", "font-feature-settings",
"font-stretch", "font-weight", "font-style"
], fontProperties = keySet(fontProperties_);
var counterDescriptors_ = [
"additive-symbols", "fallback", "negative", "pad", "prefix", "range",
"speak-as", "suffix", "symbols", "system"
], counterDescriptors = keySet(counterDescriptors_);
var colorKeywords_ = [
"aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige",
"bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown",
"burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue",
"cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod",
"darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen",
"darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen",
"darkslateblue", "darkslategray", "darkturquoise", "darkviolet",
"deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick",
"floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite",
"gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew",
"hotpink", "indianred", "indigo", "ivory", "khaki", "lavender",
"lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral",
"lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightpink",
"lightsalmon", "lightseagreen", "lightskyblue", "lightslategray",
"lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta",
"maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple",
"mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise",
"mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin",
"navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered",
"orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred",
"papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue",
"purple", "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown",
"salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue",
"slateblue", "slategray", "snow", "springgreen", "steelblue", "tan",
"teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white",
"whitesmoke", "yellow", "yellowgreen"
], colorKeywords = keySet(colorKeywords_);
var valueKeywords_ = [
"above", "absolute", "activeborder", "additive", "activecaption", "afar",
"after-white-space", "ahead", "alias", "all", "all-scroll", "alphabetic", "alternate",
"always", "amharic", "amharic-abegede", "antialiased", "appworkspace",
"arabic-indic", "armenian", "asterisks", "attr", "auto", "auto-flow", "avoid", "avoid-column", "avoid-page",
"avoid-region", "background", "backwards", "baseline", "below", "bidi-override", "binary",
"bengali", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box",
"both", "bottom", "break", "break-all", "break-word", "bullets", "button", "button-bevel",
"buttonface", "buttonhighlight", "buttonshadow", "buttontext", "calc", "cambodian",
"capitalize", "caps-lock-indicator", "caption", "captiontext", "caret",
"cell", "center", "checkbox", "circle", "cjk-decimal", "cjk-earthly-branch",
"cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote",
"col-resize", "collapse", "color", "color-burn", "color-dodge", "column", "column-reverse",
"compact", "condensed", "contain", "content", "contents",
"content-box", "context-menu", "continuous", "copy", "counter", "counters", "cover", "crop",
"cross", "crosshair", "currentcolor", "cursive", "cyclic", "darken", "dashed", "decimal",
"decimal-leading-zero", "default", "default-button", "dense", "destination-atop",
"destination-in", "destination-out", "destination-over", "devanagari", "difference",
"disc", "discard", "disclosure-closed", "disclosure-open", "document",
"dot-dash", "dot-dot-dash",
"dotted", "double", "down", "e-resize", "ease", "ease-in", "ease-in-out", "ease-out",
"element", "ellipse", "ellipsis", "embed", "end", "ethiopic", "ethiopic-abegede",
"ethiopic-abegede-am-et", "ethiopic-abegede-gez", "ethiopic-abegede-ti-er",
"ethiopic-abegede-ti-et", "ethiopic-halehame-aa-er",
"ethiopic-halehame-aa-et", "ethiopic-halehame-am-et",
"ethiopic-halehame-gez", "ethiopic-halehame-om-et",
"ethiopic-halehame-sid-et", "ethiopic-halehame-so-et",
"ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et", "ethiopic-halehame-tig",
"ethiopic-numeric", "ew-resize", "exclusion", "expanded", "extends", "extra-condensed",
"extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "flex", "flex-end", "flex-start", "footnotes",
"forwards", "from", "geometricPrecision", "georgian", "graytext", "grid", "groove",
"gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hard-light", "hebrew",
"help", "hidden", "hide", "higher", "highlight", "highlighttext",
"hiragana", "hiragana-iroha", "horizontal", "hsl", "hsla", "hue", "icon", "ignore",
"inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite",
"infobackground", "infotext", "inherit", "initial", "inline", "inline-axis",
"inline-block", "inline-flex", "inline-grid", "inline-table", "inset", "inside", "intrinsic", "invert",
"italic", "japanese-formal", "japanese-informal", "justify", "kannada",
"katakana", "katakana-iroha", "keep-all", "khmer",
"korean-hangul-formal", "korean-hanja-formal", "korean-hanja-informal",
"landscape", "lao", "large", "larger", "left", "level", "lighter", "lighten",
"line-through", "linear", "linear-gradient", "lines", "list-item", "listbox", "listitem",
"local", "logical", "loud", "lower", "lower-alpha", "lower-armenian",
"lower-greek", "lower-hexadecimal", "lower-latin", "lower-norwegian",
"lower-roman", "lowercase", "ltr", "luminosity", "malayalam", "match", "matrix", "matrix3d",
"media-controls-background", "media-current-time-display",
"media-fullscreen-button", "media-mute-button", "media-play-button",
"media-return-to-realtime-button", "media-rewind-button",
"media-seek-back-button", "media-seek-forward-button", "media-slider",
"media-sliderthumb", "media-time-remaining-display", "media-volume-slider",
"media-volume-slider-container", "media-volume-sliderthumb", "medium",
"menu", "menulist", "menulist-button", "menulist-text",
"menulist-textfield", "menutext", "message-box", "middle", "min-intrinsic",
"mix", "mongolian", "monospace", "move", "multiple", "multiply", "myanmar", "n-resize",
"narrower", "ne-resize", "nesw-resize", "no-close-quote", "no-drop",
"no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap",
"ns-resize", "numbers", "numeric", "nw-resize", "nwse-resize", "oblique", "octal", "opacity", "open-quote",
"optimizeLegibility", "optimizeSpeed", "oriya", "oromo", "outset",
"outside", "outside-shape", "overlay", "overline", "padding", "padding-box",
"painted", "page", "paused", "persian", "perspective", "plus-darker", "plus-lighter",
"pointer", "polygon", "portrait", "pre", "pre-line", "pre-wrap", "preserve-3d",
"progress", "push-button", "radial-gradient", "radio", "read-only",
"read-write", "read-write-plaintext-only", "rectangle", "region",
"relative", "repeat", "repeating-linear-gradient",
"repeating-radial-gradient", "repeat-x", "repeat-y", "reset", "reverse",
"rgb", "rgba", "ridge", "right", "rotate", "rotate3d", "rotateX", "rotateY",
"rotateZ", "round", "row", "row-resize", "row-reverse", "rtl", "run-in", "running",
"s-resize", "sans-serif", "saturation", "scale", "scale3d", "scaleX", "scaleY", "scaleZ", "screen",
"scroll", "scrollbar", "scroll-position", "se-resize", "searchfield",
"searchfield-cancel-button", "searchfield-decoration",
"searchfield-results-button", "searchfield-results-decoration", "self-start", "self-end",
"semi-condensed", "semi-expanded", "separate", "serif", "show", "sidama",
"simp-chinese-formal", "simp-chinese-informal", "single",
"skew", "skewX", "skewY", "skip-white-space", "slide", "slider-horizontal",
"slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow",
"small", "small-caps", "small-caption", "smaller", "soft-light", "solid", "somali",
"source-atop", "source-in", "source-out", "source-over", "space", "space-around", "space-between", "space-evenly", "spell-out", "square",
"square-button", "start", "static", "status-bar", "stretch", "stroke", "sub",
"subpixel-antialiased", "super", "sw-resize", "symbolic", "symbols", "system-ui", "table",
"table-caption", "table-cell", "table-column", "table-column-group",
"table-footer-group", "table-header-group", "table-row", "table-row-group",
"tamil",
"telugu", "text", "text-bottom", "text-top", "textarea", "textfield", "thai",
"thick", "thin", "threeddarkshadow", "threedface", "threedhighlight",
"threedlightshadow", "threedshadow", "tibetan", "tigre", "tigrinya-er",
"tigrinya-er-abegede", "tigrinya-et", "tigrinya-et-abegede", "to", "top",
"trad-chinese-formal", "trad-chinese-informal", "transform",
"translate", "translate3d", "translateX", "translateY", "translateZ",
"transparent", "ultra-condensed", "ultra-expanded", "underline", "unset", "up",
"upper-alpha", "upper-armenian", "upper-greek", "upper-hexadecimal",
"upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url",
"var", "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted",
"visibleStroke", "visual", "w-resize", "wait", "wave", "wider",
"window", "windowframe", "windowtext", "words", "wrap", "wrap-reverse", "x-large", "x-small", "xor",
"xx-large", "xx-small"
], valueKeywords = keySet(valueKeywords_);
var allWords = documentTypes_.concat(mediaTypes_).concat(mediaFeatures_).concat(mediaValueKeywords_)
.concat(propertyKeywords_).concat(nonStandardPropertyKeywords_).concat(colorKeywords_)
.concat(valueKeywords_);
CodeMirror.registerHelper("hintWords", "css", allWords);
function tokenCComment(stream, state) {
var maybeEnd = false, ch;
while ((ch = stream.next()) != null) {
if (maybeEnd && ch == "/") {
state.tokenize = null;
break;
}
maybeEnd = (ch == "*");
}
return ["comment", "comment"];
}
CodeMirror.defineMIME("text/css", {
documentTypes: documentTypes,
mediaTypes: mediaTypes,
mediaFeatures: mediaFeatures,
mediaValueKeywords: mediaValueKeywords,
propertyKeywords: propertyKeywords,
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
fontProperties: fontProperties,
counterDescriptors: counterDescriptors,
colorKeywords: colorKeywords,
valueKeywords: valueKeywords,
tokenHooks: {
"/": function(stream, state) {
if (!stream.eat("*")) return false;
state.tokenize = tokenCComment;
return tokenCComment(stream, state);
}
},
name: "css"
});
CodeMirror.defineMIME("text/x-scss", {
mediaTypes: mediaTypes,
mediaFeatures: mediaFeatures,
mediaValueKeywords: mediaValueKeywords,
propertyKeywords: propertyKeywords,
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
colorKeywords: colorKeywords,
valueKeywords: valueKeywords,
fontProperties: fontProperties,
allowNested: true,
lineComment: "//",
tokenHooks: {
"/": function(stream, state) {
if (stream.eat("/")) {
stream.skipToEnd();
return ["comment", "comment"];
} else if (stream.eat("*")) {
state.tokenize = tokenCComment;
return tokenCComment(stream, state);
} else {
return ["operator", "operator"];
}
},
":": function(stream) {
if (stream.match(/\s*\{/, false))
return [null, null]
return false;
},
"$": function(stream) {
stream.match(/^[\w-]+/);
if (stream.match(/^\s*:/, false))
return ["variable-2", "variable-definition"];
return ["variable-2", "variable"];
},
"#": function(stream) {
if (!stream.eat("{")) return false;
return [null, "interpolation"];
}
},
name: "css",
helperType: "scss"
});
CodeMirror.defineMIME("text/x-less", {
mediaTypes: mediaTypes,
mediaFeatures: mediaFeatures,
mediaValueKeywords: mediaValueKeywords,
propertyKeywords: propertyKeywords,
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
colorKeywords: colorKeywords,
valueKeywords: valueKeywords,
fontProperties: fontProperties,
allowNested: true,
lineComment: "//",
tokenHooks: {
"/": function(stream, state) {
if (stream.eat("/")) {
stream.skipToEnd();
return ["comment", "comment"];
} else if (stream.eat("*")) {
state.tokenize = tokenCComment;
return tokenCComment(stream, state);
} else {
return ["operator", "operator"];
}
},
"@": function(stream) {
if (stream.eat("{")) return [null, "interpolation"];
if (stream.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/i, false)) return false;
stream.eatWhile(/[\w\\\-]/);
if (stream.match(/^\s*:/, false))
return ["variable-2", "variable-definition"];
return ["variable-2", "variable"];
},
"&": function() {
return ["atom", "atom"];
}
},
name: "css",
helperType: "less"
});
CodeMirror.defineMIME("text/x-gss", {
documentTypes: documentTypes,
mediaTypes: mediaTypes,
mediaFeatures: mediaFeatures,
propertyKeywords: propertyKeywords,
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
fontProperties: fontProperties,
counterDescriptors: counterDescriptors,
colorKeywords: colorKeywords,
valueKeywords: valueKeywords,
supportsAtComponent: true,
tokenHooks: {
"/": function(stream, state) {
if (!stream.eat("*")) return false;
state.tokenize = tokenCComment;
return tokenCComment(stream, state);
}
},
name: "css",
helperType: "gss"
});
});

104
3rdparty/codemirror/mode/css/gss.html vendored Normal file
View File

@ -0,0 +1,104 @@
<!doctype html>
<title>CodeMirror: Closure Stylesheets (GSS) mode</title>
<meta charset="utf-8"/>
<link rel=stylesheet href="../../doc/docs.css">
<link rel="stylesheet" href="../../lib/codemirror.css">
<link rel="stylesheet" href="../../addon/hint/show-hint.css">
<script src="../../lib/codemirror.js"></script>
<script src="css.js"></script>
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="../../addon/hint/show-hint.js"></script>
<script src="../../addon/hint/css-hint.js"></script>
<style>.CodeMirror {background: #f8f8f8;}</style>
<div id=nav>
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
<li><a class=active href="#">Closure Stylesheets (GSS)</a>
</ul>
</div>
<article>
<h2>Closure Stylesheets (GSS) mode</h2>
<form><textarea id="code" name="code">
/* Some example Closure Stylesheets */
@provide 'some.styles';
@require 'other.styles';
@component {
@def FONT_FAMILY "Times New Roman", Georgia, Serif;
@def FONT_SIZE_NORMAL 15px;
@def FONT_NORMAL normal FONT_SIZE_NORMAL FONT_FAMILY;
@def BG_COLOR rgb(235, 239, 249);
@def DIALOG_BORDER_COLOR rgb(107, 144, 218);
@def DIALOG_BG_COLOR BG_COLOR;
@def LEFT_HAND_NAV_WIDTH 180px;
@def LEFT_HAND_NAV_PADDING 3px;
@defmixin size(WIDTH, HEIGHT) {
width: WIDTH;
height: HEIGHT;
}
body {
background-color: BG_COLOR;
margin: 0;
padding: 3em 6em;
font: FONT_NORMAL;
color: #000;
}
#navigation a {
font-weight: bold;
text-decoration: none !important;
}
.dialog {
background-color: DIALOG_BG_COLOR;
border: 1px solid DIALOG_BORDER_COLOR;
}
.content {
position: absolute;
margin-left: add(LEFT_HAND_NAV_PADDING, /* padding left */
LEFT_HAND_NAV_WIDTH,
LEFT_HAND_NAV_PADDING); /* padding right */
}
.logo {
@mixin size(150px, 55px);
background-image: url('http://www.google.com/images/logo_sm.gif');
}
}
</textarea></form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
extraKeys: {"Ctrl-Space": "autocomplete"},
lineNumbers: true,
matchBrackets: true,
mode: "text/x-gss"
});
</script>
<p>A mode for <a href="https://github.com/google/closure-stylesheets">Closure Stylesheets</a> (GSS).</p>
<p><strong>MIME type defined:</strong> <code>text/x-gss</code>.</p>
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#gss_*">normal</a>, <a href="../../test/index.html#verbose,gss_*">verbose</a>.</p>
</article>

View File

@ -0,0 +1,17 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
(function() {
"use strict";
var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-gss");
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "gss"); }
MT("atComponent",
"[def @component] {",
"[tag foo] {",
" [property color]: [keyword black];",
"}",
"}");
})();

75
3rdparty/codemirror/mode/css/index.html vendored Normal file
View File

@ -0,0 +1,75 @@
<!doctype html>
<title>CodeMirror: CSS mode</title>
<meta charset="utf-8"/>
<link rel=stylesheet href="../../doc/docs.css">
<link rel="stylesheet" href="../../lib/codemirror.css">
<link rel="stylesheet" href="../../addon/hint/show-hint.css">
<script src="../../lib/codemirror.js"></script>
<script src="css.js"></script>
<script src="../../addon/hint/show-hint.js"></script>
<script src="../../addon/hint/css-hint.js"></script>
<style>.CodeMirror {background: #f8f8f8;}</style>
<div id=nav>
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
<li><a class=active href="#">CSS</a>
</ul>
</div>
<article>
<h2>CSS mode</h2>
<form><textarea id="code" name="code">
/* Some example CSS */
@import url("something.css");
body {
margin: 0;
padding: 3em 6em;
font-family: tahoma, arial, sans-serif;
color: #000;
}
#navigation a {
font-weight: bold;
text-decoration: none !important;
}
h1 {
font-size: 2.5em;
}
h2 {
font-size: 1.7em;
}
h1:before, h2:before {
content: "::";
}
code {
font-family: courier, monospace;
font-size: 80%;
color: #418A8A;
}
</textarea></form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
extraKeys: {"Ctrl-Space": "autocomplete"}
});
</script>
<p><strong>MIME types defined:</strong> <code>text/css</code>, <code>text/x-scss</code> (<a href="scss.html">demo</a>), <code>text/x-less</code> (<a href="less.html">demo</a>).</p>
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#css_*">normal</a>, <a href="../../test/index.html#verbose,css_*">verbose</a>.</p>
</article>

152
3rdparty/codemirror/mode/css/less.html vendored Normal file
View File

@ -0,0 +1,152 @@
<!doctype html>
<title>CodeMirror: LESS mode</title>
<meta charset="utf-8"/>
<link rel=stylesheet href="../../doc/docs.css">
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="css.js"></script>
<style>.CodeMirror {border: 1px solid #ddd; line-height: 1.2;}</style>
<div id=nav>
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
<li><a class=active href="#">LESS</a>
</ul>
</div>
<article>
<h2>LESS mode</h2>
<form><textarea id="code" name="code">@media screen and (device-aspect-ratio: 16/9) { … }
@media screen and (device-aspect-ratio: 1280/720) { … }
@media screen and (device-aspect-ratio: 2560/1440) { … }
html:lang(fr-be)
tr:nth-child(2n+1) /* represents every odd row of an HTML table */
img:nth-of-type(2n+1) { float: right; }
img:nth-of-type(2n) { float: left; }
body > h2:not(:first-of-type):not(:last-of-type)
html|*:not(:link):not(:visited)
*|*:not(:hover)
p::first-line { text-transform: uppercase }
@namespace foo url(http://www.example.com);
foo|h1 { color: blue } /* first rule */
span[hello="Ocean"][goodbye="Land"]
E[foo]{
padding:65px;
}
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button {
-webkit-appearance: none; // Inner-padding issues in Chrome OSX, Safari 5
}
button::-moz-focus-inner,
input::-moz-focus-inner { // Inner padding and border oddities in FF3/4
padding: 0;
border: 0;
}
.btn {
// reset here as of 2.0.3 due to Recess property order
border-color: #ccc;
border-color: rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);
}
fieldset span button, fieldset span input[type="file"] {
font-size:12px;
font-family:Arial, Helvetica, sans-serif;
}
.rounded-corners (@radius: 5px) {
border-radius: @radius;
-webkit-border-radius: @radius;
-moz-border-radius: @radius;
}
@import url("something.css");
@light-blue: hsl(190, 50%, 65%);
#menu {
position: absolute;
width: 100%;
z-index: 3;
clear: both;
display: block;
background-color: @blue;
height: 42px;
border-top: 2px solid lighten(@alpha-blue, 20%);
border-bottom: 2px solid darken(@alpha-blue, 25%);
.box-shadow(0, 1px, 8px, 0.6);
-moz-box-shadow: 0 0 0 #000; // Because firefox sucks.
&.docked {
background-color: hsla(210, 60%, 40%, 0.4);
}
&:hover {
background-color: @blue;
}
#dropdown {
margin: 0 0 0 117px;
padding: 0;
padding-top: 5px;
display: none;
width: 190px;
border-top: 2px solid @medium;
color: @highlight;
border: 2px solid darken(@medium, 25%);
border-left-color: darken(@medium, 15%);
border-right-color: darken(@medium, 15%);
border-top-width: 0;
background-color: darken(@medium, 10%);
ul {
padding: 0px;
}
li {
font-size: 14px;
display: block;
text-align: left;
padding: 0;
border: 0;
a {
display: block;
padding: 0px 15px;
text-decoration: none;
color: white;
&:hover {
background-color: darken(@medium, 15%);
text-decoration: none;
}
}
}
.border-radius(5px, bottom);
.box-shadow(0, 6px, 8px, 0.5);
}
}
</textarea></form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
matchBrackets: true,
mode: "text/x-less"
});
</script>
<p>The LESS mode is a sub-mode of the <a href="index.html">CSS mode</a> (defined in <code>css.js</code>).</p>
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#less_*">normal</a>, <a href="../../test/index.html#verbose,less_*">verbose</a>.</p>
</article>

View File

@ -0,0 +1,54 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
(function() {
"use strict";
var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-less");
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "less"); }
MT("variable",
"[variable-2 @base]: [atom #f04615];",
"[qualifier .class] {",
" [property width]: [variable&callee percentage]([number 0.5]); [comment // returns `50%`]",
" [property color]: [variable&callee saturate]([variable-2 @base], [number 5%]);",
"}");
MT("amp",
"[qualifier .child], [qualifier .sibling] {",
" [qualifier .parent] [atom &] {",
" [property color]: [keyword black];",
" }",
" [atom &] + [atom &] {",
" [property color]: [keyword red];",
" }",
"}");
MT("mixin",
"[qualifier .mixin] ([variable dark]; [variable-2 @color]) {",
" [property color]: [variable&callee darken]([variable-2 @color], [number 10%]);",
"}",
"[qualifier .mixin] ([variable light]; [variable-2 @color]) {",
" [property color]: [variable&callee lighten]([variable-2 @color], [number 10%]);",
"}",
"[qualifier .mixin] ([variable-2 @_]; [variable-2 @color]) {",
" [property display]: [atom block];",
"}",
"[variable-2 @switch]: [variable light];",
"[qualifier .class] {",
" [qualifier .mixin]([variable-2 @switch]; [atom #888]);",
"}");
MT("nest",
"[qualifier .one] {",
" [def @media] ([property width]: [number 400px]) {",
" [property font-size]: [number 1.2em];",
" [def @media] [attribute print] [keyword and] [property color] {",
" [property color]: [keyword blue];",
" }",
" }",
"}");
MT("interpolation", ".@{[variable foo]} { [property font-weight]: [atom bold]; }");
})();

158
3rdparty/codemirror/mode/css/scss.html vendored Normal file
View File

@ -0,0 +1,158 @@
<!doctype html>
<title>CodeMirror: SCSS mode</title>
<meta charset="utf-8"/>
<link rel=stylesheet href="../../doc/docs.css">
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="css.js"></script>
<style>.CodeMirror {background: #f8f8f8;}</style>
<div id=nav>
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
<li><a class=active href="#">SCSS</a>
</ul>
</div>
<article>
<h2>SCSS mode</h2>
<form><textarea id="code" name="code">
/* Some example SCSS */
@import "compass/css3";
$variable: #333;
$blue: #3bbfce;
$margin: 16px;
.content-navigation {
#nested {
background-color: black;
}
border-color: $blue;
color:
darken($blue, 9%);
}
.border {
padding: $margin / 2;
margin: $margin / 2;
border-color: $blue;
}
@mixin table-base {
th {
text-align: center;
font-weight: bold;
}
td, th {padding: 2px}
}
table.hl {
margin: 2em 0;
td.ln {
text-align: right;
}
}
li {
font: {
family: serif;
weight: bold;
size: 1.2em;
}
}
@mixin left($dist) {
float: left;
margin-left: $dist;
}
#data {
@include left(10px);
@include table-base;
}
.source {
@include flow-into(target);
border: 10px solid green;
margin: 20px;
width: 200px; }
.new-container {
@include flow-from(target);
border: 10px solid red;
margin: 20px;
width: 200px; }
body {
margin: 0;
padding: 3em 6em;
font-family: tahoma, arial, sans-serif;
color: #000;
}
@mixin yellow() {
background: yellow;
}
.big {
font-size: 14px;
}
.nested {
@include border-radius(3px);
@extend .big;
p {
background: whitesmoke;
a {
color: red;
}
}
}
#navigation a {
font-weight: bold;
text-decoration: none !important;
}
h1 {
font-size: 2.5em;
}
h2 {
font-size: 1.7em;
}
h1:before, h2:before {
content: "::";
}
code {
font-family: courier, monospace;
font-size: 80%;
color: #418A8A;
}
</textarea></form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
matchBrackets: true,
mode: "text/x-scss"
});
</script>
<p>The SCSS mode is a sub-mode of the <a href="index.html">CSS mode</a> (defined in <code>css.js</code>).</p>
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#scss_*">normal</a>, <a href="../../test/index.html#verbose,scss_*">verbose</a>.</p>
</article>

View File

@ -0,0 +1,110 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
(function() {
var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-scss");
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "scss"); }
MT('url_with_quotation',
"[tag foo] { [property background]:[variable&callee url]([string test.jpg]) }");
MT('url_with_double_quotes',
"[tag foo] { [property background]:[variable&callee url]([string \"test.jpg\"]) }");
MT('url_with_single_quotes',
"[tag foo] { [property background]:[variable&callee url]([string \'test.jpg\']) }");
MT('string',
"[def @import] [string \"compass/css3\"]");
MT('important_keyword',
"[tag foo] { [property background]:[variable&callee url]([string \'test.jpg\']) [keyword !important] }");
MT('variable',
"[variable-2 $blue]:[atom #333]");
MT('variable_as_attribute',
"[tag foo] { [property color]:[variable-2 $blue] }");
MT('numbers',
"[tag foo] { [property padding]:[number 10px] [number 10] [number 10em] [number 8in] }");
MT('number_percentage',
"[tag foo] { [property width]:[number 80%] }");
MT('selector',
"[builtin #hello][qualifier .world]{}");
MT('singleline_comment',
"[comment // this is a comment]");
MT('multiline_comment',
"[comment /*foobar*/]");
MT('attribute_with_hyphen',
"[tag foo] { [property font-size]:[number 10px] }");
MT('string_after_attribute',
"[tag foo] { [property content]:[string \"::\"] }");
MT('directives',
"[def @include] [qualifier .mixin]");
MT('basic_structure',
"[tag p] { [property background]:[keyword red]; }");
MT('nested_structure',
"[tag p] { [tag a] { [property color]:[keyword red]; } }");
MT('mixin',
"[def @mixin] [tag table-base] {}");
MT('number_without_semicolon',
"[tag p] {[property width]:[number 12]}",
"[tag a] {[property color]:[keyword red];}");
MT('atom_in_nested_block',
"[tag p] { [tag a] { [property color]:[atom #000]; } }");
MT('interpolation_in_property',
"[tag foo] { #{[variable-2 $hello]}:[number 2]; }");
MT('interpolation_in_selector',
"[tag foo]#{[variable-2 $hello]} { [property color]:[atom #000]; }");
MT('interpolation_error',
"[tag foo]#{[variable foo]} { [property color]:[atom #000]; }");
MT("divide_operator",
"[tag foo] { [property width]:[number 4] [operator /] [number 2] }");
MT('nested_structure_with_id_selector',
"[tag p] { [builtin #hello] { [property color]:[keyword red]; } }");
MT('indent_mixin',
"[def @mixin] [tag container] (",
" [variable-2 $a]: [number 10],",
" [variable-2 $b]: [number 10])",
"{}");
MT('indent_nested',
"[tag foo] {",
" [tag bar] {",
" }",
"}");
MT('indent_parentheses',
"[tag foo] {",
" [property color]: [variable&callee darken]([variable-2 $blue],",
" [number 9%]);",
"}");
MT('indent_vardef',
"[variable-2 $name]:",
" [string 'val'];",
"[tag tag] {",
" [tag inner] {",
" [property margin]: [number 3px];",
" }",
"}");
})();

217
3rdparty/codemirror/mode/css/test.js vendored Normal file
View File

@ -0,0 +1,217 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
(function() {
var mode = CodeMirror.getMode({indentUnit: 2}, "css");
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
// Error, because "foobarhello" is neither a known type or property, but
// property was expected (after "and"), and it should be in parentheses.
MT("atMediaUnknownType",
"[def @media] [attribute screen] [keyword and] [error foobarhello] { }");
// Soft error, because "foobarhello" is not a known property or type.
MT("atMediaUnknownProperty",
"[def @media] [attribute screen] [keyword and] ([error foobarhello]) { }");
// Make sure nesting works with media queries
MT("atMediaMaxWidthNested",
"[def @media] [attribute screen] [keyword and] ([property max-width]: [number 25px]) { [tag foo] { } }");
MT("atMediaFeatureValueKeyword",
"[def @media] ([property orientation]: [keyword landscape]) { }");
MT("atMediaUnknownFeatureValueKeyword",
"[def @media] ([property orientation]: [error upsidedown]) { }");
MT("atMediaUppercase",
"[def @MEDIA] ([property orienTAtion]: [keyword landScape]) { }");
MT("tagSelector",
"[tag foo] { }");
MT("classSelector",
"[qualifier .foo-bar_hello] { }");
MT("idSelector",
"[builtin #foo] { [error #foo] }");
MT("tagSelectorUnclosed",
"[tag foo] { [property margin]: [number 0] } [tag bar] { }");
MT("tagStringNoQuotes",
"[tag foo] { [property font-family]: [variable hello] [variable world]; }");
MT("tagStringDouble",
"[tag foo] { [property font-family]: [string \"hello world\"]; }");
MT("tagStringSingle",
"[tag foo] { [property font-family]: [string 'hello world']; }");
MT("tagColorKeyword",
"[tag foo] {",
" [property color]: [keyword black];",
" [property color]: [keyword navy];",
" [property color]: [keyword yellow];",
"}");
MT("tagColorHex3",
"[tag foo] { [property background]: [atom #fff]; }");
MT("tagColorHex4",
"[tag foo] { [property background]: [atom #ffff]; }");
MT("tagColorHex6",
"[tag foo] { [property background]: [atom #ffffff]; }");
MT("tagColorHex8",
"[tag foo] { [property background]: [atom #ffffffff]; }");
MT("tagColorHex5Invalid",
"[tag foo] { [property background]: [atom&error #fffff]; }");
MT("tagColorHexInvalid",
"[tag foo] { [property background]: [atom&error #ffg]; }");
MT("tagNegativeNumber",
"[tag foo] { [property margin]: [number -5px]; }");
MT("tagPositiveNumber",
"[tag foo] { [property padding]: [number 5px]; }");
MT("tagVendor",
"[tag foo] { [meta -foo-][property box-sizing]: [meta -foo-][atom border-box]; }");
MT("tagBogusProperty",
"[tag foo] { [property&error barhelloworld]: [number 0]; }");
MT("tagTwoProperties",
"[tag foo] { [property margin]: [number 0]; [property padding]: [number 0]; }");
MT("tagTwoPropertiesURL",
"[tag foo] { [property background]: [variable&callee url]([string //example.com/foo.png]); [property padding]: [number 0]; }");
MT("indent_tagSelector",
"[tag strong], [tag em] {",
" [property background]: [variable&callee rgba](",
" [number 255], [number 255], [number 0], [number .2]",
" );",
"}");
MT("indent_atMedia",
"[def @media] {",
" [tag foo] {",
" [property color]:",
" [keyword yellow];",
" }",
"}");
MT("indent_comma",
"[tag foo] {",
" [property font-family]: [variable verdana],",
" [atom sans-serif];",
"}");
MT("indent_parentheses",
"[tag foo]:[variable-3 before] {",
" [property background]: [variable&callee url](",
"[string blahblah]",
"[string etc]",
"[string ]) [keyword !important];",
"}");
MT("font_face",
"[def @font-face] {",
" [property font-family]: [string 'myfont'];",
" [error nonsense]: [string 'abc'];",
" [property src]: [variable&callee url]([string http://blah]),",
" [variable&callee url]([string http://foo]);",
"}");
MT("empty_url",
"[def @import] [variable&callee url]() [attribute screen];");
MT("parens",
"[qualifier .foo] {",
" [property background-image]: [variable&callee fade]([atom #000], [number 20%]);",
" [property border-image]: [variable&callee linear-gradient](",
" [atom to] [atom bottom],",
" [variable&callee fade]([atom #000], [number 20%]) [number 0%],",
" [variable&callee fade]([atom #000], [number 20%]) [number 100%]",
" );",
"}");
MT("css_variable",
":[variable-3 root] {",
" [variable-2 --main-color]: [atom #06c];",
"}",
"[tag h1][builtin #foo] {",
" [property color]: [variable&callee var]([variable-2 --main-color]);",
"}");
MT("blank_css_variable",
":[variable-3 root] {",
" [variable-2 --]: [atom #06c];",
"}",
"[tag h1][builtin #foo] {",
" [property color]: [variable&callee var]([variable-2 --]);",
"}");
MT("supports",
"[def @supports] ([keyword not] (([property text-align-last]: [atom justify]) [keyword or] ([meta -moz-][property text-align-last]: [atom justify])) {",
" [property text-align-last]: [atom justify];",
"}");
MT("document",
"[def @document] [variable&callee url]([string http://blah]),",
" [variable&callee url-prefix]([string https://]),",
" [variable&callee domain]([string blah.com]),",
" [variable&callee regexp]([string \".*blah.+\"]) {",
" [builtin #id] {",
" [property background-color]: [keyword white];",
" }",
" [tag foo] {",
" [property font-family]: [variable Verdana], [atom sans-serif];",
" }",
"}");
MT("document_url",
"[def @document] [variable&callee url]([string http://blah]) { [qualifier .class] { } }");
MT("document_urlPrefix",
"[def @document] [variable&callee url-prefix]([string https://]) { [builtin #id] { } }");
MT("document_domain",
"[def @document] [variable&callee domain]([string blah.com]) { [tag foo] { } }");
MT("document_regexp",
"[def @document] [variable&callee regexp]([string \".*blah.+\"]) { [builtin #id] { } }");
MT("counter-style",
"[def @counter-style] [variable binary] {",
" [property system]: [atom numeric];",
" [property symbols]: [number 0] [number 1];",
" [property suffix]: [string \".\"];",
" [property range]: [atom infinite];",
" [property speak-as]: [atom numeric];",
"}");
MT("counter-style-additive-symbols",
"[def @counter-style] [variable simple-roman] {",
" [property system]: [atom additive];",
" [property additive-symbols]: [number 10] [variable X], [number 5] [variable V], [number 1] [variable I];",
" [property range]: [number 1] [number 49];",
"}");
MT("counter-style-use",
"[tag ol][qualifier .roman] { [property list-style]: [variable simple-roman]; }");
MT("counter-style-symbols",
"[tag ol] { [property list-style]: [variable&callee symbols]([atom cyclic] [string \"*\"] [string \"\\2020\"] [string \"\\2021\"] [string \"\\A7\"]); }");
MT("comment-does-not-disrupt",
"[def @font-face] [comment /* foo */] {",
" [property src]: [variable&callee url]([string x]);",
" [property font-family]: [variable One];",
"}")
})();

View File

@ -0,0 +1,152 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"), require("../xml/xml"), require("../javascript/javascript"), require("../css/css"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror", "../xml/xml", "../javascript/javascript", "../css/css"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
"use strict";
var defaultTags = {
script: [
["lang", /(javascript|babel)/i, "javascript"],
["type", /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i, "javascript"],
["type", /./, "text/plain"],
[null, null, "javascript"]
],
style: [
["lang", /^css$/i, "css"],
["type", /^(text\/)?(x-)?(stylesheet|css)$/i, "css"],
["type", /./, "text/plain"],
[null, null, "css"]
]
};
function maybeBackup(stream, pat, style) {
var cur = stream.current(), close = cur.search(pat);
if (close > -1) {
stream.backUp(cur.length - close);
} else if (cur.match(/<\/?$/)) {
stream.backUp(cur.length);
if (!stream.match(pat, false)) stream.match(cur);
}
return style;
}
var attrRegexpCache = {};
function getAttrRegexp(attr) {
var regexp = attrRegexpCache[attr];
if (regexp) return regexp;
return attrRegexpCache[attr] = new RegExp("\\s+" + attr + "\\s*=\\s*('|\")?([^'\"]+)('|\")?\\s*");
}
function getAttrValue(text, attr) {
var match = text.match(getAttrRegexp(attr))
return match ? /^\s*(.*?)\s*$/.exec(match[2])[1] : ""
}
function getTagRegexp(tagName, anchored) {
return new RegExp((anchored ? "^" : "") + "<\/\s*" + tagName + "\s*>", "i");
}
function addTags(from, to) {
for (var tag in from) {
var dest = to[tag] || (to[tag] = []);
var source = from[tag];
for (var i = source.length - 1; i >= 0; i--)
dest.unshift(source[i])
}
}
function findMatchingMode(tagInfo, tagText) {
for (var i = 0; i < tagInfo.length; i++) {
var spec = tagInfo[i];
if (!spec[0] || spec[1].test(getAttrValue(tagText, spec[0]))) return spec[2];
}
}
CodeMirror.defineMode("htmlmixed", function (config, parserConfig) {
var htmlMode = CodeMirror.getMode(config, {
name: "xml",
htmlMode: true,
multilineTagIndentFactor: parserConfig.multilineTagIndentFactor,
multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag
});
var tags = {};
var configTags = parserConfig && parserConfig.tags, configScript = parserConfig && parserConfig.scriptTypes;
addTags(defaultTags, tags);
if (configTags) addTags(configTags, tags);
if (configScript) for (var i = configScript.length - 1; i >= 0; i--)
tags.script.unshift(["type", configScript[i].matches, configScript[i].mode])
function html(stream, state) {
var style = htmlMode.token(stream, state.htmlState), tag = /\btag\b/.test(style), tagName
if (tag && !/[<>\s\/]/.test(stream.current()) &&
(tagName = state.htmlState.tagName && state.htmlState.tagName.toLowerCase()) &&
tags.hasOwnProperty(tagName)) {
state.inTag = tagName + " "
} else if (state.inTag && tag && />$/.test(stream.current())) {
var inTag = /^([\S]+) (.*)/.exec(state.inTag)
state.inTag = null
var modeSpec = stream.current() == ">" && findMatchingMode(tags[inTag[1]], inTag[2])
var mode = CodeMirror.getMode(config, modeSpec)
var endTagA = getTagRegexp(inTag[1], true), endTag = getTagRegexp(inTag[1], false);
state.token = function (stream, state) {
if (stream.match(endTagA, false)) {
state.token = html;
state.localState = state.localMode = null;
return null;
}
return maybeBackup(stream, endTag, state.localMode.token(stream, state.localState));
};
state.localMode = mode;
state.localState = CodeMirror.startState(mode, htmlMode.indent(state.htmlState, "", ""));
} else if (state.inTag) {
state.inTag += stream.current()
if (stream.eol()) state.inTag += " "
}
return style;
};
return {
startState: function () {
var state = CodeMirror.startState(htmlMode);
return {token: html, inTag: null, localMode: null, localState: null, htmlState: state};
},
copyState: function (state) {
var local;
if (state.localState) {
local = CodeMirror.copyState(state.localMode, state.localState);
}
return {token: state.token, inTag: state.inTag,
localMode: state.localMode, localState: local,
htmlState: CodeMirror.copyState(htmlMode, state.htmlState)};
},
token: function (stream, state) {
return state.token(stream, state);
},
indent: function (state, textAfter, line) {
if (!state.localMode || /^\s*<\//.test(textAfter))
return htmlMode.indent(state.htmlState, textAfter, line);
else if (state.localMode.indent)
return state.localMode.indent(state.localState, textAfter, line);
else
return CodeMirror.Pass;
},
innerMode: function (state) {
return {state: state.localState || state.htmlState, mode: state.localMode || htmlMode};
}
};
}, "xml", "javascript", "css");
CodeMirror.defineMIME("text/html", "htmlmixed");
});

View File

@ -0,0 +1,100 @@
<!doctype html>
<title>CodeMirror: HTML mixed mode</title>
<meta charset="utf-8"/>
<link rel=stylesheet href="../../doc/docs.css">
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="../../addon/selection/selection-pointer.js"></script>
<script src="../xml/xml.js"></script>
<script src="../javascript/javascript.js"></script>
<script src="../css/css.js"></script>
<script src="../vbscript/vbscript.js"></script>
<script src="htmlmixed.js"></script>
<style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
<li><a class=active href="#">HTML mixed</a>
</ul>
</div>
<article>
<h2>HTML mixed mode</h2>
<form><textarea id="code" name="code">
<html style="color: green">
<!-- this is a comment -->
<head>
<title>Mixed HTML Example</title>
<style>
h1 {font-family: comic sans; color: #f0f;}
div {background: yellow !important;}
body {
max-width: 50em;
margin: 1em 2em 1em 5em;
}
</style>
</head>
<body>
<h1>Mixed HTML Example</h1>
<script>
function jsFunc(arg1, arg2) {
if (arg1 && arg2) document.body.innerHTML = "achoo";
}
</script>
</body>
</html>
</textarea></form>
<script>
// Define an extended mixed-mode that understands vbscript and
// leaves mustache/handlebars embedded templates in html mode
var mixedMode = {
name: "htmlmixed",
scriptTypes: [{matches: /\/x-handlebars-template|\/x-mustache/i,
mode: null},
{matches: /(text|application)\/(x-)?vb(a|script)/i,
mode: "vbscript"}]
};
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
mode: mixedMode,
selectionPointer: true
});
</script>
<p>The HTML mixed mode depends on the XML, JavaScript, and CSS modes.</p>
<p>It takes an optional mode configuration
option, <code>tags</code>, which can be used to add custom
behavior for specific tags. When given, it should be an object
mapping tag names (for example <code>script</code>) to arrays or
three-element arrays. Those inner arrays indicate [attributeName,
valueRegexp, <a href="../../doc/manual.html#option_mode">modeSpec</a>]
specifications. For example, you could use <code>["type", /^foo$/,
"foo"]</code> to map the attribute <code>type="foo"</code> to
the <code>foo</code> mode. When the first two fields are null
(<code>[null, null, "mode"]</code>), the given mode is used for
any such tag that doesn't match any of the previously given
attributes. For example:</p>
<pre>var myModeSpec = {
name: "htmlmixed",
tags: {
style: [["type", /^text\/(x-)?scss$/, "text/x-scss"],
[null, null, "css"]],
custom: [[null, null, "customMode"]]
}
}</pre>
<p><strong>MIME types defined:</strong> <code>text/html</code>
(redefined, only takes effect if you load this parser after the
XML parser).</p>
</article>

View File

@ -0,0 +1,114 @@
<!doctype html>
<title>CodeMirror: JavaScript mode</title>
<meta charset="utf-8"/>
<link rel=stylesheet href="../../doc/docs.css">
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="../../addon/comment/continuecomment.js"></script>
<script src="../../addon/comment/comment.js"></script>
<script src="javascript.js"></script>
<style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
<li><a class=active href="#">JavaScript</a>
</ul>
</div>
<article>
<h2>JavaScript mode</h2>
<div><textarea id="code" name="code">
// Demo code (the actual new parser character stream implementation)
function StringStream(string) {
this.pos = 0;
this.string = string;
}
StringStream.prototype = {
done: function() {return this.pos >= this.string.length;},
peek: function() {return this.string.charAt(this.pos);},
next: function() {
if (this.pos &lt; this.string.length)
return this.string.charAt(this.pos++);
},
eat: function(match) {
var ch = this.string.charAt(this.pos);
if (typeof match == "string") var ok = ch == match;
else var ok = ch &amp;&amp; match.test ? match.test(ch) : match(ch);
if (ok) {this.pos++; return ch;}
},
eatWhile: function(match) {
var start = this.pos;
while (this.eat(match));
if (this.pos > start) return this.string.slice(start, this.pos);
},
backUp: function(n) {this.pos -= n;},
column: function() {return this.pos;},
eatSpace: function() {
var start = this.pos;
while (/\s/.test(this.string.charAt(this.pos))) this.pos++;
return this.pos - start;
},
match: function(pattern, consume, caseInsensitive) {
if (typeof pattern == "string") {
function cased(str) {return caseInsensitive ? str.toLowerCase() : str;}
if (cased(this.string).indexOf(cased(pattern), this.pos) == this.pos) {
if (consume !== false) this.pos += str.length;
return true;
}
}
else {
var match = this.string.slice(this.pos).match(pattern);
if (match &amp;&amp; consume !== false) this.pos += match[0].length;
return match;
}
}
};
</textarea></div>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
matchBrackets: true,
continueComments: "Enter",
extraKeys: {"Ctrl-Q": "toggleComment"}
});
</script>
<p>
JavaScript mode supports several configuration options:
<ul>
<li><code>json</code> which will set the mode to expect JSON
data rather than a JavaScript program.</li>
<li><code>jsonld</code> which will set the mode to expect
<a href="http://json-ld.org">JSON-LD</a> linked data rather
than a JavaScript program (<a href="json-ld.html">demo</a>).</li>
<li><code>typescript</code> which will activate additional
syntax highlighting and some other things for TypeScript code
(<a href="typescript.html">demo</a>).</li>
<li><code>statementIndent</code> which (given a number) will
determine the amount of indentation to use for statements
continued on a new line.</li>
<li><code>wordCharacters</code>, a regexp that indicates which
characters should be considered part of an identifier.
Defaults to <code>/[\w$]/</code>, which does not handle
non-ASCII identifiers. Can be set to something more elaborate
to improve Unicode support.</li>
</ul>
</p>
<p><strong>MIME types defined:</strong> <code>text/javascript</code>, <code>application/json</code>, <code>application/ld+json</code>, <code>text/typescript</code>, <code>application/typescript</code>.</p>
</article>

View File

@ -0,0 +1,913 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
"use strict";
CodeMirror.defineMode("javascript", function(config, parserConfig) {
var indentUnit = config.indentUnit;
var statementIndent = parserConfig.statementIndent;
var jsonldMode = parserConfig.jsonld;
var jsonMode = parserConfig.json || jsonldMode;
var isTS = parserConfig.typescript;
var wordRE = parserConfig.wordCharacters || /[\w$\xa1-\uffff]/;
// Tokenizer
var keywords = function(){
function kw(type) {return {type: type, style: "keyword"};}
var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c"), D = kw("keyword d");
var operator = kw("operator"), atom = {type: "atom", style: "atom"};
return {
"if": kw("if"), "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B,
"return": D, "break": D, "continue": D, "new": kw("new"), "delete": C, "void": C, "throw": C,
"debugger": kw("debugger"), "var": kw("var"), "const": kw("var"), "let": kw("var"),
"function": kw("function"), "catch": kw("catch"),
"for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
"in": operator, "typeof": operator, "instanceof": operator,
"true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom,
"this": kw("this"), "class": kw("class"), "super": kw("atom"),
"yield": C, "export": kw("export"), "import": kw("import"), "extends": C,
"await": C
};
}();
var isOperatorChar = /[+\-*&%=<>!?|~^@]/;
var isJsonldKeyword = /^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;
function readRegexp(stream) {
var escaped = false, next, inSet = false;
while ((next = stream.next()) != null) {
if (!escaped) {
if (next == "/" && !inSet) return;
if (next == "[") inSet = true;
else if (inSet && next == "]") inSet = false;
}
escaped = !escaped && next == "\\";
}
}
// Used as scratch variables to communicate multiple values without
// consing up tons of objects.
var type, content;
function ret(tp, style, cont) {
type = tp; content = cont;
return style;
}
function tokenBase(stream, state) {
var ch = stream.next();
if (ch == '"' || ch == "'") {
state.tokenize = tokenString(ch);
return state.tokenize(stream, state);
} else if (ch == "." && stream.match(/^\d+(?:[eE][+\-]?\d+)?/)) {
return ret("number", "number");
} else if (ch == "." && stream.match("..")) {
return ret("spread", "meta");
} else if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
return ret(ch);
} else if (ch == "=" && stream.eat(">")) {
return ret("=>", "operator");
} else if (ch == "0" && stream.match(/^(?:x[\da-f]+|o[0-7]+|b[01]+)n?/i)) {
return ret("number", "number");
} else if (/\d/.test(ch)) {
stream.match(/^\d*(?:n|(?:\.\d*)?(?:[eE][+\-]?\d+)?)?/);
return ret("number", "number");
} else if (ch == "/") {
if (stream.eat("*")) {
state.tokenize = tokenComment;
return tokenComment(stream, state);
} else if (stream.eat("/")) {
stream.skipToEnd();
return ret("comment", "comment");
} else if (expressionAllowed(stream, state, 1)) {
readRegexp(stream);
stream.match(/^\b(([gimyus])(?![gimyus]*\2))+\b/);
return ret("regexp", "string-2");
} else {
stream.eat("=");
return ret("operator", "operator", stream.current());
}
} else if (ch == "`") {
state.tokenize = tokenQuasi;
return tokenQuasi(stream, state);
} else if (ch == "#") {
stream.skipToEnd();
return ret("error", "error");
} else if (isOperatorChar.test(ch)) {
if (ch != ">" || !state.lexical || state.lexical.type != ">") {
if (stream.eat("=")) {
if (ch == "!" || ch == "=") stream.eat("=")
} else if (/[<>*+\-]/.test(ch)) {
stream.eat(ch)
if (ch == ">") stream.eat(ch)
}
}
return ret("operator", "operator", stream.current());
} else if (wordRE.test(ch)) {
stream.eatWhile(wordRE);
var word = stream.current()
if (state.lastType != ".") {
if (keywords.propertyIsEnumerable(word)) {
var kw = keywords[word]
return ret(kw.type, kw.style, word)
}
if (word == "async" && stream.match(/^(\s|\/\*.*?\*\/)*[\[\(\w]/, false))
return ret("async", "keyword", word)
}
return ret("variable", "variable", word)
}
}
function tokenString(quote) {
return function(stream, state) {
var escaped = false, next;
if (jsonldMode && stream.peek() == "@" && stream.match(isJsonldKeyword)){
state.tokenize = tokenBase;
return ret("jsonld-keyword", "meta");
}
while ((next = stream.next()) != null) {
if (next == quote && !escaped) break;
escaped = !escaped && next == "\\";
}
if (!escaped) state.tokenize = tokenBase;
return ret("string", "string");
};
}
function tokenComment(stream, state) {
var maybeEnd = false, ch;
while (ch = stream.next()) {
if (ch == "/" && maybeEnd) {
state.tokenize = tokenBase;
break;
}
maybeEnd = (ch == "*");
}
return ret("comment", "comment");
}
function tokenQuasi(stream, state) {
var escaped = false, next;
while ((next = stream.next()) != null) {
if (!escaped && (next == "`" || next == "$" && stream.eat("{"))) {
state.tokenize = tokenBase;
break;
}
escaped = !escaped && next == "\\";
}
return ret("quasi", "string-2", stream.current());
}
var brackets = "([{}])";
// This is a crude lookahead trick to try and notice that we're
// parsing the argument patterns for a fat-arrow function before we
// actually hit the arrow token. It only works if the arrow is on
// the same line as the arguments and there's no strange noise
// (comments) in between. Fallback is to only notice when we hit the
// arrow, and not declare the arguments as locals for the arrow
// body.
function findFatArrow(stream, state) {
if (state.fatArrowAt) state.fatArrowAt = null;
var arrow = stream.string.indexOf("=>", stream.start);
if (arrow < 0) return;
if (isTS) { // Try to skip TypeScript return type declarations after the arguments
var m = /:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(stream.string.slice(stream.start, arrow))
if (m) arrow = m.index
}
var depth = 0, sawSomething = false;
for (var pos = arrow - 1; pos >= 0; --pos) {
var ch = stream.string.charAt(pos);
var bracket = brackets.indexOf(ch);
if (bracket >= 0 && bracket < 3) {
if (!depth) { ++pos; break; }
if (--depth == 0) { if (ch == "(") sawSomething = true; break; }
} else if (bracket >= 3 && bracket < 6) {
++depth;
} else if (wordRE.test(ch)) {
sawSomething = true;
} else if (/["'\/]/.test(ch)) {
return;
} else if (sawSomething && !depth) {
++pos;
break;
}
}
if (sawSomething && !depth) state.fatArrowAt = pos;
}
// Parser
var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true, "this": true, "jsonld-keyword": true};
function JSLexical(indented, column, type, align, prev, info) {
this.indented = indented;
this.column = column;
this.type = type;
this.prev = prev;
this.info = info;
if (align != null) this.align = align;
}
function inScope(state, varname) {
for (var v = state.localVars; v; v = v.next)
if (v.name == varname) return true;
for (var cx = state.context; cx; cx = cx.prev) {
for (var v = cx.vars; v; v = v.next)
if (v.name == varname) return true;
}
}
function parseJS(state, style, type, content, stream) {
var cc = state.cc;
// Communicate our context to the combinators.
// (Less wasteful than consing up a hundred closures on every call.)
cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc; cx.style = style;
if (!state.lexical.hasOwnProperty("align"))
state.lexical.align = true;
while(true) {
var combinator = cc.length ? cc.pop() : jsonMode ? expression : statement;
if (combinator(type, content)) {
while(cc.length && cc[cc.length - 1].lex)
cc.pop()();
if (cx.marked) return cx.marked;
if (type == "variable" && inScope(state, content)) return "variable-2";
return style;
}
}
}
// Combinator utils
var cx = {state: null, column: null, marked: null, cc: null};
function pass() {
for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);
}
function cont() {
pass.apply(null, arguments);
return true;
}
function inList(name, list) {
for (var v = list; v; v = v.next) if (v.name == name) return true
return false;
}
function register(varname) {
var state = cx.state;
cx.marked = "def";
if (state.context) {
if (state.lexical.info == "var" && state.context && state.context.block) {
// FIXME function decls are also not block scoped
var newContext = registerVarScoped(varname, state.context)
if (newContext != null) {
state.context = newContext
return
}
} else if (!inList(varname, state.localVars)) {
state.localVars = new Var(varname, state.localVars)
return
}
}
// Fall through means this is global
if (parserConfig.globalVars && !inList(varname, state.globalVars))
state.globalVars = new Var(varname, state.globalVars)
}
function registerVarScoped(varname, context) {
if (!context) {
return null
} else if (context.block) {
var inner = registerVarScoped(varname, context.prev)
if (!inner) return null
if (inner == context.prev) return context
return new Context(inner, context.vars, true)
} else if (inList(varname, context.vars)) {
return context
} else {
return new Context(context.prev, new Var(varname, context.vars), false)
}
}
function isModifier(name) {
return name == "public" || name == "private" || name == "protected" || name == "abstract" || name == "readonly"
}
// Combinators
function Context(prev, vars, block) { this.prev = prev; this.vars = vars; this.block = block }
function Var(name, next) { this.name = name; this.next = next }
var defaultVars = new Var("this", new Var("arguments", null))
function pushcontext() {
cx.state.context = new Context(cx.state.context, cx.state.localVars, false)
cx.state.localVars = defaultVars
}
function pushblockcontext() {
cx.state.context = new Context(cx.state.context, cx.state.localVars, true)
cx.state.localVars = null
}
function popcontext() {
cx.state.localVars = cx.state.context.vars
cx.state.context = cx.state.context.prev
}
popcontext.lex = true
function pushlex(type, info) {
var result = function() {
var state = cx.state, indent = state.indented;
if (state.lexical.type == "stat") indent = state.lexical.indented;
else for (var outer = state.lexical; outer && outer.type == ")" && outer.align; outer = outer.prev)
indent = outer.indented;
state.lexical = new JSLexical(indent, cx.stream.column(), type, null, state.lexical, info);
};
result.lex = true;
return result;
}
function poplex() {
var state = cx.state;
if (state.lexical.prev) {
if (state.lexical.type == ")")
state.indented = state.lexical.indented;
state.lexical = state.lexical.prev;
}
}
poplex.lex = true;
function expect(wanted) {
function exp(type) {
if (type == wanted) return cont();
else if (wanted == ";" || type == "}" || type == ")" || type == "]") return pass();
else return cont(exp);
};
return exp;
}
function statement(type, value) {
if (type == "var") return cont(pushlex("vardef", value), vardef, expect(";"), poplex);
if (type == "keyword a") return cont(pushlex("form"), parenExpr, statement, poplex);
if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
if (type == "keyword d") return cx.stream.match(/^\s*$/, false) ? cont() : cont(pushlex("stat"), maybeexpression, expect(";"), poplex);
if (type == "debugger") return cont(expect(";"));
if (type == "{") return cont(pushlex("}"), pushblockcontext, block, poplex, popcontext);
if (type == ";") return cont();
if (type == "if") {
if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex)
cx.state.cc.pop()();
return cont(pushlex("form"), parenExpr, statement, poplex, maybeelse);
}
if (type == "function") return cont(functiondef);
if (type == "for") return cont(pushlex("form"), forspec, statement, poplex);
if (type == "class" || (isTS && value == "interface")) {
cx.marked = "keyword"
return cont(pushlex("form", type == "class" ? type : value), className, poplex)
}
if (type == "variable") {
if (isTS && value == "declare") {
cx.marked = "keyword"
return cont(statement)
} else if (isTS && (value == "module" || value == "enum" || value == "type") && cx.stream.match(/^\s*\w/, false)) {
cx.marked = "keyword"
if (value == "enum") return cont(enumdef);
else if (value == "type") return cont(typeexpr, expect("operator"), typeexpr, expect(";"));
else return cont(pushlex("form"), pattern, expect("{"), pushlex("}"), block, poplex, poplex)
} else if (isTS && value == "namespace") {
cx.marked = "keyword"
return cont(pushlex("form"), expression, statement, poplex)
} else if (isTS && value == "abstract") {
cx.marked = "keyword"
return cont(statement)
} else {
return cont(pushlex("stat"), maybelabel);
}
}
if (type == "switch") return cont(pushlex("form"), parenExpr, expect("{"), pushlex("}", "switch"), pushblockcontext,
block, poplex, poplex, popcontext);
if (type == "case") return cont(expression, expect(":"));
if (type == "default") return cont(expect(":"));
if (type == "catch") return cont(pushlex("form"), pushcontext, maybeCatchBinding, statement, poplex, popcontext);
if (type == "export") return cont(pushlex("stat"), afterExport, poplex);
if (type == "import") return cont(pushlex("stat"), afterImport, poplex);
if (type == "async") return cont(statement)
if (value == "@") return cont(expression, statement)
return pass(pushlex("stat"), expression, expect(";"), poplex);
}
function maybeCatchBinding(type) {
if (type == "(") return cont(funarg, expect(")"))
}
function expression(type, value) {
return expressionInner(type, value, false);
}
function expressionNoComma(type, value) {
return expressionInner(type, value, true);
}
function parenExpr(type) {
if (type != "(") return pass()
return cont(pushlex(")"), expression, expect(")"), poplex)
}
function expressionInner(type, value, noComma) {
if (cx.state.fatArrowAt == cx.stream.start) {
var body = noComma ? arrowBodyNoComma : arrowBody;
if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, expect("=>"), body, popcontext);
else if (type == "variable") return pass(pushcontext, pattern, expect("=>"), body, popcontext);
}
var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma;
if (atomicTypes.hasOwnProperty(type)) return cont(maybeop);
if (type == "function") return cont(functiondef, maybeop);
if (type == "class" || (isTS && value == "interface")) { cx.marked = "keyword"; return cont(pushlex("form"), classExpression, poplex); }
if (type == "keyword c" || type == "async") return cont(noComma ? expressionNoComma : expression);
if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeop);
if (type == "operator" || type == "spread") return cont(noComma ? expressionNoComma : expression);
if (type == "[") return cont(pushlex("]"), arrayLiteral, poplex, maybeop);
if (type == "{") return contCommasep(objprop, "}", null, maybeop);
if (type == "quasi") return pass(quasi, maybeop);
if (type == "new") return cont(maybeTarget(noComma));
if (type == "import") return cont(expression);
return cont();
}
function maybeexpression(type) {
if (type.match(/[;\}\)\],]/)) return pass();
return pass(expression);
}
function maybeoperatorComma(type, value) {
if (type == ",") return cont(expression);
return maybeoperatorNoComma(type, value, false);
}
function maybeoperatorNoComma(type, value, noComma) {
var me = noComma == false ? maybeoperatorComma : maybeoperatorNoComma;
var expr = noComma == false ? expression : expressionNoComma;
if (type == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext);
if (type == "operator") {
if (/\+\+|--/.test(value) || isTS && value == "!") return cont(me);
if (isTS && value == "<" && cx.stream.match(/^([^>]|<.*?>)*>\s*\(/, false))
return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, me);
if (value == "?") return cont(expression, expect(":"), expr);
return cont(expr);
}
if (type == "quasi") { return pass(quasi, me); }
if (type == ";") return;
if (type == "(") return contCommasep(expressionNoComma, ")", "call", me);
if (type == ".") return cont(property, me);
if (type == "[") return cont(pushlex("]"), maybeexpression, expect("]"), poplex, me);
if (isTS && value == "as") { cx.marked = "keyword"; return cont(typeexpr, me) }
if (type == "regexp") {
cx.state.lastType = cx.marked = "operator"
cx.stream.backUp(cx.stream.pos - cx.stream.start - 1)
return cont(expr)
}
}
function quasi(type, value) {
if (type != "quasi") return pass();
if (value.slice(value.length - 2) != "${") return cont(quasi);
return cont(expression, continueQuasi);
}
function continueQuasi(type) {
if (type == "}") {
cx.marked = "string-2";
cx.state.tokenize = tokenQuasi;
return cont(quasi);
}
}
function arrowBody(type) {
findFatArrow(cx.stream, cx.state);
return pass(type == "{" ? statement : expression);
}
function arrowBodyNoComma(type) {
findFatArrow(cx.stream, cx.state);
return pass(type == "{" ? statement : expressionNoComma);
}
function maybeTarget(noComma) {
return function(type) {
if (type == ".") return cont(noComma ? targetNoComma : target);
else if (type == "variable" && isTS) return cont(maybeTypeArgs, noComma ? maybeoperatorNoComma : maybeoperatorComma)
else return pass(noComma ? expressionNoComma : expression);
};
}
function target(_, value) {
if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorComma); }
}
function targetNoComma(_, value) {
if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorNoComma); }
}
function maybelabel(type) {
if (type == ":") return cont(poplex, statement);
return pass(maybeoperatorComma, expect(";"), poplex);
}
function property(type) {
if (type == "variable") {cx.marked = "property"; return cont();}
}
function objprop(type, value) {
if (type == "async") {
cx.marked = "property";
return cont(objprop);
} else if (type == "variable" || cx.style == "keyword") {
cx.marked = "property";
if (value == "get" || value == "set") return cont(getterSetter);
var m // Work around fat-arrow-detection complication for detecting typescript typed arrow params
if (isTS && cx.state.fatArrowAt == cx.stream.start && (m = cx.stream.match(/^\s*:\s*/, false)))
cx.state.fatArrowAt = cx.stream.pos + m[0].length
return cont(afterprop);
} else if (type == "number" || type == "string") {
cx.marked = jsonldMode ? "property" : (cx.style + " property");
return cont(afterprop);
} else if (type == "jsonld-keyword") {
return cont(afterprop);
} else if (isTS && isModifier(value)) {
cx.marked = "keyword"
return cont(objprop)
} else if (type == "[") {
return cont(expression, maybetype, expect("]"), afterprop);
} else if (type == "spread") {
return cont(expressionNoComma, afterprop);
} else if (value == "*") {
cx.marked = "keyword";
return cont(objprop);
} else if (type == ":") {
return pass(afterprop)
}
}
function getterSetter(type) {
if (type != "variable") return pass(afterprop);
cx.marked = "property";
return cont(functiondef);
}
function afterprop(type) {
if (type == ":") return cont(expressionNoComma);
if (type == "(") return pass(functiondef);
}
function commasep(what, end, sep) {
function proceed(type, value) {
if (sep ? sep.indexOf(type) > -1 : type == ",") {
var lex = cx.state.lexical;
if (lex.info == "call") lex.pos = (lex.pos || 0) + 1;
return cont(function(type, value) {
if (type == end || value == end) return pass()
return pass(what)
}, proceed);
}
if (type == end || value == end) return cont();
if (sep && sep.indexOf(";") > -1) return pass(what)
return cont(expect(end));
}
return function(type, value) {
if (type == end || value == end) return cont();
return pass(what, proceed);
};
}
function contCommasep(what, end, info) {
for (var i = 3; i < arguments.length; i++)
cx.cc.push(arguments[i]);
return cont(pushlex(end, info), commasep(what, end), poplex);
}
function block(type) {
if (type == "}") return cont();
return pass(statement, block);
}
function maybetype(type, value) {
if (isTS) {
if (type == ":") return cont(typeexpr);
if (value == "?") return cont(maybetype);
}
}
function mayberettype(type) {
if (isTS && type == ":") {
if (cx.stream.match(/^\s*\w+\s+is\b/, false)) return cont(expression, isKW, typeexpr)
else return cont(typeexpr)
}
}
function isKW(_, value) {
if (value == "is") {
cx.marked = "keyword"
return cont()
}
}
function typeexpr(type, value) {
if (value == "keyof" || value == "typeof") {
cx.marked = "keyword"
return cont(value == "keyof" ? typeexpr : expressionNoComma)
}
if (type == "variable" || value == "void") {
cx.marked = "type"
return cont(afterType)
}
if (type == "string" || type == "number" || type == "atom") return cont(afterType);
if (type == "[") return cont(pushlex("]"), commasep(typeexpr, "]", ","), poplex, afterType)
if (type == "{") return cont(pushlex("}"), commasep(typeprop, "}", ",;"), poplex, afterType)
if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType)
if (type == "<") return cont(commasep(typeexpr, ">"), typeexpr)
}
function maybeReturnType(type) {
if (type == "=>") return cont(typeexpr)
}
function typeprop(type, value) {
if (type == "variable" || cx.style == "keyword") {
cx.marked = "property"
return cont(typeprop)
} else if (value == "?") {
return cont(typeprop)
} else if (type == ":") {
return cont(typeexpr)
} else if (type == "[") {
return cont(expression, maybetype, expect("]"), typeprop)
} else if (type == "(") {
return cont(pushlex(")"), commasep(funarg, ")"), poplex, typeprop)
}
}
function typearg(type, value) {
if (type == "variable" && cx.stream.match(/^\s*[?:]/, false) || value == "?") return cont(typearg)
if (type == ":") return cont(typeexpr)
return pass(typeexpr)
}
function afterType(type, value) {
if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType)
if (value == "|" || type == "." || value == "&") return cont(typeexpr)
if (type == "[") return cont(expect("]"), afterType)
if (value == "extends" || value == "implements") { cx.marked = "keyword"; return cont(typeexpr) }
}
function maybeTypeArgs(_, value) {
if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType)
}
function typeparam() {
return pass(typeexpr, maybeTypeDefault)
}
function maybeTypeDefault(_, value) {
if (value == "=") return cont(typeexpr)
}
function vardef(_, value) {
if (value == "enum") {cx.marked = "keyword"; return cont(enumdef)}
return pass(pattern, maybetype, maybeAssign, vardefCont);
}
function pattern(type, value) {
if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(pattern) }
if (type == "variable") { register(value); return cont(); }
if (type == "spread") return cont(pattern);
if (type == "[") return contCommasep(eltpattern, "]");
if (type == "{") return contCommasep(proppattern, "}");
}
function proppattern(type, value) {
if (type == "variable" && !cx.stream.match(/^\s*:/, false)) {
register(value);
return cont(maybeAssign);
}
if (type == "variable") cx.marked = "property";
if (type == "spread") return cont(pattern);
if (type == "}") return pass();
if (type == "[") return cont(expression, expect(']'), expect(':'), proppattern);
return cont(expect(":"), pattern, maybeAssign);
}
function eltpattern() {
return pass(pattern, maybeAssign)
}
function maybeAssign(_type, value) {
if (value == "=") return cont(expressionNoComma);
}
function vardefCont(type) {
if (type == ",") return cont(vardef);
}
function maybeelse(type, value) {
if (type == "keyword b" && value == "else") return cont(pushlex("form", "else"), statement, poplex);
}
function forspec(type, value) {
if (value == "await") return cont(forspec);
if (type == "(") return cont(pushlex(")"), forspec1, expect(")"), poplex);
}
function forspec1(type) {
if (type == "var") return cont(vardef, expect(";"), forspec2);
if (type == ";") return cont(forspec2);
if (type == "variable") return cont(formaybeinof);
return pass(expression, expect(";"), forspec2);
}
function formaybeinof(_type, value) {
if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression); }
return cont(maybeoperatorComma, forspec2);
}
function forspec2(type, value) {
if (type == ";") return cont(forspec3);
if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression); }
return pass(expression, expect(";"), forspec3);
}
function forspec3(type) {
if (type != ")") cont(expression);
}
function functiondef(type, value) {
if (value == "*") {cx.marked = "keyword"; return cont(functiondef);}
if (type == "variable") {register(value); return cont(functiondef);}
if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, statement, popcontext);
if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondef)
}
function functiondecl(type, value) {
if (value == "*") {cx.marked = "keyword"; return cont(functiondecl);}
if (type == "variable") {register(value); return cont(functiondecl);}
if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, popcontext);
if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondecl)
}
function funarg(type, value) {
if (value == "@") cont(expression, funarg)
if (type == "spread") return cont(funarg);
if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(funarg); }
return pass(pattern, maybetype, maybeAssign);
}
function classExpression(type, value) {
// Class expressions may have an optional name.
if (type == "variable") return className(type, value);
return classNameAfter(type, value);
}
function className(type, value) {
if (type == "variable") {register(value); return cont(classNameAfter);}
}
function classNameAfter(type, value) {
if (value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, classNameAfter)
if (value == "extends" || value == "implements" || (isTS && type == ",")) {
if (value == "implements") cx.marked = "keyword";
return cont(isTS ? typeexpr : expression, classNameAfter);
}
if (type == "{") return cont(pushlex("}"), classBody, poplex);
}
function classBody(type, value) {
if (type == "async" ||
(type == "variable" &&
(value == "static" || value == "get" || value == "set" || (isTS && isModifier(value))) &&
cx.stream.match(/^\s+[\w$\xa1-\uffff]/, false))) {
cx.marked = "keyword";
return cont(classBody);
}
if (type == "variable" || cx.style == "keyword") {
cx.marked = "property";
return cont(isTS ? classfield : functiondef, classBody);
}
if (type == "[")
return cont(expression, maybetype, expect("]"), isTS ? classfield : functiondef, classBody)
if (value == "*") {
cx.marked = "keyword";
return cont(classBody);
}
if (type == ";") return cont(classBody);
if (type == "}") return cont();
if (value == "@") return cont(expression, classBody)
}
function classfield(type, value) {
if (value == "?") return cont(classfield)
if (type == ":") return cont(typeexpr, maybeAssign)
if (value == "=") return cont(expressionNoComma)
var context = cx.state.lexical.prev, isInterface = context && context.info == "interface"
return pass(isInterface ? functiondecl : functiondef)
}
function afterExport(type, value) {
if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); }
if (value == "default") { cx.marked = "keyword"; return cont(expression, expect(";")); }
if (type == "{") return cont(commasep(exportField, "}"), maybeFrom, expect(";"));
return pass(statement);
}
function exportField(type, value) {
if (value == "as") { cx.marked = "keyword"; return cont(expect("variable")); }
if (type == "variable") return pass(expressionNoComma, exportField);
}
function afterImport(type) {
if (type == "string") return cont();
if (type == "(") return pass(expression);
return pass(importSpec, maybeMoreImports, maybeFrom);
}
function importSpec(type, value) {
if (type == "{") return contCommasep(importSpec, "}");
if (type == "variable") register(value);
if (value == "*") cx.marked = "keyword";
return cont(maybeAs);
}
function maybeMoreImports(type) {
if (type == ",") return cont(importSpec, maybeMoreImports)
}
function maybeAs(_type, value) {
if (value == "as") { cx.marked = "keyword"; return cont(importSpec); }
}
function maybeFrom(_type, value) {
if (value == "from") { cx.marked = "keyword"; return cont(expression); }
}
function arrayLiteral(type) {
if (type == "]") return cont();
return pass(commasep(expressionNoComma, "]"));
}
function enumdef() {
return pass(pushlex("form"), pattern, expect("{"), pushlex("}"), commasep(enummember, "}"), poplex, poplex)
}
function enummember() {
return pass(pattern, maybeAssign);
}
function isContinuedStatement(state, textAfter) {
return state.lastType == "operator" || state.lastType == "," ||
isOperatorChar.test(textAfter.charAt(0)) ||
/[,.]/.test(textAfter.charAt(0));
}
function expressionAllowed(stream, state, backUp) {
return state.tokenize == tokenBase &&
/^(?:operator|sof|keyword [bcd]|case|new|export|default|spread|[\[{}\(,;:]|=>)$/.test(state.lastType) ||
(state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0))))
}
// Interface
return {
startState: function(basecolumn) {
var state = {
tokenize: tokenBase,
lastType: "sof",
cc: [],
lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
localVars: parserConfig.localVars,
context: parserConfig.localVars && new Context(null, null, false),
indented: basecolumn || 0
};
if (parserConfig.globalVars && typeof parserConfig.globalVars == "object")
state.globalVars = parserConfig.globalVars;
return state;
},
token: function(stream, state) {
if (stream.sol()) {
if (!state.lexical.hasOwnProperty("align"))
state.lexical.align = false;
state.indented = stream.indentation();
findFatArrow(stream, state);
}
if (state.tokenize != tokenComment && stream.eatSpace()) return null;
var style = state.tokenize(stream, state);
if (type == "comment") return style;
state.lastType = type == "operator" && (content == "++" || content == "--") ? "incdec" : type;
return parseJS(state, style, type, content, stream);
},
indent: function(state, textAfter) {
if (state.tokenize == tokenComment) return CodeMirror.Pass;
if (state.tokenize != tokenBase) return 0;
var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical, top
// Kludge to prevent 'maybelse' from blocking lexical scope pops
if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) {
var c = state.cc[i];
if (c == poplex) lexical = lexical.prev;
else if (c != maybeelse) break;
}
while ((lexical.type == "stat" || lexical.type == "form") &&
(firstChar == "}" || ((top = state.cc[state.cc.length - 1]) &&
(top == maybeoperatorComma || top == maybeoperatorNoComma) &&
!/^[,\.=+\-*:?[\(]/.test(textAfter))))
lexical = lexical.prev;
if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat")
lexical = lexical.prev;
var type = lexical.type, closing = firstChar == type;
if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? lexical.info.length + 1 : 0);
else if (type == "form" && firstChar == "{") return lexical.indented;
else if (type == "form") return lexical.indented + indentUnit;
else if (type == "stat")
return lexical.indented + (isContinuedStatement(state, textAfter) ? statementIndent || indentUnit : 0);
else if (lexical.info == "switch" && !closing && parserConfig.doubleIndentSwitch != false)
return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit);
else if (lexical.align) return lexical.column + (closing ? 0 : 1);
else return lexical.indented + (closing ? 0 : indentUnit);
},
electricInput: /^\s*(?:case .*?:|default:|\{|\})$/,
blockCommentStart: jsonMode ? null : "/*",
blockCommentEnd: jsonMode ? null : "*/",
blockCommentContinue: jsonMode ? null : " * ",
lineComment: jsonMode ? null : "//",
fold: "brace",
closeBrackets: "()[]{}''\"\"``",
helperType: jsonMode ? "json" : "javascript",
jsonldMode: jsonldMode,
jsonMode: jsonMode,
expressionAllowed: expressionAllowed,
skipExpression: function(state) {
var top = state.cc[state.cc.length - 1]
if (top == expression || top == expressionNoComma) state.cc.pop()
}
};
});
CodeMirror.registerHelper("wordChars", "javascript", /[\w$]/);
CodeMirror.defineMIME("text/javascript", "javascript");
CodeMirror.defineMIME("text/ecmascript", "javascript");
CodeMirror.defineMIME("application/javascript", "javascript");
CodeMirror.defineMIME("application/x-javascript", "javascript");
CodeMirror.defineMIME("application/ecmascript", "javascript");
CodeMirror.defineMIME("application/json", {name: "javascript", json: true});
CodeMirror.defineMIME("application/x-json", {name: "javascript", json: true});
CodeMirror.defineMIME("application/ld+json", {name: "javascript", jsonld: true});
CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true });
CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true });
});

View File

@ -0,0 +1,72 @@
<!doctype html>
<title>CodeMirror: JSON-LD mode</title>
<meta charset="utf-8"/>
<link rel=stylesheet href="../../doc/docs.css">
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="../../addon/comment/continuecomment.js"></script>
<script src="../../addon/comment/comment.js"></script>
<script src="javascript.js"></script>
<style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id="nav">
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"/></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
<li><a class=active href="#">JSON-LD</a>
</ul>
</div>
<article>
<h2>JSON-LD mode</h2>
<div><textarea id="code" name="code">
{
"@context": {
"name": "http://schema.org/name",
"description": "http://schema.org/description",
"image": {
"@id": "http://schema.org/image",
"@type": "@id"
},
"geo": "http://schema.org/geo",
"latitude": {
"@id": "http://schema.org/latitude",
"@type": "xsd:float"
},
"longitude": {
"@id": "http://schema.org/longitude",
"@type": "xsd:float"
},
"xsd": "http://www.w3.org/2001/XMLSchema#"
},
"name": "The Empire State Building",
"description": "The Empire State Building is a 102-story landmark in New York City.",
"image": "http://www.civil.usherbrooke.ca/cours/gci215a/empire-state-building.jpg",
"geo": {
"latitude": "40.75",
"longitude": "73.98"
}
}
</textarea></div>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
matchBrackets: true,
autoCloseBrackets: true,
mode: "application/ld+json",
lineWrapping: true
});
</script>
<p>This is a specialization of the <a href="index.html">JavaScript mode</a>.</p>
</article>

View File

@ -0,0 +1,494 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
(function() {
var mode = CodeMirror.getMode({indentUnit: 2}, "javascript");
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
MT("locals",
"[keyword function] [def foo]([def a], [def b]) { [keyword var] [def c] [operator =] [number 10]; [keyword return] [variable-2 a] [operator +] [variable-2 c] [operator +] [variable d]; }");
MT("comma-and-binop",
"[keyword function](){ [keyword var] [def x] [operator =] [number 1] [operator +] [number 2], [def y]; }");
MT("destructuring",
"([keyword function]([def a], [[[def b], [def c] ]]) {",
" [keyword let] {[def d], [property foo]: [def c][operator =][number 10], [def x]} [operator =] [variable foo]([variable-2 a]);",
" [[[variable-2 c], [variable y] ]] [operator =] [variable-2 c];",
"})();");
MT("destructure_trailing_comma",
"[keyword let] {[def a], [def b],} [operator =] [variable foo];",
"[keyword let] [def c];"); // Parser still in good state?
MT("class_body",
"[keyword class] [def Foo] {",
" [property constructor]() {}",
" [property sayName]() {",
" [keyword return] [string-2 `foo${][variable foo][string-2 }oo`];",
" }",
"}");
MT("class",
"[keyword class] [def Point] [keyword extends] [variable SuperThing] {",
" [keyword get] [property prop]() { [keyword return] [number 24]; }",
" [property constructor]([def x], [def y]) {",
" [keyword super]([string 'something']);",
" [keyword this].[property x] [operator =] [variable-2 x];",
" }",
"}");
MT("anonymous_class_expression",
"[keyword const] [def Adder] [operator =] [keyword class] [keyword extends] [variable Arithmetic] {",
" [property add]([def a], [def b]) {}",
"};");
MT("named_class_expression",
"[keyword const] [def Subber] [operator =] [keyword class] [def Subtract] {",
" [property sub]([def a], [def b]) {}",
"};");
MT("class_async_method",
"[keyword class] [def Foo] {",
" [property sayName1]() {}",
" [keyword async] [property sayName2]() {}",
"}");
MT("import",
"[keyword function] [def foo]() {",
" [keyword import] [def $] [keyword from] [string 'jquery'];",
" [keyword import] { [def encrypt], [def decrypt] } [keyword from] [string 'crypto'];",
"}");
MT("import_trailing_comma",
"[keyword import] {[def foo], [def bar],} [keyword from] [string 'baz']")
MT("import_dynamic",
"[keyword import]([string 'baz']).[property then]")
MT("import_dynamic",
"[keyword const] [def t] [operator =] [keyword import]([string 'baz']).[property then]")
MT("const",
"[keyword function] [def f]() {",
" [keyword const] [[ [def a], [def b] ]] [operator =] [[ [number 1], [number 2] ]];",
"}");
MT("for/of",
"[keyword for]([keyword let] [def of] [keyword of] [variable something]) {}");
MT("for await",
"[keyword for] [keyword await]([keyword let] [def of] [keyword of] [variable something]) {}");
MT("generator",
"[keyword function*] [def repeat]([def n]) {",
" [keyword for]([keyword var] [def i] [operator =] [number 0]; [variable-2 i] [operator <] [variable-2 n]; [operator ++][variable-2 i])",
" [keyword yield] [variable-2 i];",
"}");
MT("let_scoping",
"[keyword function] [def scoped]([def n]) {",
" { [keyword var] [def i]; } [variable-2 i];",
" { [keyword let] [def j]; [variable-2 j]; } [variable j];",
" [keyword if] ([atom true]) { [keyword const] [def k]; [variable-2 k]; } [variable k];",
"}");
MT("switch_scoping",
"[keyword switch] ([variable x]) {",
" [keyword default]:",
" [keyword let] [def j];",
" [keyword return] [variable-2 j]",
"}",
"[variable j];")
MT("leaving_scope",
"[keyword function] [def a]() {",
" {",
" [keyword const] [def x] [operator =] [number 1]",
" [keyword if] ([atom true]) {",
" [keyword let] [def y] [operator =] [number 2]",
" [keyword var] [def z] [operator =] [number 3]",
" [variable console].[property log]([variable-2 x], [variable-2 y], [variable-2 z])",
" }",
" [variable console].[property log]([variable-2 x], [variable y], [variable-2 z])",
" }",
" [variable console].[property log]([variable x], [variable y], [variable-2 z])",
"}")
MT("quotedStringAddition",
"[keyword let] [def f] [operator =] [variable a] [operator +] [string 'fatarrow'] [operator +] [variable c];");
MT("quotedFatArrow",
"[keyword let] [def f] [operator =] [variable a] [operator +] [string '=>'] [operator +] [variable c];");
MT("fatArrow",
"[variable array].[property filter]([def a] [operator =>] [variable-2 a] [operator +] [number 1]);",
"[variable a];", // No longer in scope
"[keyword let] [def f] [operator =] ([[ [def a], [def b] ]], [def c]) [operator =>] [variable-2 a] [operator +] [variable-2 c];",
"[variable c];");
MT("spread",
"[keyword function] [def f]([def a], [meta ...][def b]) {",
" [variable something]([variable-2 a], [meta ...][variable-2 b]);",
"}");
MT("quasi",
"[variable re][string-2 `fofdlakj${][variable x] [operator +] ([variable re][string-2 `foo`]) [operator +] [number 1][string-2 }fdsa`] [operator +] [number 2]");
MT("quasi_no_function",
"[variable x] [operator =] [string-2 `fofdlakj${][variable x] [operator +] [string-2 `foo`] [operator +] [number 1][string-2 }fdsa`] [operator +] [number 2]");
MT("indent_statement",
"[keyword var] [def x] [operator =] [number 10]",
"[variable x] [operator +=] [variable y] [operator +]",
" [atom Infinity]",
"[keyword debugger];");
MT("indent_if",
"[keyword if] ([number 1])",
" [keyword break];",
"[keyword else] [keyword if] ([number 2])",
" [keyword continue];",
"[keyword else]",
" [number 10];",
"[keyword if] ([number 1]) {",
" [keyword break];",
"} [keyword else] [keyword if] ([number 2]) {",
" [keyword continue];",
"} [keyword else] {",
" [number 10];",
"}");
MT("indent_for",
"[keyword for] ([keyword var] [def i] [operator =] [number 0];",
" [variable i] [operator <] [number 100];",
" [variable i][operator ++])",
" [variable doSomething]([variable i]);",
"[keyword debugger];");
MT("indent_c_style",
"[keyword function] [def foo]()",
"{",
" [keyword debugger];",
"}");
MT("indent_else",
"[keyword for] (;;)",
" [keyword if] ([variable foo])",
" [keyword if] ([variable bar])",
" [number 1];",
" [keyword else]",
" [number 2];",
" [keyword else]",
" [number 3];");
MT("indent_funarg",
"[variable foo]([number 10000],",
" [keyword function]([def a]) {",
" [keyword debugger];",
"};");
MT("indent_below_if",
"[keyword for] (;;)",
" [keyword if] ([variable foo])",
" [number 1];",
"[number 2];");
MT("indent_semicolonless_if",
"[keyword function] [def foo]() {",
" [keyword if] ([variable x])",
" [variable foo]()",
"}")
MT("indent_semicolonless_if_with_statement",
"[keyword function] [def foo]() {",
" [keyword if] ([variable x])",
" [variable foo]()",
" [variable bar]()",
"}")
MT("multilinestring",
"[keyword var] [def x] [operator =] [string 'foo\\]",
"[string bar'];");
MT("scary_regexp",
"[string-2 /foo[[/]]bar/];");
MT("indent_strange_array",
"[keyword var] [def x] [operator =] [[",
" [number 1],,",
" [number 2],",
"]];",
"[number 10];");
MT("param_default",
"[keyword function] [def foo]([def x] [operator =] [string-2 `foo${][number 10][string-2 }bar`]) {",
" [keyword return] [variable-2 x];",
"}");
MT(
"param_destructuring",
"[keyword function] [def foo]([def x] [operator =] [string-2 `foo${][number 10][string-2 }bar`]) {",
" [keyword return] [variable-2 x];",
"}");
MT("new_target",
"[keyword function] [def F]([def target]) {",
" [keyword if] ([variable-2 target] [operator &&] [keyword new].[keyword target].[property name]) {",
" [keyword return] [keyword new]",
" .[keyword target];",
" }",
"}");
MT("async",
"[keyword async] [keyword function] [def foo]([def args]) { [keyword return] [atom true]; }");
MT("async_assignment",
"[keyword const] [def foo] [operator =] [keyword async] [keyword function] ([def args]) { [keyword return] [atom true]; };");
MT("async_object",
"[keyword let] [def obj] [operator =] { [property async]: [atom false] };");
// async be highlighet as keyword and foo as def, but it requires potentially expensive look-ahead. See #4173
MT("async_object_function",
"[keyword let] [def obj] [operator =] { [property async] [property foo]([def args]) { [keyword return] [atom true]; } };");
MT("async_object_properties",
"[keyword let] [def obj] [operator =] {",
" [property prop1]: [keyword async] [keyword function] ([def args]) { [keyword return] [atom true]; },",
" [property prop2]: [keyword async] [keyword function] ([def args]) { [keyword return] [atom true]; },",
" [property prop3]: [keyword async] [keyword function] [def prop3]([def args]) { [keyword return] [atom true]; },",
"};");
MT("async_arrow",
"[keyword const] [def foo] [operator =] [keyword async] ([def args]) [operator =>] { [keyword return] [atom true]; };");
MT("async_jquery",
"[variable $].[property ajax]({",
" [property url]: [variable url],",
" [property async]: [atom true],",
" [property method]: [string 'GET']",
"});");
MT("async_variable",
"[keyword const] [def async] [operator =] {[property a]: [number 1]};",
"[keyword const] [def foo] [operator =] [string-2 `bar ${][variable async].[property a][string-2 }`];")
MT("bigint", "[number 1n] [operator +] [number 0x1afn] [operator +] [number 0o064n] [operator +] [number 0b100n];")
MT("async_comment",
"[keyword async] [comment /**/] [keyword function] [def foo]([def args]) { [keyword return] [atom true]; }");
MT("indent_switch",
"[keyword switch] ([variable x]) {",
" [keyword default]:",
" [keyword return] [number 2]",
"}")
MT("regexp_corner_case",
"[operator +]{} [operator /] [atom undefined];",
"[[[meta ...][string-2 /\\//] ]];",
"[keyword void] [string-2 /\\//];",
"[keyword do] [string-2 /\\//]; [keyword while] ([number 0]);",
"[keyword if] ([number 0]) {} [keyword else] [string-2 /\\//];",
"[string-2 `${][variable async][operator ++][string-2 }//`];",
"[string-2 `${]{} [operator /] [string-2 /\\//}`];")
MT("return_eol",
"[keyword return]",
"{} [string-2 /5/]")
var ts_mode = CodeMirror.getMode({indentUnit: 2}, "application/typescript")
function TS(name) {
test.mode(name, ts_mode, Array.prototype.slice.call(arguments, 1))
}
TS("typescript_extend_type",
"[keyword class] [def Foo] [keyword extends] [type Some][operator <][type Type][operator >] {}")
TS("typescript_arrow_type",
"[keyword let] [def x]: ([variable arg]: [type Type]) [operator =>] [type ReturnType]")
TS("typescript_class",
"[keyword class] [def Foo] {",
" [keyword public] [keyword static] [property main]() {}",
" [keyword private] [property _foo]: [type string];",
"}")
TS("typescript_literal_types",
"[keyword import] [keyword *] [keyword as] [def Sequelize] [keyword from] [string 'sequelize'];",
"[keyword interface] [def MyAttributes] {",
" [property truthy]: [string 'true'] [operator |] [number 1] [operator |] [atom true];",
" [property falsy]: [string 'false'] [operator |] [number 0] [operator |] [atom false];",
"}",
"[keyword interface] [def MyInstance] [keyword extends] [type Sequelize].[type Instance] [operator <] [type MyAttributes] [operator >] {",
" [property rawAttributes]: [type MyAttributes];",
" [property truthy]: [string 'true'] [operator |] [number 1] [operator |] [atom true];",
" [property falsy]: [string 'false'] [operator |] [number 0] [operator |] [atom false];",
"}")
TS("typescript_extend_operators",
"[keyword export] [keyword interface] [def UserModel] [keyword extends]",
" [type Sequelize].[type Model] [operator <] [type UserInstance], [type UserAttributes] [operator >] {",
" [property findById]: (",
" [variable userId]: [type number]",
" ) [operator =>] [type Promise] [operator <] [type Array] [operator <] { [property id], [property name] } [operator >>];",
" [property updateById]: (",
" [variable userId]: [type number],",
" [variable isActive]: [type boolean]",
" ) [operator =>] [type Promise] [operator <] [type AccountHolderNotificationPreferenceInstance] [operator >];",
" }")
TS("typescript_interface_with_const",
"[keyword const] [def hello]: {",
" [property prop1][operator ?]: [type string];",
" [property prop2][operator ?]: [type string];",
"} [operator =] {};")
TS("typescript_double_extend",
"[keyword export] [keyword interface] [def UserAttributes] {",
" [property id][operator ?]: [type number];",
" [property createdAt][operator ?]: [type Date];",
"}",
"[keyword export] [keyword interface] [def UserInstance] [keyword extends] [type Sequelize].[type Instance][operator <][type UserAttributes][operator >], [type UserAttributes] {",
" [property id]: [type number];",
" [property createdAt]: [type Date];",
"}");
TS("typescript_index_signature",
"[keyword interface] [def A] {",
" [[ [variable prop]: [type string] ]]: [type any];",
" [property prop1]: [type any];",
"}");
TS("typescript_generic_class",
"[keyword class] [def Foo][operator <][type T][operator >] {",
" [property bar]() {}",
" [property foo](): [type Foo] {}",
"}")
TS("typescript_type_when_keyword",
"[keyword export] [keyword type] [type AB] [operator =] [type A] [operator |] [type B];",
"[keyword type] [type Flags] [operator =] {",
" [property p1]: [type string];",
" [property p2]: [type boolean];",
"};")
TS("typescript_type_when_not_keyword",
"[keyword class] [def HasType] {",
" [property type]: [type string];",
" [property constructor]([def type]: [type string]) {",
" [keyword this].[property type] [operator =] [variable-2 type];",
" }",
" [property setType]({ [def type] }: { [property type]: [type string]; }) {",
" [keyword this].[property type] [operator =] [variable-2 type];",
" }",
"}")
TS("typescript_function_generics",
"[keyword function] [def a]() {}",
"[keyword function] [def b][operator <][type IA] [keyword extends] [type object], [type IB] [keyword extends] [type object][operator >]() {}",
"[keyword function] [def c]() {}")
TS("typescript_complex_return_type",
"[keyword function] [def A]() {",
" [keyword return] [keyword this].[property property];",
"}",
"[keyword function] [def B](): [type Promise][operator <]{ [[ [variable key]: [type string] ]]: [type any] } [operator |] [atom null][operator >] {",
" [keyword return] [keyword this].[property property];",
"}")
TS("typescript_complex_type_casting",
"[keyword const] [def giftpay] [operator =] [variable config].[property get]([string 'giftpay']) [keyword as] { [[ [variable platformUuid]: [type string] ]]: { [property version]: [type number]; [property apiCode]: [type string]; } };")
TS("typescript_keyof",
"[keyword function] [def x][operator <][type T] [keyword extends] [keyword keyof] [type X][operator >]([def a]: [type T]) {",
" [keyword return]")
TS("typescript_new_typeargs",
"[keyword let] [def x] [operator =] [keyword new] [variable Map][operator <][type string], [type Date][operator >]([string-2 `foo${][variable bar][string-2 }`])")
TS("modifiers",
"[keyword class] [def Foo] {",
" [keyword public] [keyword abstract] [property bar]() {}",
" [property constructor]([keyword readonly] [keyword private] [def x]) {}",
"}")
TS("arrow prop",
"({[property a]: [def p] [operator =>] [variable-2 p]})")
TS("generic in function call",
"[keyword this].[property a][operator <][type Type][operator >]([variable foo]);",
"[keyword this].[property a][operator <][variable Type][operator >][variable foo];")
TS("type guard",
"[keyword class] [def Appler] {",
" [keyword static] [property assertApple]([def fruit]: [type Fruit]): [variable-2 fruit] [keyword is] [type Apple] {",
" [keyword if] ([operator !]([variable-2 fruit] [keyword instanceof] [variable Apple]))",
" [keyword throw] [keyword new] [variable Error]();",
" }",
"}")
TS("type as variable",
"[variable type] [operator =] [variable x] [keyword as] [type Bar];");
TS("enum body",
"[keyword export] [keyword const] [keyword enum] [def CodeInspectionResultType] {",
" [def ERROR] [operator =] [string 'problem_type_error'],",
" [def WARNING] [operator =] [string 'problem_type_warning'],",
" [def META],",
"}")
TS("parenthesized type",
"[keyword class] [def Foo] {",
" [property x] [operator =] [keyword new] [variable A][operator <][type B], [type string][operator |](() [operator =>] [type void])[operator >]();",
" [keyword private] [property bar]();",
"}")
TS("abstract class",
"[keyword export] [keyword abstract] [keyword class] [def Foo] {}")
TS("interface without semicolons",
"[keyword interface] [def Foo] {",
" [property greet]([def x]: [type int]): [type blah]",
" [property bar]: [type void]",
"}")
var jsonld_mode = CodeMirror.getMode(
{indentUnit: 2},
{name: "javascript", jsonld: true}
);
function LD(name) {
test.mode(name, jsonld_mode, Array.prototype.slice.call(arguments, 1));
}
LD("json_ld_keywords",
'{',
' [meta "@context"]: {',
' [meta "@base"]: [string "http://example.com"],',
' [meta "@vocab"]: [string "http://xmlns.com/foaf/0.1/"],',
' [property "likesFlavor"]: {',
' [meta "@container"]: [meta "@list"]',
' [meta "@reverse"]: [string "@beFavoriteOf"]',
' },',
' [property "nick"]: { [meta "@container"]: [meta "@set"] },',
' [property "nick"]: { [meta "@container"]: [meta "@index"] }',
' },',
' [meta "@graph"]: [[ {',
' [meta "@id"]: [string "http://dbpedia.org/resource/John_Lennon"],',
' [property "name"]: [string "John Lennon"],',
' [property "modified"]: {',
' [meta "@value"]: [string "2010-05-29T14:17:39+02:00"],',
' [meta "@type"]: [string "http://www.w3.org/2001/XMLSchema#dateTime"]',
' }',
' } ]]',
'}');
LD("json_ld_fake",
'{',
' [property "@fake"]: [string "@fake"],',
' [property "@contextual"]: [string "@identifier"],',
' [property "user@domain.com"]: [string "@graphical"],',
' [property "@ID"]: [string "@@ID"]',
'}');
})();

View File

@ -0,0 +1,62 @@
<!doctype html>
<title>CodeMirror: TypeScript mode</title>
<meta charset="utf-8"/>
<link rel=stylesheet href="../../doc/docs.css">
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="javascript.js"></script>
<style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
<li><a class=active href="#">TypeScript</a>
</ul>
</div>
<article>
<h2>TypeScript mode</h2>
<div><textarea id="code" name="code">
class Greeter {
greeting: string;
constructor (message: string) {
this.greeting = message;
}
greet() {
return "Hello, " + this.greeting;
}
}
var greeter = new Greeter("world");
var button = document.createElement('button')
button.innerText = "Say Hello"
button.onclick = function() {
alert(greeter.greet())
}
document.body.appendChild(button)
</textarea></div>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
matchBrackets: true,
mode: "text/typescript"
});
</script>
<p>This is a specialization of the <a href="index.html">JavaScript mode</a>.</p>
</article>

402
3rdparty/codemirror/mode/xml/xml.js vendored Normal file
View File

@ -0,0 +1,402 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
"use strict";
var htmlConfig = {
autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true,
'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true,
'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true,
'track': true, 'wbr': true, 'menuitem': true},
implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true,
'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true,
'th': true, 'tr': true},
contextGrabbers: {
'dd': {'dd': true, 'dt': true},
'dt': {'dd': true, 'dt': true},
'li': {'li': true},
'option': {'option': true, 'optgroup': true},
'optgroup': {'optgroup': true},
'p': {'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true,
'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true,
'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true,
'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true,
'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true},
'rp': {'rp': true, 'rt': true},
'rt': {'rp': true, 'rt': true},
'tbody': {'tbody': true, 'tfoot': true},
'td': {'td': true, 'th': true},
'tfoot': {'tbody': true},
'th': {'td': true, 'th': true},
'thead': {'tbody': true, 'tfoot': true},
'tr': {'tr': true}
},
doNotIndent: {"pre": true},
allowUnquoted: true,
allowMissing: true,
caseFold: true
}
var xmlConfig = {
autoSelfClosers: {},
implicitlyClosed: {},
contextGrabbers: {},
doNotIndent: {},
allowUnquoted: false,
allowMissing: false,
allowMissingTagName: false,
caseFold: false
}
CodeMirror.defineMode("xml", function(editorConf, config_) {
var indentUnit = editorConf.indentUnit
var config = {}
var defaults = config_.htmlMode ? htmlConfig : xmlConfig
for (var prop in defaults) config[prop] = defaults[prop]
for (var prop in config_) config[prop] = config_[prop]
// Return variables for tokenizers
var type, setStyle;
function inText(stream, state) {
function chain(parser) {
state.tokenize = parser;
return parser(stream, state);
}
var ch = stream.next();
if (ch == "<") {
if (stream.eat("!")) {
if (stream.eat("[")) {
if (stream.match("CDATA[")) return chain(inBlock("atom", "]]>"));
else return null;
} else if (stream.match("--")) {
return chain(inBlock("comment", "-->"));
} else if (stream.match("DOCTYPE", true, true)) {
stream.eatWhile(/[\w\._\-]/);
return chain(doctype(1));
} else {
return null;
}
} else if (stream.eat("?")) {
stream.eatWhile(/[\w\._\-]/);
state.tokenize = inBlock("meta", "?>");
return "meta";
} else {
type = stream.eat("/") ? "closeTag" : "openTag";
state.tokenize = inTag;
return "tag bracket";
}
} else if (ch == "&") {
var ok;
if (stream.eat("#")) {
if (stream.eat("x")) {
ok = stream.eatWhile(/[a-fA-F\d]/) && stream.eat(";");
} else {
ok = stream.eatWhile(/[\d]/) && stream.eat(";");
}
} else {
ok = stream.eatWhile(/[\w\.\-:]/) && stream.eat(";");
}
return ok ? "atom" : "error";
} else {
stream.eatWhile(/[^&<]/);
return null;
}
}
inText.isInText = true;
function inTag(stream, state) {
var ch = stream.next();
if (ch == ">" || (ch == "/" && stream.eat(">"))) {
state.tokenize = inText;
type = ch == ">" ? "endTag" : "selfcloseTag";
return "tag bracket";
} else if (ch == "=") {
type = "equals";
return null;
} else if (ch == "<") {
state.tokenize = inText;
state.state = baseState;
state.tagName = state.tagStart = null;
var next = state.tokenize(stream, state);
return next ? next + " tag error" : "tag error";
} else if (/[\'\"]/.test(ch)) {
state.tokenize = inAttribute(ch);
state.stringStartCol = stream.column();
return state.tokenize(stream, state);
} else {
stream.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/);
return "word";
}
}
function inAttribute(quote) {
var closure = function(stream, state) {
while (!stream.eol()) {
if (stream.next() == quote) {
state.tokenize = inTag;
break;
}
}
return "string";
};
closure.isInAttribute = true;
return closure;
}
function inBlock(style, terminator) {
return function(stream, state) {
while (!stream.eol()) {
if (stream.match(terminator)) {
state.tokenize = inText;
break;
}
stream.next();
}
return style;
}
}
function doctype(depth) {
return function(stream, state) {
var ch;
while ((ch = stream.next()) != null) {
if (ch == "<") {
state.tokenize = doctype(depth + 1);
return state.tokenize(stream, state);
} else if (ch == ">") {
if (depth == 1) {
state.tokenize = inText;
break;
} else {
state.tokenize = doctype(depth - 1);
return state.tokenize(stream, state);
}
}
}
return "meta";
};
}
function Context(state, tagName, startOfLine) {
this.prev = state.context;
this.tagName = tagName;
this.indent = state.indented;
this.startOfLine = startOfLine;
if (config.doNotIndent.hasOwnProperty(tagName) || (state.context && state.context.noIndent))
this.noIndent = true;
}
function popContext(state) {
if (state.context) state.context = state.context.prev;
}
function maybePopContext(state, nextTagName) {
var parentTagName;
while (true) {
if (!state.context) {
return;
}
parentTagName = state.context.tagName;
if (!config.contextGrabbers.hasOwnProperty(parentTagName) ||
!config.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) {
return;
}
popContext(state);
}
}
function baseState(type, stream, state) {
if (type == "openTag") {
state.tagStart = stream.column();
return tagNameState;
} else if (type == "closeTag") {
return closeTagNameState;
} else {
return baseState;
}
}
function tagNameState(type, stream, state) {
if (type == "word") {
state.tagName = stream.current();
setStyle = "tag";
return attrState;
} else if (config.allowMissingTagName && type == "endTag") {
setStyle = "tag bracket";
return attrState(type, stream, state);
} else {
setStyle = "error";
return tagNameState;
}
}
function closeTagNameState(type, stream, state) {
if (type == "word") {
var tagName = stream.current();
if (state.context && state.context.tagName != tagName &&
config.implicitlyClosed.hasOwnProperty(state.context.tagName))
popContext(state);
if ((state.context && state.context.tagName == tagName) || config.matchClosing === false) {
setStyle = "tag";
return closeState;
} else {
setStyle = "tag error";
return closeStateErr;
}
} else if (config.allowMissingTagName && type == "endTag") {
setStyle = "tag bracket";
return closeState(type, stream, state);
} else {
setStyle = "error";
return closeStateErr;
}
}
function closeState(type, _stream, state) {
if (type != "endTag") {
setStyle = "error";
return closeState;
}
popContext(state);
return baseState;
}
function closeStateErr(type, stream, state) {
setStyle = "error";
return closeState(type, stream, state);
}
function attrState(type, _stream, state) {
if (type == "word") {
setStyle = "attribute";
return attrEqState;
} else if (type == "endTag" || type == "selfcloseTag") {
var tagName = state.tagName, tagStart = state.tagStart;
state.tagName = state.tagStart = null;
if (type == "selfcloseTag" ||
config.autoSelfClosers.hasOwnProperty(tagName)) {
maybePopContext(state, tagName);
} else {
maybePopContext(state, tagName);
state.context = new Context(state, tagName, tagStart == state.indented);
}
return baseState;
}
setStyle = "error";
return attrState;
}
function attrEqState(type, stream, state) {
if (type == "equals") return attrValueState;
if (!config.allowMissing) setStyle = "error";
return attrState(type, stream, state);
}
function attrValueState(type, stream, state) {
if (type == "string") return attrContinuedState;
if (type == "word" && config.allowUnquoted) {setStyle = "string"; return attrState;}
setStyle = "error";
return attrState(type, stream, state);
}
function attrContinuedState(type, stream, state) {
if (type == "string") return attrContinuedState;
return attrState(type, stream, state);
}
return {
startState: function(baseIndent) {
var state = {tokenize: inText,
state: baseState,
indented: baseIndent || 0,
tagName: null, tagStart: null,
context: null}
if (baseIndent != null) state.baseIndent = baseIndent
return state
},
token: function(stream, state) {
if (!state.tagName && stream.sol())
state.indented = stream.indentation();
if (stream.eatSpace()) return null;
type = null;
var style = state.tokenize(stream, state);
if ((style || type) && style != "comment") {
setStyle = null;
state.state = state.state(type || style, stream, state);
if (setStyle)
style = setStyle == "error" ? style + " error" : setStyle;
}
return style;
},
indent: function(state, textAfter, fullLine) {
var context = state.context;
// Indent multi-line strings (e.g. css).
if (state.tokenize.isInAttribute) {
if (state.tagStart == state.indented)
return state.stringStartCol + 1;
else
return state.indented + indentUnit;
}
if (context && context.noIndent) return CodeMirror.Pass;
if (state.tokenize != inTag && state.tokenize != inText)
return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0;
// Indent the starts of attribute names.
if (state.tagName) {
if (config.multilineTagIndentPastTag !== false)
return state.tagStart + state.tagName.length + 2;
else
return state.tagStart + indentUnit * (config.multilineTagIndentFactor || 1);
}
if (config.alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0;
var tagAfter = textAfter && /^<(\/)?([\w_:\.-]*)/.exec(textAfter);
if (tagAfter && tagAfter[1]) { // Closing tag spotted
while (context) {
if (context.tagName == tagAfter[2]) {
context = context.prev;
break;
} else if (config.implicitlyClosed.hasOwnProperty(context.tagName)) {
context = context.prev;
} else {
break;
}
}
} else if (tagAfter) { // Opening tag spotted
while (context) {
var grabbers = config.contextGrabbers[context.tagName];
if (grabbers && grabbers.hasOwnProperty(tagAfter[2]))
context = context.prev;
else
break;
}
}
while (context && context.prev && !context.startOfLine)
context = context.prev;
if (context) return context.indent + indentUnit;
else return state.baseIndent || 0;
},
electricInput: /<\/[\s\w:]+>$/,
blockCommentStart: "<!--",
blockCommentEnd: "-->",
configuration: config.htmlMode ? "html" : "xml",
helperType: config.htmlMode ? "html" : "xml",
skipAttribute: function(state) {
if (state.state == attrValueState)
state.state = attrState
}
};
});
CodeMirror.defineMIME("text/xml", "xml");
CodeMirror.defineMIME("application/xml", "xml");
if (!CodeMirror.mimeModes.hasOwnProperty("text/html"))
CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true});
});

83
3rdparty/convertPointFromPageToNode.js vendored Normal file
View File

@ -0,0 +1,83 @@
/*jslint plusplus: true, vars: true, indent: 2 */
/* convertPointFromPageToNode.js from
<script src="https://gist.github.com/Yaffle/1145197.js"></script>
convertPointFromPageToNode(element, event.pageX, event.pageY) -> {x, y}
returns coordinate in element's local coordinate system (works properly
with css transforms without perspective projection)
convertPointFromNodeToPage(element, offsetX, offsetY) -> {x, y}
returns coordinate in window's coordinate system (works properly with
css transforms without perspective projection)
*/
(function () {
'use strict'
var I = (typeof(WebKitCSSMatrix) == 'undefined') ? new DOMMatrix() : new WebKitCSSMatrix()
function Point(x, y, z) {
this.x = x
this.y = y
this.z = z
}
Point.prototype.transformBy = function (matrix) {
var tmp = matrix.multiply(I.translate(this.x, this.y, this.z))
return new Point(tmp.m41, tmp.m42, tmp.m43)
}
function createMatrix(transform) {
try {
return (typeof(WebKitCSSMatrix) == 'undefined') ? new DOMMatrix(transform) : new WebKitCSSMatrix(transform)
} catch(e) {
console.warn(transform)
console.warn(e.toString())
return I
}
}
function getTransformationMatrix(element) {
var transformationMatrix = I
var x = element
while (x != undefined && x !== x.ownerDocument.documentElement) {
var computedStyle = window.getComputedStyle(x, undefined)
var transform = computedStyle.transform || 'none'
var c = transform === 'none' ? I : createMatrix(transform)
transformationMatrix = c.multiply(transformationMatrix)
x = x.parentNode
}
var w = element.offsetWidth
var h = element.offsetHeight
var i = 4
var left = +Infinity
var top = +Infinity
while (--i >= 0) {
var p = new Point(i === 0 || i === 1 ? 0 : w, i === 0 || i === 3 ? 0 : h,
0).transformBy(transformationMatrix)
if (p.x < left) {
left = p.x
}
if (p.y < top) {
top = p.y
}
}
var rect = element.getBoundingClientRect()
transformationMatrix = I.translate(window.pageXOffset + rect.left - left,
window.pageYOffset + rect.top - top, 0)
.multiply(transformationMatrix)
return transformationMatrix
}
window.convertPointFromPageToNode = function (element, pageX, pageY) {
return new Point(pageX, pageY, 0).transformBy(
getTransformationMatrix(element).inverse())
}
window.convertPointFromNodeToPage = function (element, offsetX, offsetY) {
return new Point(offsetX, offsetY, 0).transformBy(
getTransformationMatrix(element))
}
}())

84
3rdparty/create_all_js.py vendored Executable file
View File

@ -0,0 +1,84 @@
#!/usr/bin/env python
"""
Module docstring.
"""
import sys, os, optparse
items = (
"jquery.js",
# "jspolygon.js",
"optimal-select.js",
"hammer.js",
"hammer.propagating.js",
"d3/d3.js",
"d3/d3-selection-multi.js",
"highlight",
"pixi/pixi.js",
"pixi/lib/crn_decomp.js",
"pixi/pixi-compressed-textures.js",
"pixi/pixi-filters.js",
"pixi/pixi-particles.js",
"pixi/pixi-projection.js",
"greensock/src/uncompressed",
"greensock/src/uncompressed/easing",
"greensock/src/uncompressed/plugins",
"greensock/src/uncompressed/utils",
"convertPointFromPageToNode.js"
# "getRelativeURL.js"
)
def process_command_line(argv):
"""
Return a 2-tuple: (settings object, args list).
`argv` is a list of arguments, or `None` for ``sys.argv[1:]``.
"""
if argv is None:
argv = sys.argv[1:]
# initialize the parser object:
parser = optparse.OptionParser(
formatter=optparse.TitledHelpFormatter(width=78),
add_help_option=None)
# define options here:
parser.add_option( # customized description; put --help last
'-h', '--help', action='help',
help='Show this help message and exit.')
settings, args = parser.parse_args(argv)
# check number of arguments, verify values, etc.:
if args:
parser.error('program takes no command-line arguments; '
'"%s" ignored.' % (args,))
# further process settings & args if necessary
return settings, args
def main(argv=None):
settings, args = process_command_line(argv)
run(settings, args)
return 0 # success
def run(settings, args):
with open("all.js", 'w') as outfile:
for item in items:
if item.endswith(".js"):
appendFile(outfile, item)
else:
for filename in os.listdir(item):
if filename.endswith(".js"):
appendFile(outfile, os.path.join(item, filename))
def appendFile(outfile, filename):
with open(filename) as infile:
outfile.write("\n")
outfile.write(infile.read())
print("File appended: " + infile.name)
if __name__ == '__main__':
status = main()
sys.exit(status)

68
3rdparty/create_preload_js.py vendored Executable file
View File

@ -0,0 +1,68 @@
#!/usr/bin/env python
"""
Module docstring.
"""
import sys, os, optparse
items = (
"highlight",
"greensock/src/uncompressed/plugins",
"greensock/src/uncompressed/TweenLite.js",
"convertPointFromPageToNode.js"
)
def process_command_line(argv):
"""
Return a 2-tuple: (settings object, args list).
`argv` is a list of arguments, or `None` for ``sys.argv[1:]``.
"""
if argv is None:
argv = sys.argv[1:]
# initialize the parser object:
parser = optparse.OptionParser(
formatter=optparse.TitledHelpFormatter(width=78),
add_help_option=None)
# define options here:
parser.add_option( # customized description; put --help last
'-h', '--help', action='help',
help='Show this help message and exit.')
settings, args = parser.parse_args(argv)
# check number of arguments, verify values, etc.:
if args:
parser.error('program takes no command-line arguments; '
'"%s" ignored.' % (args,))
# further process settings & args if necessary
return settings, args
def main(argv=None):
settings, args = process_command_line(argv)
run(settings, args)
return 0 # success
def run(settings, args):
with open("preload.js", 'w') as outfile:
for item in items:
if item.endswith(".js"):
appendFile(outfile, item)
else:
for filename in os.listdir(item):
if filename.endswith(".js"):
appendFile(outfile, os.path.join(item, filename))
def appendFile(outfile, filename):
with open(filename) as infile:
outfile.write("\n")
outfile.write(infile.read())
print("File appended: " + infile.name)
if __name__ == '__main__':
status = main()
sys.exit(status)

94
3rdparty/d3/d3-selection-multi.js vendored Normal file
View File

@ -0,0 +1,94 @@
// https://github.com/d3/d3-selection-multi Version 1.0.1. Copyright 2017 Mike Bostock.
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('d3-selection'), require('d3-transition')) :
typeof define === 'function' && define.amd ? define(['d3-selection', 'd3-transition'], factory) :
(factory(global.d3,global.d3));
}(this, (function (d3Selection,d3Transition) { 'use strict';
function attrsFunction(selection$$1, map) {
return selection$$1.each(function() {
var x = map.apply(this, arguments), s = d3Selection.select(this);
for (var name in x) s.attr(name, x[name]);
});
}
function attrsObject(selection$$1, map) {
for (var name in map) selection$$1.attr(name, map[name]);
return selection$$1;
}
var selection_attrs = function(map) {
return (typeof map === "function" ? attrsFunction : attrsObject)(this, map);
};
function stylesFunction(selection$$1, map, priority) {
return selection$$1.each(function() {
var x = map.apply(this, arguments), s = d3Selection.select(this);
for (var name in x) s.style(name, x[name], priority);
});
}
function stylesObject(selection$$1, map, priority) {
for (var name in map) selection$$1.style(name, map[name], priority);
return selection$$1;
}
var selection_styles = function(map, priority) {
return (typeof map === "function" ? stylesFunction : stylesObject)(this, map, priority == null ? "" : priority);
};
function propertiesFunction(selection$$1, map) {
return selection$$1.each(function() {
var x = map.apply(this, arguments), s = d3Selection.select(this);
for (var name in x) s.property(name, x[name]);
});
}
function propertiesObject(selection$$1, map) {
for (var name in map) selection$$1.property(name, map[name]);
return selection$$1;
}
var selection_properties = function(map) {
return (typeof map === "function" ? propertiesFunction : propertiesObject)(this, map);
};
function attrsFunction$1(transition$$1, map) {
return transition$$1.each(function() {
var x = map.apply(this, arguments), t = d3Selection.select(this).transition(transition$$1);
for (var name in x) t.attr(name, x[name]);
});
}
function attrsObject$1(transition$$1, map) {
for (var name in map) transition$$1.attr(name, map[name]);
return transition$$1;
}
var transition_attrs = function(map) {
return (typeof map === "function" ? attrsFunction$1 : attrsObject$1)(this, map);
};
function stylesFunction$1(transition$$1, map, priority) {
return transition$$1.each(function() {
var x = map.apply(this, arguments), t = d3Selection.select(this).transition(transition$$1);
for (var name in x) t.style(name, x[name], priority);
});
}
function stylesObject$1(transition$$1, map, priority) {
for (var name in map) transition$$1.style(name, map[name], priority);
return transition$$1;
}
var transition_styles = function(map, priority) {
return (typeof map === "function" ? stylesFunction$1 : stylesObject$1)(this, map, priority == null ? "" : priority);
};
d3Selection.selection.prototype.attrs = selection_attrs;
d3Selection.selection.prototype.styles = selection_styles;
d3Selection.selection.prototype.properties = selection_properties;
d3Transition.transition.prototype.attrs = transition_attrs;
d3Transition.transition.prototype.styles = transition_styles;
})));

2
3rdparty/d3/d3-selection-multi.min.js vendored Normal file
View File

@ -0,0 +1,2 @@
// https://github.com/d3/d3-selection-multi Version 1.0.1. Copyright 2017 Mike Bostock.
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(require("d3-selection"),require("d3-transition")):"function"==typeof define&&define.amd?define(["d3-selection","d3-transition"],n):n(t.d3,t.d3)}(this,function(t,n){"use strict";function r(n,r){return n.each(function(){var n=r.apply(this,arguments),e=t.select(this);for(var i in n)e.attr(i,n[i])})}function e(t,n){for(var r in n)t.attr(r,n[r]);return t}function i(n,r,e){return n.each(function(){var n=r.apply(this,arguments),i=t.select(this);for(var o in n)i.style(o,n[o],e)})}function o(t,n,r){for(var e in n)t.style(e,n[e],r);return t}function f(n,r){return n.each(function(){var n=r.apply(this,arguments),e=t.select(this);for(var i in n)e.property(i,n[i])})}function u(t,n){for(var r in n)t.property(r,n[r]);return t}function s(n,r){return n.each(function(){var e=r.apply(this,arguments),i=t.select(this).transition(n);for(var o in e)i.attr(o,e[o])})}function c(t,n){for(var r in n)t.attr(r,n[r]);return t}function a(n,r,e){return n.each(function(){var i=r.apply(this,arguments),o=t.select(this).transition(n);for(var f in i)o.style(f,i[f],e)})}function p(t,n,r){for(var e in n)t.style(e,n[e],r);return t}var l=function(t){return("function"==typeof t?r:e)(this,t)},y=function(t,n){return("function"==typeof t?i:o)(this,t,null==n?"":n)},h=function(t){return("function"==typeof t?f:u)(this,t)},v=function(t){return("function"==typeof t?s:c)(this,t)},d=function(t,n){return("function"==typeof t?a:p)(this,t,null==n?"":n)};t.selection.prototype.attrs=l,t.selection.prototype.styles=y,t.selection.prototype.properties=h,n.transition.prototype.attrs=v,n.transition.prototype.styles=d});

18293
3rdparty/d3/d3.js vendored Normal file

File diff suppressed because it is too large Load Diff

2
3rdparty/d3/d3.min.js vendored Normal file

File diff suppressed because one or more lines are too long

2
3rdparty/d3/topojson.v2.min.js vendored Normal file

File diff suppressed because one or more lines are too long

4511
3rdparty/dexie.js vendored Normal file

File diff suppressed because it is too large Load Diff

1
3rdparty/dexie.js.map vendored Normal file

File diff suppressed because one or more lines are too long

10
3rdparty/greensock/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
3rdparty/greensock/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"));

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
3rdparty/greensock/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
3rdparty/greensock/src/esm/Draggable.js vendored Normal file

File diff suppressed because it is too large Load Diff

375
3rdparty/greensock/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 };

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
3rdparty/greensock/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
3rdparty/greensock/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 };

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
3rdparty/greensock/src/esm/TweenLite.js vendored Normal file

File diff suppressed because it is too large Load Diff

30
3rdparty/greensock/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
3rdparty/greensock/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
3rdparty/greensock/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
3rdparty/greensock/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

1949
3rdparty/greensock/src/uncompressed/TweenLite.js vendored Executable file

File diff suppressed because it is too large Load Diff

8106
3rdparty/greensock/src/uncompressed/TweenMax.js vendored Executable file

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"));

2643
3rdparty/hammer.js vendored Normal file

File diff suppressed because it is too large Load Diff

7
3rdparty/hammer.min.js vendored Normal file

File diff suppressed because one or more lines are too long

1
3rdparty/hammer.min.js.map vendored Normal file

File diff suppressed because one or more lines are too long

231
3rdparty/hammer.propagating.js vendored Normal file
View File

@ -0,0 +1,231 @@
'use strict';
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define([], factory);
} else if (typeof exports === 'object') {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory();
} else {
// Browser globals (root is window)
window.propagating = factory();
}
}(function () {
var _firstTarget = null; // singleton, will contain the target element where the touch event started
/**
* Extend an Hammer.js instance with event propagation.
*
* Features:
* - Events emitted by hammer will propagate in order from child to parent
* elements.
* - Events are extended with a function `event.stopPropagation()` to stop
* propagation to parent elements.
* - An option `preventDefault` to stop all default browser behavior.
*
* Usage:
* var hammer = propagatingHammer(new Hammer(element));
* var hammer = propagatingHammer(new Hammer(element), {preventDefault: true});
*
* @param {Hammer.Manager} hammer An hammer instance.
* @param {Object} [options] Available options:
* - `preventDefault: true | false | 'mouse' | 'touch' | 'pen'`.
* Enforce preventing the default browser behavior.
* Cannot be set to `false`.
* @return {Hammer.Manager} Returns the same hammer instance with extended
* functionality
*/
return function propagating(hammer, options) {
var _options = options || {
preventDefault: false
};
if (hammer.Manager) {
// This looks like the Hammer constructor.
// Overload the constructors with our own.
var Hammer = hammer;
var PropagatingHammer = function(element, options) {
var o = Object.create(_options);
if (options) Hammer.assign(o, options);
return propagating(new Hammer(element, o), o);
};
Hammer.assign(PropagatingHammer, Hammer);
PropagatingHammer.Manager = function (element, options) {
var o = Object.create(_options);
if (options) Hammer.assign(o, options);
return propagating(new Hammer.Manager(element, o), o);
};
return PropagatingHammer;
}
// create a wrapper object which will override the functions
// `on`, `off`, `destroy`, and `emit` of the hammer instance
var wrapper = Object.create(hammer);
// attach to DOM element
var element = hammer.element;
if(!element.hammer) element.hammer = [];
element.hammer.push(wrapper);
// register an event to catch the start of a gesture and store the
// target in a singleton
hammer.on('hammer.input', function (event) {
if (_options.preventDefault === true || (_options.preventDefault === event.pointerType)) {
event.preventDefault();
}
if (event.isFirst) {
_firstTarget = event.target;
}
});
/** @type {Object.<String, Array.<function>>} */
wrapper._handlers = {};
/**
* Register a handler for one or multiple events
* @param {String} events A space separated string with events
* @param {function} handler A callback function, called as handler(event)
* @returns {Hammer.Manager} Returns the hammer instance
*/
wrapper.on = function (events, handler) {
// register the handler
split(events).forEach(function (event) {
var _handlers = wrapper._handlers[event];
if (!_handlers) {
wrapper._handlers[event] = _handlers = [];
// register the static, propagated handler
hammer.on(event, propagatedHandler);
}
_handlers.push(handler);
});
return wrapper;
};
/**
* Unregister a handler for one or multiple events
* @param {String} events A space separated string with events
* @param {function} [handler] Optional. The registered handler. If not
* provided, all handlers for given events
* are removed.
* @returns {Hammer.Manager} Returns the hammer instance
*/
wrapper.off = function (events, handler) {
// unregister the handler
split(events).forEach(function (event) {
var _handlers = wrapper._handlers[event];
if (_handlers) {
_handlers = handler ? _handlers.filter(function (h) {
return h !== handler;
}) : [];
if (_handlers.length > 0) {
wrapper._handlers[event] = _handlers;
}
else {
// remove static, propagated handler
hammer.off(event, propagatedHandler);
delete wrapper._handlers[event];
}
}
});
return wrapper;
};
/**
* Emit to the event listeners
* @param {string} eventType
* @param {Event} event
*/
wrapper.emit = function(eventType, event) {
_firstTarget = event.target;
hammer.emit(eventType, event);
};
wrapper.destroy = function () {
// Detach from DOM element
var hammers = hammer.element.hammer;
var idx = hammers.indexOf(wrapper);
if(idx !== -1) hammers.splice(idx,1);
if(!hammers.length) delete hammer.element.hammer;
// clear all handlers
wrapper._handlers = {};
// call original hammer destroy
hammer.destroy();
};
// split a string with space separated words
function split(events) {
return events.match(/[^ ]+/g);
}
/**
* A static event handler, applying event propagation.
* @param {Object} event
*/
function propagatedHandler(event) {
// let only a single hammer instance handle this event
if (event.type !== 'hammer.input') {
// it is possible that the same srcEvent is used with multiple hammer events,
// we keep track on which events are handled in an object _handled
if (!event.srcEvent._handled) {
event.srcEvent._handled = {};
}
if (event.srcEvent._handled[event.type]) {
return;
}
else {
event.srcEvent._handled[event.type] = true;
}
}
// attach a stopPropagation function to the event
var stopped = false;
event.stopPropagation = function () {
stopped = true;
};
//wrap the srcEvent's stopPropagation to also stop hammer propagation:
var srcStop = event.srcEvent.stopPropagation.bind(event.srcEvent);
if(typeof srcStop == "function") {
event.srcEvent.stopPropagation = function(){
srcStop();
event.stopPropagation();
}
}
// attach firstTarget property to the event
event.firstTarget = _firstTarget;
// propagate over all elements (until stopped)
var elem = _firstTarget;
while (elem && !stopped) {
var elemHammer = elem.hammer;
if(elemHammer){
var _handlers;
for(var k = 0; k < elemHammer.length; k++){
_handlers = elemHammer[k]._handlers[event.type];
if(_handlers) for (var i = 0; i < _handlers.length && !stopped; i++) {
_handlers[i](event);
}
}
}
elem = elem.parentNode;
}
}
return wrapper;
};
}));

1546
3rdparty/highlight/CHANGES.md vendored Normal file

File diff suppressed because it is too large Load Diff

24
3rdparty/highlight/LICENSE vendored Normal file
View File

@ -0,0 +1,24 @@
Copyright (c) 2006, Ivan Sagalaev
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of highlight.js nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

150
3rdparty/highlight/README.md vendored Normal file
View File

@ -0,0 +1,150 @@
# Highlight.js
[![Build Status](https://travis-ci.org/isagalaev/highlight.js.svg?branch=master)](https://travis-ci.org/isagalaev/highlight.js)
Highlight.js is a syntax highlighter written in JavaScript. It works in
the browser as well as on the server. It works with pretty much any
markup, doesnt depend on any framework and has automatic language
detection.
## Getting Started
The bare minimum for using highlight.js on a web page is linking to the
library along with one of the styles and calling
[`initHighlightingOnLoad`][1]:
```html
<link rel="stylesheet" href="/path/to/styles/default.css">
<script src="/path/to/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
```
This will find and highlight code inside of `<pre><code>` tags; it tries
to detect the language automatically. If automatic detection doesnt
work for you, you can specify the language in the `class` attribute:
```html
<pre><code class="html">...</code></pre>
```
The list of supported language classes is available in the [class
reference][2]. Classes can also be prefixed with either `language-` or
`lang-`.
To disable highlighting altogether use the `nohighlight` class:
```html
<pre><code class="nohighlight">...</code></pre>
```
## Custom Initialization
When you need a bit more control over the initialization of
highlight.js, you can use the [`highlightBlock`][3] and [`configure`][4]
functions. This allows you to control *what* to highlight and *when*.
Heres an equivalent way to calling [`initHighlightingOnLoad`][1] using
jQuery:
```javascript
$(document).ready(function() {
$('pre code').each(function(i, block) {
hljs.highlightBlock(block);
});
});
```
You can use any tags instead of `<pre><code>` to mark up your code. If
you don't use a container that preserve line breaks you will need to
configure highlight.js to use the `<br>` tag:
```javascript
hljs.configure({useBR: true});
$('div.code').each(function(i, block) {
hljs.highlightBlock(block);
});
```
For other options refer to the documentation for [`configure`][4].
## Web Workers
You can run highlighting inside a web worker to avoid freezing the browser
window while dealing with very big chunks of code.
In your main script:
```javascript
addEventListener('load', function() {
var code = document.querySelector('#code');
var worker = new Worker('worker.js');
worker.onmessage = function(event) { code.innerHTML = event.data; }
worker.postMessage(code.textContent);
})
```
In worker.js:
```javascript
onmessage = function(event) {
importScripts('<path>/highlight.pack.js');
var result = self.hljs.highlightAuto(event.data);
postMessage(result.value);
}
```
## Getting the Library
You can get highlight.js as a hosted, or custom-build, browser script or
as a server module. Right out of the box the browser script supports
both AMD and CommonJS, so if you wish you can use RequireJS or
Browserify without having to build from source. The server module also
works perfectly fine with Browserify, but there is the option to use a
build specific to browsers rather than something meant for a server.
Head over to the [download page][5] for all the options.
**Don't link to GitHub directly.** The library is not supposed to work straight
from the source, it requires building. If none of the pre-packaged options
work for you refer to the [building documentation][6].
**The CDN-hosted package doesn't have all the languages.** Otherwise it'd be
too big. If you don't see the language you need in the ["Common" section][5],
it can be added manually:
```html
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/languages/go.min.js"></script>
```
**On Almond.** You need to use the optimizer to give the module a name. For
example:
```
r.js -o name=hljs paths.hljs=/path/to/highlight out=highlight.js
```
## License
Highlight.js is released under the BSD License. See [LICENSE][7] file
for details.
## Links
The official site for the library is at <https://highlightjs.org/>.
Further in-depth documentation for the API and other topics is at
<http://highlightjs.readthedocs.io/>.
Authors and contributors are listed in the [AUTHORS.en.txt][8] file.
[1]: http://highlightjs.readthedocs.io/en/latest/api.html#inithighlightingonload
[2]: http://highlightjs.readthedocs.io/en/latest/css-classes-reference.html
[3]: http://highlightjs.readthedocs.io/en/latest/api.html#highlightblock-block
[4]: http://highlightjs.readthedocs.io/en/latest/api.html#configure-options
[5]: https://highlightjs.org/download/
[6]: http://highlightjs.readthedocs.io/en/latest/building-testing.html
[7]: https://github.com/isagalaev/highlight.js/blob/master/LICENSE
[8]: https://github.com/isagalaev/highlight.js/blob/master/AUTHORS.en.txt

142
3rdparty/highlight/README.ru.md vendored Normal file
View File

@ -0,0 +1,142 @@
# Highlight.js
Highlight.js — это инструмент для подсветки синтаксиса, написанный на JavaScript. Он работает
и в браузере, и на сервере. Он работает с практически любой HTML разметкой, не
зависит от каких-либо фреймворков и умеет автоматически определять язык.
## Начало работы
Минимум, что нужно сделать для использования highlight.js на веб-странице — это
подключить библиотеку, CSS-стили и вызывать [`initHighlightingOnLoad`][1]:
```html
<link rel="stylesheet" href="/path/to/styles/default.css">
<script src="/path/to/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
```
Библиотека найдёт и раскрасит код внутри тегов `<pre><code>`, попытавшись
автоматически определить язык. Когда автоопределение не срабатывает, можно явно
указать язык в атрибуте class:
```html
<pre><code class="html">...</code></pre>
```
Список поддерживаемых классов языков доступен в [справочнике по классам][2].
Класс также можно предварить префиксами `language-` или `lang-`.
Чтобы отключить подсветку для какого-то блока, используйте класс `nohighlight`:
```html
<pre><code class="nohighlight">...</code></pre>
```
## Инициализация вручную
Чтобы иметь чуть больше контроля за инициализацией подсветки, вы можете
использовать функции [`highlightBlock`][3] и [`configure`][4]. Таким образом
можно управлять тем, *что* и *когда* подсвечивать.
Вот пример инициализации, эквивалентной вызову [`initHighlightingOnLoad`][1], но
с использованием jQuery:
```javascript
$(document).ready(function() {
$('pre code').each(function(i, block) {
hljs.highlightBlock(block);
});
});
```
Вы можете использовать любые теги разметки вместо `<pre><code>`. Если
используете контейнер, не сохраняющий переводы строк, вам нужно сказать
highlight.js использовать для них тег `<br>`:
```javascript
hljs.configure({useBR: true});
$('div.code').each(function(i, block) {
hljs.highlightBlock(block);
});
```
Другие опции можно найти в документации функции [`configure`][4].
## Web Workers
Подсветку можно запустить внутри web worker'а, чтобы окно
браузера не подтормаживало при работе с большими кусками кода.
В основном скрипте:
```javascript
addEventListener('load', function() {
var code = document.querySelector('#code');
var worker = new Worker('worker.js');
worker.onmessage = function(event) { code.innerHTML = event.data; }
worker.postMessage(code.textContent);
})
```
В worker.js:
```javascript
onmessage = function(event) {
importScripts('<path>/highlight.pack.js');
var result = self.hljs.highlightAuto(event.data);
postMessage(result.value);
}
```
## Установка библиотеки
Highlight.js можно использовать в браузере прямо с CDN хостинга или скачать
индивидуальную сборку, а также установив модуль на сервере. На
[странице загрузки][5] подробно описаны все варианты.
**Не подключайте GitHub напрямую.** Библиотека не предназначена для
использования в виде исходного кода, а требует отдельной сборки. Если вам не
подходит ни один из готовых вариантов, читайте [документацию по сборке][6].
**Файл на CDN содержит не все языки.** Иначе он будет слишком большого размера.
Если нужного вам языка нет в [категории "Common"][5], можно дообавить его
вручную:
```html
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/languages/go.min.js"></script>
```
**Про Almond.** Нужно задать имя модуля в оптимизаторе, например:
```
r.js -o name=hljs paths.hljs=/path/to/highlight out=highlight.js
```
## Лицензия
Highlight.js распространяется под лицензией BSD. Подробнее читайте файл
[LICENSE][7].
## Ссылки
Официальный сайт билиотеки расположен по адресу <https://highlightjs.org/>.
Более подробная документация по API и другим темам расположена на
<http://highlightjs.readthedocs.io/>.
Авторы и контрибьюторы перечислены в файле [AUTHORS.ru.txt][8] file.
[1]: http://highlightjs.readthedocs.io/en/latest/api.html#inithighlightingonload
[2]: http://highlightjs.readthedocs.io/en/latest/css-classes-reference.html
[3]: http://highlightjs.readthedocs.io/en/latest/api.html#highlightblock-block
[4]: http://highlightjs.readthedocs.io/en/latest/api.html#configure-options
[5]: https://highlightjs.org/download/
[6]: http://highlightjs.readthedocs.io/en/latest/building-testing.html
[7]: https://github.com/isagalaev/highlight.js/blob/master/LICENSE
[8]: https://github.com/isagalaev/highlight.js/blob/master/AUTHORS.ru.txt

2
3rdparty/highlight/highlight.pack.js vendored Normal file

File diff suppressed because one or more lines are too long

108
3rdparty/highlight/styles/agate.css vendored Normal file
View File

@ -0,0 +1,108 @@
/*!
* Agate by Taufik Nurrohman <https://github.com/tovic>
* ----------------------------------------------------
*
* #ade5fc
* #a2fca2
* #c6b4f0
* #d36363
* #fcc28c
* #fc9b9b
* #ffa
* #fff
* #333
* #62c8f3
* #888
*
*/
.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
background: #333;
color: white;
}
.hljs-name,
.hljs-strong {
font-weight: bold;
}
.hljs-code,
.hljs-emphasis {
font-style: italic;
}
.hljs-tag {
color: #62c8f3;
}
.hljs-variable,
.hljs-template-variable,
.hljs-selector-id,
.hljs-selector-class {
color: #ade5fc;
}
.hljs-string,
.hljs-bullet {
color: #a2fca2;
}
.hljs-type,
.hljs-title,
.hljs-section,
.hljs-attribute,
.hljs-quote,
.hljs-built_in,
.hljs-builtin-name {
color: #ffa;
}
.hljs-number,
.hljs-symbol,
.hljs-bullet {
color: #d36363;
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-literal {
color: #fcc28c;
}
.hljs-comment,
.hljs-deletion,
.hljs-code {
color: #888;
}
.hljs-regexp,
.hljs-link {
color: #c6b4f0;
}
.hljs-meta {
color: #fc9b9b;
}
.hljs-deletion {
background-color: #fc9b9b;
color: #333;
}
.hljs-addition {
background-color: #a2fca2;
color: #333;
}
.hljs a {
color: inherit;
}
.hljs a:focus,
.hljs a:hover {
color: inherit;
text-decoration: underline;
}

View File

@ -0,0 +1,66 @@
/*
Date: 24 Fev 2015
Author: Pedro Oliveira <kanytu@gmail . com>
*/
.hljs {
color: #a9b7c6;
background: #282b2e;
display: block;
overflow-x: auto;
padding: 0.5em;
}
.hljs-number,
.hljs-literal,
.hljs-symbol,
.hljs-bullet {
color: #6897BB;
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-deletion {
color: #cc7832;
}
.hljs-variable,
.hljs-template-variable,
.hljs-link {
color: #629755;
}
.hljs-comment,
.hljs-quote {
color: #808080;
}
.hljs-meta {
color: #bbb529;
}
.hljs-string,
.hljs-attribute,
.hljs-addition {
color: #6A8759;
}
.hljs-section,
.hljs-title,
.hljs-type {
color: #ffc66d;
}
.hljs-name,
.hljs-selector-id,
.hljs-selector-class {
color: #e8bf6a;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}

View File

@ -0,0 +1,88 @@
/*
Arduino® Light Theme - Stefania Mellai <s.mellai@arduino.cc>
*/
.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
background: #FFFFFF;
}
.hljs,
.hljs-subst {
color: #434f54;
}
.hljs-keyword,
.hljs-attribute,
.hljs-selector-tag,
.hljs-doctag,
.hljs-name {
color: #00979D;
}
.hljs-built_in,
.hljs-literal,
.hljs-bullet,
.hljs-code,
.hljs-addition {
color: #D35400;
}
.hljs-regexp,
.hljs-symbol,
.hljs-variable,
.hljs-template-variable,
.hljs-link,
.hljs-selector-attr,
.hljs-selector-pseudo {
color: #00979D;
}
.hljs-type,
.hljs-string,
.hljs-selector-id,
.hljs-selector-class,
.hljs-quote,
.hljs-template-tag,
.hljs-deletion {
color: #005C5F;
}
.hljs-title,
.hljs-section {
color: #880000;
font-weight: bold;
}
.hljs-comment {
color: rgba(149,165,166,.8);
}
.hljs-meta-keyword {
color: #728E00;
}
.hljs-meta {
color: #728E00;
color: #434f54;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}
.hljs-function {
color: #728E00;
}
.hljs-number {
color: #8A7B52;
}

73
3rdparty/highlight/styles/arta.css vendored Normal file
View File

@ -0,0 +1,73 @@
/*
Date: 17.V.2011
Author: pumbur <pumbur@pumbur.net>
*/
.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
background: #222;
}
.hljs,
.hljs-subst {
color: #aaa;
}
.hljs-section {
color: #fff;
}
.hljs-comment,
.hljs-quote,
.hljs-meta {
color: #444;
}
.hljs-string,
.hljs-symbol,
.hljs-bullet,
.hljs-regexp {
color: #ffcc33;
}
.hljs-number,
.hljs-addition {
color: #00cc66;
}
.hljs-built_in,
.hljs-builtin-name,
.hljs-literal,
.hljs-type,
.hljs-template-variable,
.hljs-attribute,
.hljs-link {
color: #32aaee;
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class {
color: #6644aa;
}
.hljs-title,
.hljs-variable,
.hljs-deletion,
.hljs-template-tag {
color: #bb1166;
}
.hljs-section,
.hljs-doctag,
.hljs-strong {
font-weight: bold;
}
.hljs-emphasis {
font-style: italic;
}

45
3rdparty/highlight/styles/ascetic.css vendored Normal file
View File

@ -0,0 +1,45 @@
/*
Original style from softwaremaniacs.org (c) Ivan Sagalaev <Maniac@SoftwareManiacs.Org>
*/
.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
background: white;
color: black;
}
.hljs-string,
.hljs-variable,
.hljs-template-variable,
.hljs-symbol,
.hljs-bullet,
.hljs-section,
.hljs-addition,
.hljs-attribute,
.hljs-link {
color: #888;
}
.hljs-comment,
.hljs-quote,
.hljs-meta,
.hljs-deletion {
color: #ccc;
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-section,
.hljs-name,
.hljs-type,
.hljs-strong {
font-weight: bold;
}
.hljs-emphasis {
font-style: italic;
}

View File

@ -0,0 +1,83 @@
/* Base16 Atelier Cave Dark - Theme */
/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/cave) */
/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */
/* Atelier-Cave Comment */
.hljs-comment,
.hljs-quote {
color: #7e7887;
}
/* Atelier-Cave Red */
.hljs-variable,
.hljs-template-variable,
.hljs-attribute,
.hljs-regexp,
.hljs-link,
.hljs-tag,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class {
color: #be4678;
}
/* Atelier-Cave Orange */
.hljs-number,
.hljs-meta,
.hljs-built_in,
.hljs-builtin-name,
.hljs-literal,
.hljs-type,
.hljs-params {
color: #aa573c;
}
/* Atelier-Cave Green */
.hljs-string,
.hljs-symbol,
.hljs-bullet {
color: #2a9292;
}
/* Atelier-Cave Blue */
.hljs-title,
.hljs-section {
color: #576ddb;
}
/* Atelier-Cave Purple */
.hljs-keyword,
.hljs-selector-tag {
color: #955ae7;
}
.hljs-deletion,
.hljs-addition {
color: #19171c;
display: inline-block;
width: 100%;
}
.hljs-deletion {
background-color: #be4678;
}
.hljs-addition {
background-color: #2a9292;
}
.hljs {
display: block;
overflow-x: auto;
background: #19171c;
color: #8b8792;
padding: 0.5em;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}

View File

@ -0,0 +1,85 @@
/* Base16 Atelier Cave Light - Theme */
/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/cave) */
/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */
/* Atelier-Cave Comment */
.hljs-comment,
.hljs-quote {
color: #655f6d;
}
/* Atelier-Cave Red */
.hljs-variable,
.hljs-template-variable,
.hljs-attribute,
.hljs-tag,
.hljs-name,
.hljs-regexp,
.hljs-link,
.hljs-name,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class {
color: #be4678;
}
/* Atelier-Cave Orange */
.hljs-number,
.hljs-meta,
.hljs-built_in,
.hljs-builtin-name,
.hljs-literal,
.hljs-type,
.hljs-params {
color: #aa573c;
}
/* Atelier-Cave Green */
.hljs-string,
.hljs-symbol,
.hljs-bullet {
color: #2a9292;
}
/* Atelier-Cave Blue */
.hljs-title,
.hljs-section {
color: #576ddb;
}
/* Atelier-Cave Purple */
.hljs-keyword,
.hljs-selector-tag {
color: #955ae7;
}
.hljs-deletion,
.hljs-addition {
color: #19171c;
display: inline-block;
width: 100%;
}
.hljs-deletion {
background-color: #be4678;
}
.hljs-addition {
background-color: #2a9292;
}
.hljs {
display: block;
overflow-x: auto;
background: #efecf4;
color: #585260;
padding: 0.5em;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}

View File

@ -0,0 +1,69 @@
/* Base16 Atelier Dune Dark - Theme */
/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/dune) */
/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */
/* Atelier-Dune Comment */
.hljs-comment,
.hljs-quote {
color: #999580;
}
/* Atelier-Dune Red */
.hljs-variable,
.hljs-template-variable,
.hljs-attribute,
.hljs-tag,
.hljs-name,
.hljs-regexp,
.hljs-link,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class {
color: #d73737;
}
/* Atelier-Dune Orange */
.hljs-number,
.hljs-meta,
.hljs-built_in,
.hljs-builtin-name,
.hljs-literal,
.hljs-type,
.hljs-params {
color: #b65611;
}
/* Atelier-Dune Green */
.hljs-string,
.hljs-symbol,
.hljs-bullet {
color: #60ac39;
}
/* Atelier-Dune Blue */
.hljs-title,
.hljs-section {
color: #6684e1;
}
/* Atelier-Dune Purple */
.hljs-keyword,
.hljs-selector-tag {
color: #b854d4;
}
.hljs {
display: block;
overflow-x: auto;
background: #20201d;
color: #a6a28c;
padding: 0.5em;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}

View File

@ -0,0 +1,69 @@
/* Base16 Atelier Dune Light - Theme */
/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/dune) */
/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */
/* Atelier-Dune Comment */
.hljs-comment,
.hljs-quote {
color: #7d7a68;
}
/* Atelier-Dune Red */
.hljs-variable,
.hljs-template-variable,
.hljs-attribute,
.hljs-tag,
.hljs-name,
.hljs-regexp,
.hljs-link,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class {
color: #d73737;
}
/* Atelier-Dune Orange */
.hljs-number,
.hljs-meta,
.hljs-built_in,
.hljs-builtin-name,
.hljs-literal,
.hljs-type,
.hljs-params {
color: #b65611;
}
/* Atelier-Dune Green */
.hljs-string,
.hljs-symbol,
.hljs-bullet {
color: #60ac39;
}
/* Atelier-Dune Blue */
.hljs-title,
.hljs-section {
color: #6684e1;
}
/* Atelier-Dune Purple */
.hljs-keyword,
.hljs-selector-tag {
color: #b854d4;
}
.hljs {
display: block;
overflow-x: auto;
background: #fefbec;
color: #6e6b5e;
padding: 0.5em;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}

View File

@ -0,0 +1,84 @@
/* Base16 Atelier Estuary Dark - Theme */
/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/estuary) */
/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */
/* Atelier-Estuary Comment */
.hljs-comment,
.hljs-quote {
color: #878573;
}
/* Atelier-Estuary Red */
.hljs-variable,
.hljs-template-variable,
.hljs-attribute,
.hljs-tag,
.hljs-name,
.hljs-regexp,
.hljs-link,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class {
color: #ba6236;
}
/* Atelier-Estuary Orange */
.hljs-number,
.hljs-meta,
.hljs-built_in,
.hljs-builtin-name,
.hljs-literal,
.hljs-type,
.hljs-params {
color: #ae7313;
}
/* Atelier-Estuary Green */
.hljs-string,
.hljs-symbol,
.hljs-bullet {
color: #7d9726;
}
/* Atelier-Estuary Blue */
.hljs-title,
.hljs-section {
color: #36a166;
}
/* Atelier-Estuary Purple */
.hljs-keyword,
.hljs-selector-tag {
color: #5f9182;
}
.hljs-deletion,
.hljs-addition {
color: #22221b;
display: inline-block;
width: 100%;
}
.hljs-deletion {
background-color: #ba6236;
}
.hljs-addition {
background-color: #7d9726;
}
.hljs {
display: block;
overflow-x: auto;
background: #22221b;
color: #929181;
padding: 0.5em;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}

View File

@ -0,0 +1,84 @@
/* Base16 Atelier Estuary Light - Theme */
/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/estuary) */
/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */
/* Atelier-Estuary Comment */
.hljs-comment,
.hljs-quote {
color: #6c6b5a;
}
/* Atelier-Estuary Red */
.hljs-variable,
.hljs-template-variable,
.hljs-attribute,
.hljs-tag,
.hljs-name,
.hljs-regexp,
.hljs-link,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class {
color: #ba6236;
}
/* Atelier-Estuary Orange */
.hljs-number,
.hljs-meta,
.hljs-built_in,
.hljs-builtin-name,
.hljs-literal,
.hljs-type,
.hljs-params {
color: #ae7313;
}
/* Atelier-Estuary Green */
.hljs-string,
.hljs-symbol,
.hljs-bullet {
color: #7d9726;
}
/* Atelier-Estuary Blue */
.hljs-title,
.hljs-section {
color: #36a166;
}
/* Atelier-Estuary Purple */
.hljs-keyword,
.hljs-selector-tag {
color: #5f9182;
}
.hljs-deletion,
.hljs-addition {
color: #22221b;
display: inline-block;
width: 100%;
}
.hljs-deletion {
background-color: #ba6236;
}
.hljs-addition {
background-color: #7d9726;
}
.hljs {
display: block;
overflow-x: auto;
background: #f4f3ec;
color: #5f5e4e;
padding: 0.5em;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}

View File

@ -0,0 +1,69 @@
/* Base16 Atelier Forest Dark - Theme */
/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/forest) */
/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */
/* Atelier-Forest Comment */
.hljs-comment,
.hljs-quote {
color: #9c9491;
}
/* Atelier-Forest Red */
.hljs-variable,
.hljs-template-variable,
.hljs-attribute,
.hljs-tag,
.hljs-name,
.hljs-regexp,
.hljs-link,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class {
color: #f22c40;
}
/* Atelier-Forest Orange */
.hljs-number,
.hljs-meta,
.hljs-built_in,
.hljs-builtin-name,
.hljs-literal,
.hljs-type,
.hljs-params {
color: #df5320;
}
/* Atelier-Forest Green */
.hljs-string,
.hljs-symbol,
.hljs-bullet {
color: #7b9726;
}
/* Atelier-Forest Blue */
.hljs-title,
.hljs-section {
color: #407ee7;
}
/* Atelier-Forest Purple */
.hljs-keyword,
.hljs-selector-tag {
color: #6666ea;
}
.hljs {
display: block;
overflow-x: auto;
background: #1b1918;
color: #a8a19f;
padding: 0.5em;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}

View File

@ -0,0 +1,69 @@
/* Base16 Atelier Forest Light - Theme */
/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/forest) */
/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */
/* Atelier-Forest Comment */
.hljs-comment,
.hljs-quote {
color: #766e6b;
}
/* Atelier-Forest Red */
.hljs-variable,
.hljs-template-variable,
.hljs-attribute,
.hljs-tag,
.hljs-name,
.hljs-regexp,
.hljs-link,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class {
color: #f22c40;
}
/* Atelier-Forest Orange */
.hljs-number,
.hljs-meta,
.hljs-built_in,
.hljs-builtin-name,
.hljs-literal,
.hljs-type,
.hljs-params {
color: #df5320;
}
/* Atelier-Forest Green */
.hljs-string,
.hljs-symbol,
.hljs-bullet {
color: #7b9726;
}
/* Atelier-Forest Blue */
.hljs-title,
.hljs-section {
color: #407ee7;
}
/* Atelier-Forest Purple */
.hljs-keyword,
.hljs-selector-tag {
color: #6666ea;
}
.hljs {
display: block;
overflow-x: auto;
background: #f1efee;
color: #68615e;
padding: 0.5em;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}

View File

@ -0,0 +1,69 @@
/* Base16 Atelier Heath Dark - Theme */
/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/heath) */
/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */
/* Atelier-Heath Comment */
.hljs-comment,
.hljs-quote {
color: #9e8f9e;
}
/* Atelier-Heath Red */
.hljs-variable,
.hljs-template-variable,
.hljs-attribute,
.hljs-tag,
.hljs-name,
.hljs-regexp,
.hljs-link,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class {
color: #ca402b;
}
/* Atelier-Heath Orange */
.hljs-number,
.hljs-meta,
.hljs-built_in,
.hljs-builtin-name,
.hljs-literal,
.hljs-type,
.hljs-params {
color: #a65926;
}
/* Atelier-Heath Green */
.hljs-string,
.hljs-symbol,
.hljs-bullet {
color: #918b3b;
}
/* Atelier-Heath Blue */
.hljs-title,
.hljs-section {
color: #516aec;
}
/* Atelier-Heath Purple */
.hljs-keyword,
.hljs-selector-tag {
color: #7b59c0;
}
.hljs {
display: block;
overflow-x: auto;
background: #1b181b;
color: #ab9bab;
padding: 0.5em;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}

View File

@ -0,0 +1,69 @@
/* Base16 Atelier Heath Light - Theme */
/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/heath) */
/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */
/* Atelier-Heath Comment */
.hljs-comment,
.hljs-quote {
color: #776977;
}
/* Atelier-Heath Red */
.hljs-variable,
.hljs-template-variable,
.hljs-attribute,
.hljs-tag,
.hljs-name,
.hljs-regexp,
.hljs-link,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class {
color: #ca402b;
}
/* Atelier-Heath Orange */
.hljs-number,
.hljs-meta,
.hljs-built_in,
.hljs-builtin-name,
.hljs-literal,
.hljs-type,
.hljs-params {
color: #a65926;
}
/* Atelier-Heath Green */
.hljs-string,
.hljs-symbol,
.hljs-bullet {
color: #918b3b;
}
/* Atelier-Heath Blue */
.hljs-title,
.hljs-section {
color: #516aec;
}
/* Atelier-Heath Purple */
.hljs-keyword,
.hljs-selector-tag {
color: #7b59c0;
}
.hljs {
display: block;
overflow-x: auto;
background: #f7f3f7;
color: #695d69;
padding: 0.5em;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}

View File

@ -0,0 +1,69 @@
/* Base16 Atelier Lakeside Dark - Theme */
/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/lakeside) */
/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */
/* Atelier-Lakeside Comment */
.hljs-comment,
.hljs-quote {
color: #7195a8;
}
/* Atelier-Lakeside Red */
.hljs-variable,
.hljs-template-variable,
.hljs-attribute,
.hljs-tag,
.hljs-name,
.hljs-regexp,
.hljs-link,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class {
color: #d22d72;
}
/* Atelier-Lakeside Orange */
.hljs-number,
.hljs-meta,
.hljs-built_in,
.hljs-builtin-name,
.hljs-literal,
.hljs-type,
.hljs-params {
color: #935c25;
}
/* Atelier-Lakeside Green */
.hljs-string,
.hljs-symbol,
.hljs-bullet {
color: #568c3b;
}
/* Atelier-Lakeside Blue */
.hljs-title,
.hljs-section {
color: #257fad;
}
/* Atelier-Lakeside Purple */
.hljs-keyword,
.hljs-selector-tag {
color: #6b6bb8;
}
.hljs {
display: block;
overflow-x: auto;
background: #161b1d;
color: #7ea2b4;
padding: 0.5em;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}

View File

@ -0,0 +1,69 @@
/* Base16 Atelier Lakeside Light - Theme */
/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/lakeside) */
/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */
/* Atelier-Lakeside Comment */
.hljs-comment,
.hljs-quote {
color: #5a7b8c;
}
/* Atelier-Lakeside Red */
.hljs-variable,
.hljs-template-variable,
.hljs-attribute,
.hljs-tag,
.hljs-name,
.hljs-regexp,
.hljs-link,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class {
color: #d22d72;
}
/* Atelier-Lakeside Orange */
.hljs-number,
.hljs-meta,
.hljs-built_in,
.hljs-builtin-name,
.hljs-literal,
.hljs-type,
.hljs-params {
color: #935c25;
}
/* Atelier-Lakeside Green */
.hljs-string,
.hljs-symbol,
.hljs-bullet {
color: #568c3b;
}
/* Atelier-Lakeside Blue */
.hljs-title,
.hljs-section {
color: #257fad;
}
/* Atelier-Lakeside Purple */
.hljs-keyword,
.hljs-selector-tag {
color: #6b6bb8;
}
.hljs {
display: block;
overflow-x: auto;
background: #ebf8ff;
color: #516d7b;
padding: 0.5em;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}

View File

@ -0,0 +1,84 @@
/* Base16 Atelier Plateau Dark - Theme */
/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/plateau) */
/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */
/* Atelier-Plateau Comment */
.hljs-comment,
.hljs-quote {
color: #7e7777;
}
/* Atelier-Plateau Red */
.hljs-variable,
.hljs-template-variable,
.hljs-attribute,
.hljs-tag,
.hljs-name,
.hljs-regexp,
.hljs-link,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class {
color: #ca4949;
}
/* Atelier-Plateau Orange */
.hljs-number,
.hljs-meta,
.hljs-built_in,
.hljs-builtin-name,
.hljs-literal,
.hljs-type,
.hljs-params {
color: #b45a3c;
}
/* Atelier-Plateau Green */
.hljs-string,
.hljs-symbol,
.hljs-bullet {
color: #4b8b8b;
}
/* Atelier-Plateau Blue */
.hljs-title,
.hljs-section {
color: #7272ca;
}
/* Atelier-Plateau Purple */
.hljs-keyword,
.hljs-selector-tag {
color: #8464c4;
}
.hljs-deletion,
.hljs-addition {
color: #1b1818;
display: inline-block;
width: 100%;
}
.hljs-deletion {
background-color: #ca4949;
}
.hljs-addition {
background-color: #4b8b8b;
}
.hljs {
display: block;
overflow-x: auto;
background: #1b1818;
color: #8a8585;
padding: 0.5em;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}

View File

@ -0,0 +1,84 @@
/* Base16 Atelier Plateau Light - Theme */
/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/plateau) */
/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */
/* Atelier-Plateau Comment */
.hljs-comment,
.hljs-quote {
color: #655d5d;
}
/* Atelier-Plateau Red */
.hljs-variable,
.hljs-template-variable,
.hljs-attribute,
.hljs-tag,
.hljs-name,
.hljs-regexp,
.hljs-link,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class {
color: #ca4949;
}
/* Atelier-Plateau Orange */
.hljs-number,
.hljs-meta,
.hljs-built_in,
.hljs-builtin-name,
.hljs-literal,
.hljs-type,
.hljs-params {
color: #b45a3c;
}
/* Atelier-Plateau Green */
.hljs-string,
.hljs-symbol,
.hljs-bullet {
color: #4b8b8b;
}
/* Atelier-Plateau Blue */
.hljs-title,
.hljs-section {
color: #7272ca;
}
/* Atelier-Plateau Purple */
.hljs-keyword,
.hljs-selector-tag {
color: #8464c4;
}
.hljs-deletion,
.hljs-addition {
color: #1b1818;
display: inline-block;
width: 100%;
}
.hljs-deletion {
background-color: #ca4949;
}
.hljs-addition {
background-color: #4b8b8b;
}
.hljs {
display: block;
overflow-x: auto;
background: #f4ecec;
color: #585050;
padding: 0.5em;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}

View File

@ -0,0 +1,84 @@
/* Base16 Atelier Savanna Dark - Theme */
/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/savanna) */
/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */
/* Atelier-Savanna Comment */
.hljs-comment,
.hljs-quote {
color: #78877d;
}
/* Atelier-Savanna Red */
.hljs-variable,
.hljs-template-variable,
.hljs-attribute,
.hljs-tag,
.hljs-name,
.hljs-regexp,
.hljs-link,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class {
color: #b16139;
}
/* Atelier-Savanna Orange */
.hljs-number,
.hljs-meta,
.hljs-built_in,
.hljs-builtin-name,
.hljs-literal,
.hljs-type,
.hljs-params {
color: #9f713c;
}
/* Atelier-Savanna Green */
.hljs-string,
.hljs-symbol,
.hljs-bullet {
color: #489963;
}
/* Atelier-Savanna Blue */
.hljs-title,
.hljs-section {
color: #478c90;
}
/* Atelier-Savanna Purple */
.hljs-keyword,
.hljs-selector-tag {
color: #55859b;
}
.hljs-deletion,
.hljs-addition {
color: #171c19;
display: inline-block;
width: 100%;
}
.hljs-deletion {
background-color: #b16139;
}
.hljs-addition {
background-color: #489963;
}
.hljs {
display: block;
overflow-x: auto;
background: #171c19;
color: #87928a;
padding: 0.5em;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}

View File

@ -0,0 +1,84 @@
/* Base16 Atelier Savanna Light - Theme */
/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/savanna) */
/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */
/* Atelier-Savanna Comment */
.hljs-comment,
.hljs-quote {
color: #5f6d64;
}
/* Atelier-Savanna Red */
.hljs-variable,
.hljs-template-variable,
.hljs-attribute,
.hljs-tag,
.hljs-name,
.hljs-regexp,
.hljs-link,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class {
color: #b16139;
}
/* Atelier-Savanna Orange */
.hljs-number,
.hljs-meta,
.hljs-built_in,
.hljs-builtin-name,
.hljs-literal,
.hljs-type,
.hljs-params {
color: #9f713c;
}
/* Atelier-Savanna Green */
.hljs-string,
.hljs-symbol,
.hljs-bullet {
color: #489963;
}
/* Atelier-Savanna Blue */
.hljs-title,
.hljs-section {
color: #478c90;
}
/* Atelier-Savanna Purple */
.hljs-keyword,
.hljs-selector-tag {
color: #55859b;
}
.hljs-deletion,
.hljs-addition {
color: #171c19;
display: inline-block;
width: 100%;
}
.hljs-deletion {
background-color: #b16139;
}
.hljs-addition {
background-color: #489963;
}
.hljs {
display: block;
overflow-x: auto;
background: #ecf4ee;
color: #526057;
padding: 0.5em;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}

View File

@ -0,0 +1,69 @@
/* Base16 Atelier Seaside Dark - Theme */
/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/seaside) */
/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */
/* Atelier-Seaside Comment */
.hljs-comment,
.hljs-quote {
color: #809980;
}
/* Atelier-Seaside Red */
.hljs-variable,
.hljs-template-variable,
.hljs-attribute,
.hljs-tag,
.hljs-name,
.hljs-regexp,
.hljs-link,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class {
color: #e6193c;
}
/* Atelier-Seaside Orange */
.hljs-number,
.hljs-meta,
.hljs-built_in,
.hljs-builtin-name,
.hljs-literal,
.hljs-type,
.hljs-params {
color: #87711d;
}
/* Atelier-Seaside Green */
.hljs-string,
.hljs-symbol,
.hljs-bullet {
color: #29a329;
}
/* Atelier-Seaside Blue */
.hljs-title,
.hljs-section {
color: #3d62f5;
}
/* Atelier-Seaside Purple */
.hljs-keyword,
.hljs-selector-tag {
color: #ad2bee;
}
.hljs {
display: block;
overflow-x: auto;
background: #131513;
color: #8ca68c;
padding: 0.5em;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}

View File

@ -0,0 +1,69 @@
/* Base16 Atelier Seaside Light - Theme */
/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/seaside) */
/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */
/* Atelier-Seaside Comment */
.hljs-comment,
.hljs-quote {
color: #687d68;
}
/* Atelier-Seaside Red */
.hljs-variable,
.hljs-template-variable,
.hljs-attribute,
.hljs-tag,
.hljs-name,
.hljs-regexp,
.hljs-link,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class {
color: #e6193c;
}
/* Atelier-Seaside Orange */
.hljs-number,
.hljs-meta,
.hljs-built_in,
.hljs-builtin-name,
.hljs-literal,
.hljs-type,
.hljs-params {
color: #87711d;
}
/* Atelier-Seaside Green */
.hljs-string,
.hljs-symbol,
.hljs-bullet {
color: #29a329;
}
/* Atelier-Seaside Blue */
.hljs-title,
.hljs-section {
color: #3d62f5;
}
/* Atelier-Seaside Purple */
.hljs-keyword,
.hljs-selector-tag {
color: #ad2bee;
}
.hljs {
display: block;
overflow-x: auto;
background: #f4fbf4;
color: #5e6e5e;
padding: 0.5em;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}

View File

@ -0,0 +1,69 @@
/* Base16 Atelier Sulphurpool Dark - Theme */
/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/sulphurpool) */
/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */
/* Atelier-Sulphurpool Comment */
.hljs-comment,
.hljs-quote {
color: #898ea4;
}
/* Atelier-Sulphurpool Red */
.hljs-variable,
.hljs-template-variable,
.hljs-attribute,
.hljs-tag,
.hljs-name,
.hljs-regexp,
.hljs-link,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class {
color: #c94922;
}
/* Atelier-Sulphurpool Orange */
.hljs-number,
.hljs-meta,
.hljs-built_in,
.hljs-builtin-name,
.hljs-literal,
.hljs-type,
.hljs-params {
color: #c76b29;
}
/* Atelier-Sulphurpool Green */
.hljs-string,
.hljs-symbol,
.hljs-bullet {
color: #ac9739;
}
/* Atelier-Sulphurpool Blue */
.hljs-title,
.hljs-section {
color: #3d8fd1;
}
/* Atelier-Sulphurpool Purple */
.hljs-keyword,
.hljs-selector-tag {
color: #6679cc;
}
.hljs {
display: block;
overflow-x: auto;
background: #202746;
color: #979db4;
padding: 0.5em;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}

View File

@ -0,0 +1,69 @@
/* Base16 Atelier Sulphurpool Light - Theme */
/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/sulphurpool) */
/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */
/* Atelier-Sulphurpool Comment */
.hljs-comment,
.hljs-quote {
color: #6b7394;
}
/* Atelier-Sulphurpool Red */
.hljs-variable,
.hljs-template-variable,
.hljs-attribute,
.hljs-tag,
.hljs-name,
.hljs-regexp,
.hljs-link,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class {
color: #c94922;
}
/* Atelier-Sulphurpool Orange */
.hljs-number,
.hljs-meta,
.hljs-built_in,
.hljs-builtin-name,
.hljs-literal,
.hljs-type,
.hljs-params {
color: #c76b29;
}
/* Atelier-Sulphurpool Green */
.hljs-string,
.hljs-symbol,
.hljs-bullet {
color: #ac9739;
}
/* Atelier-Sulphurpool Blue */
.hljs-title,
.hljs-section {
color: #3d8fd1;
}
/* Atelier-Sulphurpool Purple */
.hljs-keyword,
.hljs-selector-tag {
color: #6679cc;
}
.hljs {
display: block;
overflow-x: auto;
background: #f5f7ff;
color: #5e6687;
padding: 0.5em;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}

View File

@ -0,0 +1,96 @@
/*
Atom One Dark by Daniel Gamage
Original One Dark Syntax theme from https://github.com/atom/one-dark-syntax
base: #282c34
mono-1: #abb2bf
mono-2: #818896
mono-3: #5c6370
hue-1: #56b6c2
hue-2: #61aeee
hue-3: #c678dd
hue-4: #98c379
hue-5: #e06c75
hue-5-2: #be5046
hue-6: #d19a66
hue-6-2: #e6c07b
*/
.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
color: #abb2bf;
background: #282c34;
}
.hljs-comment,
.hljs-quote {
color: #5c6370;
font-style: italic;
}
.hljs-doctag,
.hljs-keyword,
.hljs-formula {
color: #c678dd;
}
.hljs-section,
.hljs-name,
.hljs-selector-tag,
.hljs-deletion,
.hljs-subst {
color: #e06c75;
}
.hljs-literal {
color: #56b6c2;
}
.hljs-string,
.hljs-regexp,
.hljs-addition,
.hljs-attribute,
.hljs-meta-string {
color: #98c379;
}
.hljs-built_in,
.hljs-class .hljs-title {
color: #e6c07b;
}
.hljs-attr,
.hljs-variable,
.hljs-template-variable,
.hljs-type,
.hljs-selector-class,
.hljs-selector-attr,
.hljs-selector-pseudo,
.hljs-number {
color: #d19a66;
}
.hljs-symbol,
.hljs-bullet,
.hljs-link,
.hljs-meta,
.hljs-selector-id,
.hljs-title {
color: #61aeee;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}
.hljs-link {
text-decoration: underline;
}

View File

@ -0,0 +1,96 @@
/*
Atom One Light by Daniel Gamage
Original One Light Syntax theme from https://github.com/atom/one-light-syntax
base: #fafafa
mono-1: #383a42
mono-2: #686b77
mono-3: #a0a1a7
hue-1: #0184bb
hue-2: #4078f2
hue-3: #a626a4
hue-4: #50a14f
hue-5: #e45649
hue-5-2: #c91243
hue-6: #986801
hue-6-2: #c18401
*/
.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
color: #383a42;
background: #fafafa;
}
.hljs-comment,
.hljs-quote {
color: #a0a1a7;
font-style: italic;
}
.hljs-doctag,
.hljs-keyword,
.hljs-formula {
color: #a626a4;
}
.hljs-section,
.hljs-name,
.hljs-selector-tag,
.hljs-deletion,
.hljs-subst {
color: #e45649;
}
.hljs-literal {
color: #0184bb;
}
.hljs-string,
.hljs-regexp,
.hljs-addition,
.hljs-attribute,
.hljs-meta-string {
color: #50a14f;
}
.hljs-built_in,
.hljs-class .hljs-title {
color: #c18401;
}
.hljs-attr,
.hljs-variable,
.hljs-template-variable,
.hljs-type,
.hljs-selector-class,
.hljs-selector-attr,
.hljs-selector-pseudo,
.hljs-number {
color: #986801;
}
.hljs-symbol,
.hljs-bullet,
.hljs-link,
.hljs-meta,
.hljs-selector-id,
.hljs-title {
color: #4078f2;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}
.hljs-link {
text-decoration: underline;
}

View File

@ -0,0 +1,64 @@
/*
Brown Paper style from goldblog.com.ua (c) Zaripov Yura <yur4ik7@ukr.net>
*/
.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
background:#b7a68e url(./brown-papersq.png);
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-literal {
color:#005599;
font-weight:bold;
}
.hljs,
.hljs-subst {
color: #363c69;
}
.hljs-string,
.hljs-title,
.hljs-section,
.hljs-type,
.hljs-attribute,
.hljs-symbol,
.hljs-bullet,
.hljs-built_in,
.hljs-addition,
.hljs-variable,
.hljs-template-tag,
.hljs-template-variable,
.hljs-link,
.hljs-name {
color: #2c009f;
}
.hljs-comment,
.hljs-quote,
.hljs-meta,
.hljs-deletion {
color: #802022;
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-literal,
.hljs-doctag,
.hljs-title,
.hljs-section,
.hljs-type,
.hljs-name,
.hljs-strong {
font-weight: bold;
}
.hljs-emphasis {
font-style: italic;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -0,0 +1,60 @@
/*
codepen.io Embed Theme
Author: Justin Perry <http://github.com/ourmaninamsterdam>
Original theme - https://github.com/chriskempson/tomorrow-theme
*/
.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
background: #222;
color: #fff;
}
.hljs-comment,
.hljs-quote {
color: #777;
}
.hljs-variable,
.hljs-template-variable,
.hljs-tag,
.hljs-regexp,
.hljs-meta,
.hljs-number,
.hljs-built_in,
.hljs-builtin-name,
.hljs-literal,
.hljs-params,
.hljs-symbol,
.hljs-bullet,
.hljs-link,
.hljs-deletion {
color: #ab875d;
}
.hljs-section,
.hljs-title,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class,
.hljs-type,
.hljs-attribute {
color: #9b869b;
}
.hljs-string,
.hljs-keyword,
.hljs-selector-tag,
.hljs-addition {
color: #8f9c6c;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}

View File

@ -0,0 +1,71 @@
/*
Colorbrewer theme
Original: https://github.com/mbostock/colorbrewer-theme (c) Mike Bostock <mike@ocks.org>
Ported by Fabrício Tavares de Oliveira
*/
.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
background: #fff;
}
.hljs,
.hljs-subst {
color: #000;
}
.hljs-string,
.hljs-meta,
.hljs-symbol,
.hljs-template-tag,
.hljs-template-variable,
.hljs-addition {
color: #756bb1;
}
.hljs-comment,
.hljs-quote {
color: #636363;
}
.hljs-number,
.hljs-regexp,
.hljs-literal,
.hljs-bullet,
.hljs-link {
color: #31a354;
}
.hljs-deletion,
.hljs-variable {
color: #88f;
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-title,
.hljs-section,
.hljs-built_in,
.hljs-doctag,
.hljs-type,
.hljs-tag,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class,
.hljs-strong {
color: #3182bd;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-attribute {
color: #e6550d;
}

77
3rdparty/highlight/styles/darcula.css vendored Normal file
View File

@ -0,0 +1,77 @@
/*
Darcula color scheme from the JetBrains family of IDEs
*/
.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
background: #2b2b2b;
}
.hljs {
color: #bababa;
}
.hljs-strong,
.hljs-emphasis {
color: #a8a8a2;
}
.hljs-bullet,
.hljs-quote,
.hljs-link,
.hljs-number,
.hljs-regexp,
.hljs-literal {
color: #6896ba;
}
.hljs-code,
.hljs-selector-class {
color: #a6e22e;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-section,
.hljs-attribute,
.hljs-name,
.hljs-variable {
color: #cb7832;
}
.hljs-params {
color: #b9b9b9;
}
.hljs-string {
color: #6a8759;
}
.hljs-subst,
.hljs-type,
.hljs-built_in,
.hljs-builtin-name,
.hljs-symbol,
.hljs-selector-id,
.hljs-selector-attr,
.hljs-selector-pseudo,
.hljs-template-tag,
.hljs-template-variable,
.hljs-addition {
color: #e0c46c;
}
.hljs-comment,
.hljs-deletion,
.hljs-meta {
color: #7f7f7f;
}

63
3rdparty/highlight/styles/dark.css vendored Normal file
View File

@ -0,0 +1,63 @@
/*
Dark style from softwaremaniacs.org (c) Ivan Sagalaev <Maniac@SoftwareManiacs.Org>
*/
.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
background: #444;
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-literal,
.hljs-section,
.hljs-link {
color: white;
}
.hljs,
.hljs-subst {
color: #ddd;
}
.hljs-string,
.hljs-title,
.hljs-name,
.hljs-type,
.hljs-attribute,
.hljs-symbol,
.hljs-bullet,
.hljs-built_in,
.hljs-addition,
.hljs-variable,
.hljs-template-tag,
.hljs-template-variable {
color: #d88;
}
.hljs-comment,
.hljs-quote,
.hljs-deletion,
.hljs-meta {
color: #777;
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-literal,
.hljs-title,
.hljs-section,
.hljs-doctag,
.hljs-type,
.hljs-name,
.hljs-strong {
font-weight: bold;
}
.hljs-emphasis {
font-style: italic;
}

6
3rdparty/highlight/styles/darkula.css vendored Normal file
View File

@ -0,0 +1,6 @@
/*
Deprecated due to a typo in the name and left here for compatibility purpose only.
Please use darcula.css instead.
*/
@import url('darcula.css');

99
3rdparty/highlight/styles/default.css vendored Normal file
View File

@ -0,0 +1,99 @@
/*
Original highlight.js style (c) Ivan Sagalaev <maniac@softwaremaniacs.org>
*/
.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
background: #F0F0F0;
}
/* Base color: saturation 0; */
.hljs,
.hljs-subst {
color: #444;
}
.hljs-comment {
color: #888888;
}
.hljs-keyword,
.hljs-attribute,
.hljs-selector-tag,
.hljs-meta-keyword,
.hljs-doctag,
.hljs-name {
font-weight: bold;
}
/* User color: hue: 0 */
.hljs-type,
.hljs-string,
.hljs-number,
.hljs-selector-id,
.hljs-selector-class,
.hljs-quote,
.hljs-template-tag,
.hljs-deletion {
color: #880000;
}
.hljs-title,
.hljs-section {
color: #880000;
font-weight: bold;
}
.hljs-regexp,
.hljs-symbol,
.hljs-variable,
.hljs-template-variable,
.hljs-link,
.hljs-selector-attr,
.hljs-selector-pseudo {
color: #BC6060;
}
/* Language color: hue: 90; */
.hljs-literal {
color: #78A960;
}
.hljs-built_in,
.hljs-bullet,
.hljs-code,
.hljs-addition {
color: #397300;
}
/* Meta color: hue: 200 */
.hljs-meta {
color: #1f7199;
}
.hljs-meta-string {
color: #4d99bf;
}
/* Misc effects */
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}

97
3rdparty/highlight/styles/docco.css vendored Normal file
View File

@ -0,0 +1,97 @@
/*
Docco style used in http://jashkenas.github.com/docco/ converted by Simon Madine (@thingsinjars)
*/
.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
color: #000;
background: #f8f8ff;
}
.hljs-comment,
.hljs-quote {
color: #408080;
font-style: italic;
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-literal,
.hljs-subst {
color: #954121;
}
.hljs-number {
color: #40a070;
}
.hljs-string,
.hljs-doctag {
color: #219161;
}
.hljs-selector-id,
.hljs-selector-class,
.hljs-section,
.hljs-type {
color: #19469d;
}
.hljs-params {
color: #00f;
}
.hljs-title {
color: #458;
font-weight: bold;
}
.hljs-tag,
.hljs-name,
.hljs-attribute {
color: #000080;
font-weight: normal;
}
.hljs-variable,
.hljs-template-variable {
color: #008080;
}
.hljs-regexp,
.hljs-link {
color: #b68;
}
.hljs-symbol,
.hljs-bullet {
color: #990073;
}
.hljs-built_in,
.hljs-builtin-name {
color: #0086b3;
}
.hljs-meta {
color: #999;
font-weight: bold;
}
.hljs-deletion {
background: #fdd;
}
.hljs-addition {
background: #dfd;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}

76
3rdparty/highlight/styles/dracula.css vendored Normal file
View File

@ -0,0 +1,76 @@
/*
Dracula Theme v1.2.0
https://github.com/zenorocha/dracula-theme
Copyright 2015, All rights reserved
Code licensed under the MIT license
http://zenorocha.mit-license.org
@author Éverton Ribeiro <nuxlli@gmail.com>
@author Zeno Rocha <hi@zenorocha.com>
*/
.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
background: #282a36;
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-literal,
.hljs-section,
.hljs-link {
color: #8be9fd;
}
.hljs-function .hljs-keyword {
color: #ff79c6;
}
.hljs,
.hljs-subst {
color: #f8f8f2;
}
.hljs-string,
.hljs-title,
.hljs-name,
.hljs-type,
.hljs-attribute,
.hljs-symbol,
.hljs-bullet,
.hljs-addition,
.hljs-variable,
.hljs-template-tag,
.hljs-template-variable {
color: #f1fa8c;
}
.hljs-comment,
.hljs-quote,
.hljs-deletion,
.hljs-meta {
color: #6272a4;
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-literal,
.hljs-title,
.hljs-section,
.hljs-doctag,
.hljs-type,
.hljs-name,
.hljs-strong {
font-weight: bold;
}
.hljs-emphasis {
font-style: italic;
}

71
3rdparty/highlight/styles/far.css vendored Normal file
View File

@ -0,0 +1,71 @@
/*
FAR Style (c) MajestiC <majestic2k@gmail.com>
*/
.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
background: #000080;
}
.hljs,
.hljs-subst {
color: #0ff;
}
.hljs-string,
.hljs-attribute,
.hljs-symbol,
.hljs-bullet,
.hljs-built_in,
.hljs-builtin-name,
.hljs-template-tag,
.hljs-template-variable,
.hljs-addition {
color: #ff0;
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-section,
.hljs-type,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class,
.hljs-variable {
color: #fff;
}
.hljs-comment,
.hljs-quote,
.hljs-doctag,
.hljs-deletion {
color: #888;
}
.hljs-number,
.hljs-regexp,
.hljs-literal,
.hljs-link {
color: #0f0;
}
.hljs-meta {
color: #008080;
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-title,
.hljs-section,
.hljs-name,
.hljs-strong {
font-weight: bold;
}
.hljs-emphasis {
font-style: italic;
}

View File

@ -0,0 +1,88 @@
/*
Description: Foundation 4 docs style for highlight.js
Author: Dan Allen <dan.j.allen@gmail.com>
Website: http://foundation.zurb.com/docs/
Version: 1.0
Date: 2013-04-02
*/
.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
background: #eee; color: black;
}
.hljs-link,
.hljs-emphasis,
.hljs-attribute,
.hljs-addition {
color: #070;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong,
.hljs-string,
.hljs-deletion {
color: #d14;
}
.hljs-strong {
font-weight: bold;
}
.hljs-quote,
.hljs-comment {
color: #998;
font-style: italic;
}
.hljs-section,
.hljs-title {
color: #900;
}
.hljs-class .hljs-title,
.hljs-type {
color: #458;
}
.hljs-variable,
.hljs-template-variable {
color: #336699;
}
.hljs-bullet {
color: #997700;
}
.hljs-meta {
color: #3344bb;
}
.hljs-code,
.hljs-number,
.hljs-literal,
.hljs-keyword,
.hljs-selector-tag {
color: #099;
}
.hljs-regexp {
background-color: #fff0ff;
color: #880088;
}
.hljs-symbol {
color: #990073;
}
.hljs-tag,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class {
color: #007700;
}

View File

@ -0,0 +1,71 @@
/**
* GitHub Gist Theme
* Author : Louis Barranqueiro - https://github.com/LouisBarranqueiro
*/
.hljs {
display: block;
background: white;
padding: 0.5em;
color: #333333;
overflow-x: auto;
}
.hljs-comment,
.hljs-meta {
color: #969896;
}
.hljs-string,
.hljs-variable,
.hljs-template-variable,
.hljs-strong,
.hljs-emphasis,
.hljs-quote {
color: #df5000;
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-type {
color: #a71d5d;
}
.hljs-literal,
.hljs-symbol,
.hljs-bullet,
.hljs-attribute {
color: #0086b3;
}
.hljs-section,
.hljs-name {
color: #63a35c;
}
.hljs-tag {
color: #333333;
}
.hljs-title,
.hljs-attr,
.hljs-selector-id,
.hljs-selector-class,
.hljs-selector-attr,
.hljs-selector-pseudo {
color: #795da3;
}
.hljs-addition {
color: #55a532;
background-color: #eaffea;
}
.hljs-deletion {
color: #bd2c00;
background-color: #ffecec;
}
.hljs-link {
text-decoration: underline;
}

99
3rdparty/highlight/styles/github.css vendored Normal file
View File

@ -0,0 +1,99 @@
/*
github.com style (c) Vasily Polovnyov <vast@whiteants.net>
*/
.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
color: #333;
background: #f8f8f8;
}
.hljs-comment,
.hljs-quote {
color: #998;
font-style: italic;
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-subst {
color: #333;
font-weight: bold;
}
.hljs-number,
.hljs-literal,
.hljs-variable,
.hljs-template-variable,
.hljs-tag .hljs-attr {
color: #008080;
}
.hljs-string,
.hljs-doctag {
color: #d14;
}
.hljs-title,
.hljs-section,
.hljs-selector-id {
color: #900;
font-weight: bold;
}
.hljs-subst {
font-weight: normal;
}
.hljs-type,
.hljs-class .hljs-title {
color: #458;
font-weight: bold;
}
.hljs-tag,
.hljs-name,
.hljs-attribute {
color: #000080;
font-weight: normal;
}
.hljs-regexp,
.hljs-link {
color: #009926;
}
.hljs-symbol,
.hljs-bullet {
color: #990073;
}
.hljs-built_in,
.hljs-builtin-name {
color: #0086b3;
}
.hljs-meta {
color: #999;
font-weight: bold;
}
.hljs-deletion {
background: #fdd;
}
.hljs-addition {
background: #dfd;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}

View File

@ -0,0 +1,89 @@
/*
Google Code style (c) Aahan Krish <geekpanth3r@gmail.com>
*/
.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
background: white;
color: black;
}
.hljs-comment,
.hljs-quote {
color: #800;
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-section,
.hljs-title,
.hljs-name {
color: #008;
}
.hljs-variable,
.hljs-template-variable {
color: #660;
}
.hljs-string,
.hljs-selector-attr,
.hljs-selector-pseudo,
.hljs-regexp {
color: #080;
}
.hljs-literal,
.hljs-symbol,
.hljs-bullet,
.hljs-meta,
.hljs-number,
.hljs-link {
color: #066;
}
.hljs-title,
.hljs-doctag,
.hljs-type,
.hljs-attr,
.hljs-built_in,
.hljs-builtin-name,
.hljs-params {
color: #606;
}
.hljs-attribute,
.hljs-subst {
color: #000;
}
.hljs-formula {
background-color: #eee;
font-style: italic;
}
.hljs-selector-id,
.hljs-selector-class {
color: #9B703F
}
.hljs-addition {
background-color: #baeeba;
}
.hljs-deletion {
background-color: #ffc8bd;
}
.hljs-doctag,
.hljs-strong {
font-weight: bold;
}
.hljs-emphasis {
font-style: italic;
}

101
3rdparty/highlight/styles/grayscale.css vendored Normal file
View File

@ -0,0 +1,101 @@
/*
grayscale style (c) MY Sun <simonmysun@gmail.com>
*/
.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
color: #333;
background: #fff;
}
.hljs-comment,
.hljs-quote {
color: #777;
font-style: italic;
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-subst {
color: #333;
font-weight: bold;
}
.hljs-number,
.hljs-literal {
color: #777;
}
.hljs-string,
.hljs-doctag,
.hljs-formula {
color: #333;
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAYAAACp8Z5+AAAAJ0lEQVQIW2O8e/fufwYGBgZBQUEQxcCIIfDu3Tuwivfv30NUoAsAALHpFMMLqZlPAAAAAElFTkSuQmCC) repeat;
}
.hljs-title,
.hljs-section,
.hljs-selector-id {
color: #000;
font-weight: bold;
}
.hljs-subst {
font-weight: normal;
}
.hljs-class .hljs-title,
.hljs-type,
.hljs-name {
color: #333;
font-weight: bold;
}
.hljs-tag {
color: #333;
}
.hljs-regexp {
color: #333;
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAICAYAAADA+m62AAAAPUlEQVQYV2NkQAN37979r6yszIgujiIAU4RNMVwhuiQ6H6wQl3XI4oy4FMHcCJPHcDS6J2A2EqUQpJhohQDexSef15DBCwAAAABJRU5ErkJggg==) repeat;
}
.hljs-symbol,
.hljs-bullet,
.hljs-link {
color: #000;
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAKElEQVQIW2NkQAO7d+/+z4gsBhJwdXVlhAvCBECKwIIwAbhKZBUwBQA6hBpm5efZsgAAAABJRU5ErkJggg==) repeat;
}
.hljs-built_in,
.hljs-builtin-name {
color: #000;
text-decoration: underline;
}
.hljs-meta {
color: #999;
font-weight: bold;
}
.hljs-deletion {
color: #fff;
background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAADCAYAAABS3WWCAAAAE0lEQVQIW2MMDQ39zzhz5kwIAQAyxweWgUHd1AAAAABJRU5ErkJggg==) repeat;
}
.hljs-addition {
color: #000;
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAYAAADgkQYQAAAALUlEQVQYV2N89+7dfwYk8P79ewZBQUFkIQZGOiu6e/cuiptQHAPl0NtNxAQBAM97Oejj3Dg7AAAAAElFTkSuQmCC) repeat;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}

Some files were not shown because too many files have changed in this diff Show More