Commit bcadd727 authored by jlklein's avatar jlklein Committed by Commit bot

Pull web-animations-js into third-party via the...

Pull web-animations-js into third-party via the third_party/polymer/reproduce.sh script. Add necessary third_party bits.

R=cpu, dzhioev
BUG=424574

Review URL: https://codereview.chromium.org/917523002

Cr-Commit-Position: refs/heads/master@{#317119}
parent 202c0025
......@@ -383,6 +383,7 @@ v8.log
/third_party/v8-i18n
/third_party/valgrind
/third_party/v4l2capture
/third_party/web-animations-js
/third_party/webdriver/pylib
/third_party/webdriver/python/selenium
/third_party/webgl
......
......@@ -26,11 +26,12 @@ using ResourcesMap = base::hash_map<std::string, int>;
// TODO(rkc): Once we have a separate source for apps, remove '*/apps/' aliases.
const char* kPathAliases[][2] = {
{"../../../third_party/polymer/components-chromium/", "polymer/"},
{"../../resources/default_100_percent/common/", "images/apps/"},
{"../../resources/default_200_percent/common/", "images/2x/apps/"},
{"../../webui/resources/cr_elements/", "cr_elements/"}
};
{"../../../third_party/polymer/components-chromium/", "polymer/"},
{"../../../third_party/web-animations-js/sources/",
"polymer/web-animations-js/"},
{"../../resources/default_100_percent/common/", "images/apps/"},
{"../../resources/default_200_percent/common/", "images/2x/apps/"},
{"../../webui/resources/cr_elements/", "cr_elements/"}};
void AddResource(const std::string& path,
int resource_id,
......
......@@ -27,6 +27,9 @@ def _CheckBowerDependencies(input_api, output_api):
bower_dependencies = \
set(json.load(open(bower_json_path))['dependencies'].keys())
installed_components = set(p for p in os.listdir(components_dir))
# Add web-animations-js because we keep it in a separate directory
# '../third_party/web-animations-js'.
installed_components.add('web-animations-js')
if bower_dependencies == installed_components:
return []
......
......@@ -7,6 +7,7 @@
"core-a11y-keys": "Polymer/core-a11y-keys#0.5.2",
"core-ajax": "Polymer/core-ajax#0.5.2",
"core-animated-pages": "Polymer/core-animated-pages#0.5.2",
"core-animation": "Polymer/core-animation#0.5.4",
"core-collapse": "Polymer/core-collapse#0.5.2",
"core-drag-drop": "Polymer/core-drag-drop#0.5.2",
"core-drawer-panel": "Polymer/core-drawer-panel#0.5.2",
......@@ -63,6 +64,8 @@
"paper-spinner": "Polymer/paper-spinner#0.5.2",
"paper-tabs": "Polymer/paper-tabs#0.5.2",
"paper-toast": "Polymer/paper-toast#0.5.2",
"paper-toggle-button": "Polymer/paper-toggle-button#0.5.4"
"paper-toggle-button": "Polymer/paper-toggle-button#0.5.4",
"web-animations-js": "web-animations/web-animations-js#1.0.5"
}
}
{
"name": "core-animation",
"private": true,
"dependencies": {
"polymer": "Polymer/polymer#^0.5",
"web-animations-js": "web-animations/web-animations-js#1.0.5"
},
"version": "0.5.4",
"homepage": "https://github.com/Polymer/core-animation",
"_release": "0.5.4",
"_resolution": {
"type": "version",
"tag": "0.5.4",
"commit": "5063fb5efb55806f6d1f7c74471f4cdf96f974ce"
},
"_source": "git://github.com/Polymer/core-animation.git",
"_target": "0.5.4",
"_originalSource": "Polymer/core-animation"
}
\ No newline at end of file
core-animation
==============
See the [component page](http://polymer-project.org/docs/elements/core-elements.html#core-animation) for more information.
{
"name": "core-animation",
"private": true,
"dependencies": {
"polymer": "Polymer/polymer#^0.5",
"web-animations-js": "web-animations/web-animations-js#1.0.5"
},
"version": "0.5.4"
}
\ No newline at end of file
(function() {
var ANIMATION_GROUPS = {
'par': AnimationGroup,
'seq': AnimationSequence
};
Polymer('core-animation-group',{
publish: {
/**
* If target is set, any children without a target will be assigned the group's
* target when this property is set.
*
* @property target
* @type HTMLElement|Node|Array|Array<HTMLElement|Node>
*/
/**
* For a `core-animation-group`, a duration of "auto" means the duration should
* be the specified duration of its children. If set to anything other than
* "auto", any children without a set duration will be assigned the group's duration.
*
* @property duration
* @type number
* @default "auto"
*/
duration: {value: 'auto', reflect: true},
/**
* The type of the animation group. 'par' creates a parallel group and 'seq' creates
* a sequential group.
*
* @property type
* @type String
* @default 'par'
*/
type: {value: 'par', reflect: true}
},
typeChanged: function() {
this.apply();
},
targetChanged: function() {
// Only propagate target to children animations if it's defined.
if (this.target) {
this.doOnChildren(function(c) {
c.target = this.target;
}.bind(this));
}
},
durationChanged: function() {
if (this.duration && this.duration !== 'auto') {
this.doOnChildren(function(c) {
// Propagate to children that is not a group and has no
// duration specified.
if (!c.type && (!c.duration || c.duration === 'auto')) {
c.duration = this.duration;
}
}.bind(this));
}
},
doOnChildren: function(inFn) {
var children = this.children;
if (!children.length) {
children = this.shadowRoot ? this.shadowRoot.childNodes : [];
}
Array.prototype.forEach.call(children, function(c) {
// TODO <template> in the way
c.apply && inFn(c);
}, this);
},
makeAnimation: function() {
return new ANIMATION_GROUPS[this.type](this.childAnimations, this.timingProps);
},
hasTarget: function() {
var ht = this.target !== null;
if (!ht) {
this.doOnChildren(function(c) {
ht = ht || c.hasTarget();
}.bind(this));
}
return ht;
},
apply: function() {
// Propagate target and duration to child animations first.
this.durationChanged();
this.targetChanged();
this.doOnChildren(function(c) {
c.apply();
});
return this.super();
},
get childAnimationElements() {
var list = [];
this.doOnChildren(function(c) {
if (c.makeAnimation) {
list.push(c);
}
});
return list;
},
get childAnimations() {
var list = [];
this.doOnChildren(function(c) {
if (c.animation) {
list.push(c.animation);
}
});
return list;
}
});
})();
\ No newline at end of file
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
--><html><head><link rel="import" href="../polymer/polymer.html">
<link rel="import" href="core-animation.html">
<!--
@group Polymer Core Elements
`core-animation-group` combines `core-animation` or `core-animation-group` elements to
create a grouped web animation. The group may be parallel (type is `par`) or sequential
(type is `seq`). Parallel groups play all the children elements simultaneously, and
sequential groups play the children one after another.
Example of an animation group to rotate and then fade an element:
<core-animation-group type="seq">
<core-animation id="fadeout" duration="500">
<core-animation-keyframe>
<core-animation-prop name="transform" value="rotate(0deg)"></core-animation-prop>
<core-animation-prop name="transform" value="rotate(45deg)"></core-animation-prop>
</core-animation-keyframe>
</core-animation>
<core-animation id="fadeout" duration="500">
<core-animation-keyframe>
<core-animation-prop name="opacity" value="1"></core-animation-prop>
</core-animation-keyframe>
<core-animation-keyframe>
<core-animation-prop name="opacity" value="0"></core-animation-prop>
</core-animation-keyframe>
</core-animation>
</core-animation-group>
@element core-animation-group
@status beta
@homepage github.io
-->
</head><body><polymer-element name="core-animation-group" constructor="CoreAnimationGroup" extends="core-animation" attributes="type" assetpath="">
</polymer-element>
<script charset="utf-8" src="core-animation-group-extracted.js"></script></body></html>
\ No newline at end of file
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
--><html><head><link rel="import" href="../polymer/polymer.html">
<link rel="import" href="web-animations.html">
<!--
@group Polymer Core Elements
`core-animation` is a convenience element to use web animations with Polymer elements. It
allows you to create a web animation declaratively. You can extend this class to create
new types of animations and combine them with `core-animation-group`.
Example to create animation to fade out an element over 500ms:
<core-animation id="fadeout" duration="500">
<core-animation-keyframe>
<core-animation-prop name="opacity" value="1"></core-animation-prop>
</core-animation-keyframe>
<core-animation-keyframe>
<core-animation-prop name="opacity" value="0"></core-animation-prop>
</core-animation-keyframe>
</core-animation>
<div id="el">Fade me out</div>
<script>
var animation = document.getElementById('fadeout');
animation.target = document.getElementById('el');
animation.play();
</script>
Or do the same imperatively:
var animation = new CoreAnimation();
animation.duration = 500;
animation.keyframes = [
{opacity: 1},
{opacity: 0}
];
animation.target = document.getElementById('el');
animation.play();
You can also provide a javascript function instead of keyframes to the animation. This
behaves essentially the same as `requestAnimationFrame`:
var animation = new CoreAnimation();
animation.customEffect = function(timeFraction, target, animation) {
// do something custom
};
animation.play();
Elements that are targets to a `core-animation` are given the `core-animation-target` class.
@element core-animation
@status beta
@homepage github.io
-->
</head><body><polymer-element name="core-animation" constructor="CoreAnimation" attributes="target keyframes customEffect composite duration fill easing iterationStart iterationCount delay direction autoplay targetSelector" assetpath="">
</polymer-element>
<!--
`core-animation-keyframe` represents a keyframe in a `core-animation`. Use them as children of
`core-animation` elements to create web animations declaratively. If the `offset` property is
unset, the keyframes will be distributed evenly within the animation duration. Use
`core-animation-prop` elements as children of this element to specify the CSS properties for
the animation.
@element core-animation-keyframe
@status beta
@homepage github.io
-->
<polymer-element name="core-animation-keyframe" attributes="offset" assetpath="">
</polymer-element>
<!--
`core-animation-prop` represents a CSS property and value pair to use with
`core-animation-keyframe`.
@element core-animation-prop
@status beta
@homepage github.io
-->
<polymer-element name="core-animation-prop" attributes="name value" assetpath="">
</polymer-element>
<script charset="utf-8" src="core-animation-extracted.js"></script></body></html>
\ No newline at end of file
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<title>core-animation</title>
<script src="../webcomponentsjs/webcomponents.js"></script>
<link href="../font-roboto/roboto.html" rel="import">
<link href="../core-icon/core-icon.html" rel="import">
<link href="../core-icons/core-icons.html" rel="import">
<link href="core-animation.html" rel="import">
<link href="core-animation-group.html" rel="import">
<style shim-shadowdom>
body {
font-family: RobotoDraft, 'Helvetica Neue', Helvetica, Arial;
font-size: 14px;
margin: 0;
padding: 24px;
-webkit-tap-highlight-color: rgba(0,0,0,0);
-webkit-touch-callout: none;
}
section {
padding: 20px 0;
}
section > div {
padding: 14px;
font-size: 16px;
}
html /deep/ core-icon {
height: 48px;
width: 48px;
}
#target {
display: inline-block;
font-size: 32px;
-webkit-transform: translateZ(0);
transform: translateZ(0);
}
</style>
</head>
<body unresolved onclick="clickAction(event);">
<section>
<div>
<div id="target" layout horizontal center>
<core-icon icon="polymer"></core-icon>
<span>polymer</span>
</div>
</div>
<button>
opacity
<core-animation id="raw" duration="1000">
<core-animation-keyframe>
<core-animation-prop name="opacity" value="1">
</core-animation-prop>
</core-animation-keyframe>
<core-animation-keyframe>
<core-animation-prop name="opacity" value="0.3">
</core-animation-prop>
</core-animation-keyframe>
<core-animation-keyframe>
<core-animation-prop name="opacity" value="1">
</core-animation-prop>
</core-animation-keyframe>
</core-animation>
</button>
<button>
group: opacity + scale
<core-animation-group type="seq">
<core-animation duration="300">
<core-animation-keyframe>
<core-animation-prop name="opacity" value="1">
</core-animation-prop>
</core-animation-keyframe>
<core-animation-keyframe>
<core-animation-prop name="opacity" value="0.3">
</core-animation-prop>
</core-animation-keyframe>
<core-animation-keyframe>
<core-animation-prop name="opacity" value="1">
</core-animation-prop>
</core-animation-keyframe>
</core-animation>
<core-animation duration="300">
<core-animation-keyframe>
<core-animation-prop name="transform" value="scale(1)">
</core-animation-prop>
</core-animation-keyframe>
<core-animation-keyframe>
<core-animation-prop name="transform" value="scale(1.2)">
</core-animation-prop>
</core-animation-keyframe>
<core-animation-keyframe>
<core-animation-prop name="transform" value="scale(1)">
</core-animation-prop>
</core-animation-keyframe>
</core-animation>
</core-animation-group>
</button>
<button>
infinite duration
<core-animation duration="1000" iterations="Infinity" direction="alternate">
<core-animation-keyframe>
<core-animation-prop name="opacity" value="1">
</core-animation-prop>
</core-animation-keyframe>
<core-animation-keyframe>
<core-animation-prop name="opacity" value="0.3">
</core-animation-prop>
</core-animation-keyframe>
</core-animation>
</button>
<button>
custom effect
<core-animation id="custom-animation" duration="500"></core-animation>
</button>
</section>
<script>
var player;
document.body.addEventListener('core-animation-finish', function(e) {
console.log('core-animation-finish');
if (player) {
player.cancel();
player = null;
target.querySelector('span').textContent = 'polymer';
}
});
var customAnimationFn = function(timeFraction, target) {
// var colors = [
// '#db4437',
// '#ff9800',
// '#ffeb3b',
// '#0f9d58',
// '#4285f4',
// '#3f51b5',
// '#9c27b0'
// ];
target.querySelector('span').textContent = timeFraction;
};
function clickAction(e) {
var t = e.target;
if (e.target.localName !== 'button') {
return;
}
if (player) {
player.cancel();
}
var a = t.querySelector('core-animation,core-animation-group');
if (a.id === 'custom-animation') {
a.customEffect = customAnimationFn;
}
a.target = document.getElementById('target');
player = a.play();
}
</script>
</body>
</html>
<!doctype html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE
The complete set of authors may be found at http://polymer.github.io/AUTHORS
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS
-->
<html>
<head>
<script src="../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="../core-component-page/core-component-page.html">
</head>
<body unresolved>
<core-component-page sources='["core-animation.html", "core-animation-group.html"]'></core-component-page>
</body>
</html>
<!doctype html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<title>core-animation tests</title>
<script src="../../web-component-tester/browser.js"></script>
</head>
<body>
<script>
WCT.loadSuites([
// 'basic.html'
]);
</script>
</body>
</html>
<!--
@license
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<script src="../web-animations-js/web-animations-next-lite.min.js"></script>
{
"name": "core-animation",
"private": true,
"dependencies": {
"polymer": "Polymer/polymer#^0.5",
"web-animations-js": "web-animations/web-animations-js#1.0.5"
},
"version": "0.5.4",
"homepage": "https://github.com/Polymer/core-animation",
"_release": "0.5.4",
"_resolution": {
"type": "version",
"tag": "0.5.4",
"commit": "5063fb5efb55806f6d1f7c74471f4cdf96f974ce"
},
"_source": "git://github.com/Polymer/core-animation.git",
"_target": "0.5.4",
"_originalSource": "Polymer/core-animation"
}
\ No newline at end of file
core-animation
==============
See the [component page](http://polymer-project.org/docs/elements/core-elements.html#core-animation) for more information.
{
"name": "core-animation",
"private": true,
"dependencies": {
"polymer": "Polymer/polymer#^0.5",
"web-animations-js": "web-animations/web-animations-js#1.0.5"
},
"version": "0.5.4"
}
\ No newline at end of file
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="core-animation.html">
<!--
@group Polymer Core Elements
`core-animation-group` combines `core-animation` or `core-animation-group` elements to
create a grouped web animation. The group may be parallel (type is `par`) or sequential
(type is `seq`). Parallel groups play all the children elements simultaneously, and
sequential groups play the children one after another.
Example of an animation group to rotate and then fade an element:
<core-animation-group type="seq">
<core-animation id="fadeout" duration="500">
<core-animation-keyframe>
<core-animation-prop name="transform" value="rotate(0deg)"></core-animation-prop>
<core-animation-prop name="transform" value="rotate(45deg)"></core-animation-prop>
</core-animation-keyframe>
</core-animation>
<core-animation id="fadeout" duration="500">
<core-animation-keyframe>
<core-animation-prop name="opacity" value="1"></core-animation-prop>
</core-animation-keyframe>
<core-animation-keyframe>
<core-animation-prop name="opacity" value="0"></core-animation-prop>
</core-animation-keyframe>
</core-animation>
</core-animation-group>
@element core-animation-group
@status beta
@homepage github.io
-->
<polymer-element name="core-animation-group" constructor="CoreAnimationGroup" extends="core-animation" attributes="type">
<script>
(function() {
var ANIMATION_GROUPS = {
'par': AnimationGroup,
'seq': AnimationSequence
};
Polymer({
publish: {
/**
* If target is set, any children without a target will be assigned the group's
* target when this property is set.
*
* @property target
* @type HTMLElement|Node|Array|Array<HTMLElement|Node>
*/
/**
* For a `core-animation-group`, a duration of "auto" means the duration should
* be the specified duration of its children. If set to anything other than
* "auto", any children without a set duration will be assigned the group's duration.
*
* @property duration
* @type number
* @default "auto"
*/
duration: {value: 'auto', reflect: true},
/**
* The type of the animation group. 'par' creates a parallel group and 'seq' creates
* a sequential group.
*
* @property type
* @type String
* @default 'par'
*/
type: {value: 'par', reflect: true}
},
typeChanged: function() {
this.apply();
},
targetChanged: function() {
// Only propagate target to children animations if it's defined.
if (this.target) {
this.doOnChildren(function(c) {
c.target = this.target;
}.bind(this));
}
},
durationChanged: function() {
if (this.duration && this.duration !== 'auto') {
this.doOnChildren(function(c) {
// Propagate to children that is not a group and has no
// duration specified.
if (!c.type && (!c.duration || c.duration === 'auto')) {
c.duration = this.duration;
}
}.bind(this));
}
},
doOnChildren: function(inFn) {
var children = this.children;
if (!children.length) {
children = this.shadowRoot ? this.shadowRoot.childNodes : [];
}
Array.prototype.forEach.call(children, function(c) {
// TODO <template> in the way
c.apply && inFn(c);
}, this);
},
makeAnimation: function() {
return new ANIMATION_GROUPS[this.type](this.childAnimations, this.timingProps);
},
hasTarget: function() {
var ht = this.target !== null;
if (!ht) {
this.doOnChildren(function(c) {
ht = ht || c.hasTarget();
}.bind(this));
}
return ht;
},
apply: function() {
// Propagate target and duration to child animations first.
this.durationChanged();
this.targetChanged();
this.doOnChildren(function(c) {
c.apply();
});
return this.super();
},
get childAnimationElements() {
var list = [];
this.doOnChildren(function(c) {
if (c.makeAnimation) {
list.push(c);
}
});
return list;
},
get childAnimations() {
var list = [];
this.doOnChildren(function(c) {
if (c.animation) {
list.push(c.animation);
}
});
return list;
}
});
})();
</script>
</polymer-element>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<title>core-animation</title>
<script src="../webcomponentsjs/webcomponents.js"></script>
<link href="../font-roboto/roboto.html" rel="import">
<link href="../core-icon/core-icon.html" rel="import">
<link href="../core-icons/core-icons.html" rel="import">
<link href="core-animation.html" rel="import">
<link href="core-animation-group.html" rel="import">
<style shim-shadowdom>
body {
font-family: RobotoDraft, 'Helvetica Neue', Helvetica, Arial;
font-size: 14px;
margin: 0;
padding: 24px;
-webkit-tap-highlight-color: rgba(0,0,0,0);
-webkit-touch-callout: none;
}
section {
padding: 20px 0;
}
section > div {
padding: 14px;
font-size: 16px;
}
html /deep/ core-icon {
height: 48px;
width: 48px;
}
#target {
display: inline-block;
font-size: 32px;
-webkit-transform: translateZ(0);
transform: translateZ(0);
}
</style>
</head>
<body unresolved onclick="clickAction(event);">
<section>
<div>
<div id="target" layout horizontal center>
<core-icon icon="polymer"></core-icon>
<span>polymer</span>
</div>
</div>
<button>
opacity
<core-animation id="raw" duration="1000">
<core-animation-keyframe>
<core-animation-prop name="opacity" value="1">
</core-animation-prop>
</core-animation-keyframe>
<core-animation-keyframe>
<core-animation-prop name="opacity" value="0.3">
</core-animation-prop>
</core-animation-keyframe>
<core-animation-keyframe>
<core-animation-prop name="opacity" value="1">
</core-animation-prop>
</core-animation-keyframe>
</core-animation>
</button>
<button>
group: opacity + scale
<core-animation-group type="seq">
<core-animation duration="300">
<core-animation-keyframe>
<core-animation-prop name="opacity" value="1">
</core-animation-prop>
</core-animation-keyframe>
<core-animation-keyframe>
<core-animation-prop name="opacity" value="0.3">
</core-animation-prop>
</core-animation-keyframe>
<core-animation-keyframe>
<core-animation-prop name="opacity" value="1">
</core-animation-prop>
</core-animation-keyframe>
</core-animation>
<core-animation duration="300">
<core-animation-keyframe>
<core-animation-prop name="transform" value="scale(1)">
</core-animation-prop>
</core-animation-keyframe>
<core-animation-keyframe>
<core-animation-prop name="transform" value="scale(1.2)">
</core-animation-prop>
</core-animation-keyframe>
<core-animation-keyframe>
<core-animation-prop name="transform" value="scale(1)">
</core-animation-prop>
</core-animation-keyframe>
</core-animation>
</core-animation-group>
</button>
<button>
infinite duration
<core-animation duration="1000" iterations="Infinity" direction="alternate">
<core-animation-keyframe>
<core-animation-prop name="opacity" value="1">
</core-animation-prop>
</core-animation-keyframe>
<core-animation-keyframe>
<core-animation-prop name="opacity" value="0.3">
</core-animation-prop>
</core-animation-keyframe>
</core-animation>
</button>
<button>
custom effect
<core-animation id="custom-animation" duration="500"></core-animation>
</button>
</section>
<script>
var player;
document.body.addEventListener('core-animation-finish', function(e) {
console.log('core-animation-finish');
if (player) {
player.cancel();
player = null;
target.querySelector('span').textContent = 'polymer';
}
});
var customAnimationFn = function(timeFraction, target) {
// var colors = [
// '#db4437',
// '#ff9800',
// '#ffeb3b',
// '#0f9d58',
// '#4285f4',
// '#3f51b5',
// '#9c27b0'
// ];
target.querySelector('span').textContent = timeFraction;
};
function clickAction(e) {
var t = e.target;
if (e.target.localName !== 'button') {
return;
}
if (player) {
player.cancel();
}
var a = t.querySelector('core-animation,core-animation-group');
if (a.id === 'custom-animation') {
a.customEffect = customAnimationFn;
}
a.target = document.getElementById('target');
player = a.play();
}
</script>
</body>
</html>
<!doctype html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE
The complete set of authors may be found at http://polymer.github.io/AUTHORS
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS
-->
<html>
<head>
<script src="../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="../core-component-page/core-component-page.html">
</head>
<body unresolved>
<core-component-page sources='["core-animation.html", "core-animation-group.html"]'></core-component-page>
</body>
</html>
<!doctype html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<title>core-animation tests</title>
<script src="../../web-component-tester/browser.js"></script>
</head>
<body>
<script>
WCT.loadSuites([
// 'basic.html'
]);
</script>
</body>
</html>
<!--
@license
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<script src="../web-animations-js/web-animations-next-lite.min.js"></script>
......@@ -14,9 +14,19 @@ set -e
cd "$(dirname "$0")"
rm -rf components components-chromium
rm -rf ../web-animations-js/sources
bower install
rm -rf components/web-animations-js/{test,node_modules}
# TODO(jlklein): Remove when
# https://github.com/web-animations/web-animations-next/pull/289 is released
# and the version of web-animations-js is bumped in bower.json.
rm components/web-animations-js/.travis-setup.sh
mv components/web-animations-js ../web-animations-js/sources
cp ../web-animations-js/sources/COPYING ../web-animations-js/LICENSE
# These components are deprecated or needed only for demos.
rm -rf components/{core-component-page,core-field,font-roboto,webcomponentsjs}
......
This diff is collapsed.
dzhioev@chromium.org
\ No newline at end of file
Name: Web Animations JS
Short Name: web-animations-js
URL: https://github.com/web-animations/web-animations-js
Version: 1.0.5
License: Apache 2.0
License File: LICENSE
Security Critical: no
Description:
An emulator of the Web Animations specification. Web Animations is a new
specification for animated content on the web. It's being developed as a W3C
specification as part of the CSS and SVG working groups. Latest specification at
http://w3c.github.io/web-animations/.
Used as a dependency of Polymer framework (see src/third_party/polymer). If
using directly, rather than through Polymer, use only the minified source.
Otherwise there may be CSP issues with inline scripts, etc. This should only
be updated via third_party/polymer/reproduce.sh after bumping the version number
in third_party/polymer/bower.json.
Local Modifications:
- The test and node_modules directories were removed. COPYING was renamed to LICENSE.
- Delete .travis-setup.sh because it is missing a license header. The header
has been added upstream in
https://github.com/web-animations/web-animations-next/pull/289. Once that is
released, .travis-setup.sh can be added back in.
{
"name": "web-animations-js",
"homepage": "https://github.com/web-animations/web-animations-js",
"version": "1.0.5",
"_release": "1.0.5",
"_resolution": {
"type": "version",
"tag": "1.0.5",
"commit": "5e9572828eaae1357e4e43485b7cab1feef17710"
},
"_source": "git://github.com/web-animations/web-animations-js.git",
"_target": "1.0.5",
"_originalSource": "web-animations/web-animations-js"
}
\ No newline at end of file
language: node_js
node_js:
- "0.10"
install:
- BROWSER="Firefox-aurora" ./.travis-setup.sh
before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
This diff is collapsed.
This diff is collapsed.
### 1.0.5 - *January 6 2015*
* Fix loading the polyfill in an SVG document
* Fix a problem where groups didn't take effect in their first frame
* Don't rely on performance.now
### 1.0.4 - *December 8 2014*
* Fix a critical bug where deprecation logic wasn't being loaded
when `web-animations-next` and `web-animations-next-lite` were
executed on top of a native `element.animate`.
### 1.0.3 - *December 4 2014*
* Fix a critical bug on iOS 7 and Safari <= 6. Due to limitations,
inline style patching is not supported on these platforms.
### 1.0.2 - *November 28 2014*
* Deprecated `AnimationTiming.playbackRate`.
For example, this is no longer supported:
var player = element.animate(
keyframes,
{duration: 1000, playbackRate: 2});
Use `AnimationPlayer.playbackRate` instead:
var player = element.animate(
keyframes,
{duration: 1000});
player.playbackRate = 2;
If you have any feedback on this change, please start a discussion
on the public-fx mailing list:
http://lists.w3.org/Archives/Public/public-fx/
Or file an issue against the specification on GitHub:
https://github.com/w3c/web-animations/issues/new
### 1.0.1 - *November 26 2014*
* Players should be constructed in idle state
* `play()` and `reverse()` should not force a start times
* Add `requestAnimationFrame` ids and `cancelAnimationFrame`
### 1.0.0 — *November 21 2014*
The web-animations-js hackers are pleased to announce the release of
a new codebase for the Web Animations Polyfill:
https://github.com/web-animations/web-animations-js
The previous polyfill has been moved to:
https://github.com/web-animations/web-animations-js-legacy
The new codebase is focused on code-size -- our smallest target is
now only 33kb or 11kb after gzip.
We've implemented native fallback. If the target browser provides
Web Animations features natively, the Polyfill will use them.
We now provide three different build targets:
`web-animations.min.js` - Tracks the Web Animations features that
are supported natively in browsers. Today that means Element.animate
and Playback Control in Chrome. If you’re not sure what features you
will need, start with this.
`web-animations-next.min.js` - All of web-animations.min.js plus
features that are still undergoing discussion or have yet to be
implemented natively.
`web-animations-next-lite.min.js` - A cut down version of
web-animations-next, removes several lesser used property handlers
and some of the larger and less used features such as matrix
interpolation/decomposition.
Not all features of the previous polyfill have been ported to the
new codebase; most notably mutation of Animations and Groups and
Additive Animations are not yet supported. These features are still
important and will be implemented in the coming weeks.
Quick Start
-----------
To provide native Chrome Web Animation features (`Element.animate` and Playback
Control) in other browsers, use `web-animations.min.js`. To explore all of the
proposed Web Animations API, use `web-animations-next.min.js`.
What is Web Animations?
-----------------------
Web Animations is a new JavaScript API for driving animated content on the web.
By unifying the animation features of SVG and CSS, Web Animations unlocks
features previously only usable declaratively, and exposes powerful,
high-performance animation capabilities to developers.
For more details see the
[W3C specification](http://w3c.github.io/web-animations/).
What is the polyfill?
---------------------
The polyfill is a JavaScript implementation of the Web Animations API. It works
on modern versions of all major browsers. For more details about browser
support see <https://www.polymer-project.org/resources/compatibility.html>.
Getting Started
---------------
Here's a simple example of an animation that scales and changes the opacity of
a `<div>` over 0.5 seconds. The animation alternates producing a pulsing
effect.
<script src="web-animations.min.js"></script>
<div class="pulse" style="width:150px;">Hello world!</div>
<script>
var elem = document.querySelector('.pulse');
var player = elem.animate([
{opacity: 0.5, transform: "scale(0.5)"},
{opacity: 1.0, transform: "scale(1)"}
], {
direction: 'alternate',
duration: 500,
iterations: Infinity
});
</script>
Web Animations supports off-main-thread animations, and also allows procedural
generation of animations and fine-grained control of animation playback. See
<http://web-animations.github.io> for ideas and inspiration!
Native Fallback
---------------
When the polyfill runs on a browser that implements Element.animate and
AnimationPlayer Playback Control it will detect and use the underlying native
features.
Different Build Targets
-----------------------
### web-animations.min.js
Tracks the Web Animations features that are supported natively in browsers.
Today that means Element.animate and Playback Control in Chrome. If you’re not
sure what features you will need, start with this.
### web-animations-next.min.js
Contains all of web-animations.min.js plus features that are still undergoing
discussion or have yet to be implemented natively.
### web-animations-next-lite.min.js
A cut down version of web-animations-next, it removes several lesser used
property handlers and some of the larger and less used features such as matrix
interpolation/decomposition.
### Build Target Comparison
| | web-animations | web-animations-next | web-animations-next-lite |
|------------------------|:--------------:|:-------------------:|:------------------------:|
|Size (gzipped) | 12.5kb | 14kb | 10.5kb |
|Element.animate | ✔ | ✔ | ✔ |
|Timing input (easings, duration, fillMode, etc.) for animations| ✔ | ✔ | ✔ |
|Playback control | ✔ | ✔ | ✔ |
|Support for animating lengths, transforms and opacity| ✔ | ✔ | ✔ |
|Support for Animating other CSS properties| ✔ | ✔ | 🚫 |
|Matrix fallback for transform animations | ✔ | ✔ | 🚫 |
|Animation constructor | 🚫 | ✔ | ✔ |
|Simple Groups | 🚫 | ✔ | ✔ |
|Custom Effects | 🚫 | ✔ | ✔ |
|Timing input (easings, duration, fillMode, etc.) for groups</div>| 🚫 | 🚫\* | 🚫 |
|Additive animation | 🚫 | 🚫\* | 🚫 |
|Motion path | 🚫\* | 🚫\* | 🚫 |
|Modifiable animation timing| 🚫 | 🚫\* | 🚫\* |
|Modifiable group timing | 🚫 | 🚫\* | 🚫\* |
|Usable inline style\*\* | ✔ | ✔ | 🚫 |
\* support is planned for these features.
\*\* see inline style caveat below.
Caveats
-------
Some things won’t ever be faithful to the native implementation due to browser
and CSS API limitations. These include:
### Inline Style
Inline style modification is the mechanism used by the polyfill to animate
properties. Both web-animations and web-animations-next incorporate a module
that emulates a vanilla inline style object, so that style modification from
JavaScript can still work in the presence of animations. However, to keep the
size of web-animations-next-lite as small as possible, the style emulation
module is not included. When using this version of the polyfill, JavaScript
inline style modification will be overwritten by animations.
Due to browser constraints inline style modification is not supported on iOS 7
or Safari 6 (or earlier versions).
### Prefix handling
The polyfill will automatically detect the correctly prefixed name to use when
writing animated properties back to the platform. Where possible, the polyfill
will only accept unprefixed versions of experimental features. For example:
var animation = new Animation(elem, {"transform": "translate(100px, 100px)"}, 2000);
will work in all browsers that implement a conforming version of transform, but
var animation = new Animation(elem, {"-webkit-transform": "translate(100px, 100px)"}, 2000);
will not work anywhere.
API and Specification Feedback
------------------------------
File an issue on GitHub: <https://github.com/w3c/web-animations/issues/new>.
Alternatively, send an email to <public-fx@w3.org> with subject line
“[web-animations] … message topic …”
([archives](http://lists.w3.org/Archives/Public/public-fx/)).
Polyfill Issues
---------------
Report any issues with this implementation on GitHub:
<https://github.com/web-animations/web-animations-next/issues/new>.
Breaking changes
----------------
When we make a potentially breaking change to the polyfill's API
surface (like a rename) where possible we will continue supporting the
old version, deprecated, for three months, and ensure that there are
console warnings to indicate that a change is pending. After three
months, the old version of the API surface (e.g. the old version of a
function name) will be removed. *If you see deprecation warnings you
can't avoid it by not updating*.
We also announce anything that isn't a bug fix on
[web-animations-changes@googlegroups.com](https://groups.google.com/forum/#!forum/web-animations-changes).
{
"name": "web-animations-js",
"private": true,
"repository": {
"type": "git",
"url": "https://github.com/web-animations/web-animations-js.git"
},
"devDependencies": {
"mocha": "1.21.4",
"chai": "^1.9.1",
"grunt": "~0.4.5",
"grunt-contrib-uglify": "^0.4.0",
"grunt-gjslint": "^0.1.4",
"grunt-karma": "^0.8.2",
"karma": "^0.12.14",
"karma-mocha": "^0.1.3",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "~0.1.4",
"karma-firefox-launcher": "~0.1.3",
"karma-ie-launcher": "~0.1.5",
"karma-safari-launcher": "~0.1.1",
"karma-sauce-launcher": "~0.2.3",
"grunt-checkrepo": "~0.1.0",
"grunt-saucelabs": "~4.0.2",
"grunt-checkrepo": "~0.1.0",
"grunt-git-status": "~1.0.0",
"grunt-template": "~0.2.3",
"source-map": "~0.1.40"
},
"scripts": {
"test": "grunt test gjslint git-status checkrepo"
}
}
// Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
(function(shared, scope, testing) {
function groupChildDuration(node) {
return node._timing.delay + node.activeDuration + node._timing.endDelay;
};
function KeyframeEffect(effect) {
this._frames = shared.normalizeKeyframes(effect);
}
KeyframeEffect.prototype = {
getFrames: function() { return this._frames; }
};
scope.Animation = function(target, effect, timingInput) {
this.target = target;
// TODO: Store a clone, not the same instance.
this._timingInput = timingInput;
this._timing = shared.normalizeTimingInput(timingInput);
// TODO: Make modifications to timing update the underlying player
this.timing = shared.makeTiming(timingInput);
// TODO: Make this a live object - will need to separate normalization of
// keyframes into a shared module.
if (typeof effect == 'function')
this.effect = effect;
else
this.effect = new KeyframeEffect(effect);
this._effect = effect;
this.activeDuration = shared.calculateActiveDuration(this._timing);
return this;
};
var originalElementAnimate = Element.prototype.animate;
Element.prototype.animate = function(effect, timing) {
return scope.timeline.play(new scope.Animation(this, effect, timing));
};
var nullTarget = document.createElementNS('http://www.w3.org/1999/xhtml', 'div');
scope.newUnderlyingPlayerForAnimation = function(animation) {
var target = animation.target || nullTarget;
var effect = animation._effect;
if (typeof effect == 'function') {
effect = [];
}
return originalElementAnimate.apply(target, [effect, animation._timingInput]);
};
scope.bindPlayerForAnimation = function(player) {
if (player.source && typeof player.source.effect == 'function') {
scope.bindPlayerForCustomEffect(player);
}
};
var pendingGroups = [];
scope.awaitStartTime = function(groupPlayer) {
if (groupPlayer.startTime !== null || !groupPlayer._isGroup)
return;
if (pendingGroups.length == 0) {
requestAnimationFrame(updatePendingGroups);
}
pendingGroups.push(groupPlayer);
};
function updatePendingGroups() {
var updated = false;
while (pendingGroups.length) {
pendingGroups.shift()._updateChildren();
updated = true;
}
return updated;
}
var originalGetComputedStyle = window.getComputedStyle;
Object.defineProperty(window, 'getComputedStyle', {
configurable: true,
enumerable: true,
value: function() {
var result = originalGetComputedStyle.apply(this, arguments);
if (updatePendingGroups())
result = originalGetComputedStyle.apply(this, arguments);
return result;
},
});
// TODO: Call into this less frequently.
scope.Player.prototype._updateChildren = function() {
if (this.paused || !this.source || !this._isGroup)
return;
var offset = this.source._timing.delay;
for (var i = 0; i < this.source.children.length; i++) {
var child = this.source.children[i];
var childPlayer;
if (i >= this._childPlayers.length) {
childPlayer = window.document.timeline.play(child);
this._childPlayers.push(childPlayer);
} else {
childPlayer = this._childPlayers[i];
}
child.player = this.source.player;
if (childPlayer.startTime != this.startTime + offset) {
if (this.startTime === null) {
childPlayer.currentTime = this.source.player.currentTime - offset;
childPlayer._startTime = null;
} else {
childPlayer.startTime = this.startTime + offset;
}
childPlayer._updateChildren();
}
if (this.playbackRate == -1 && this.currentTime < offset && childPlayer.currentTime !== -1) {
childPlayer.currentTime = -1;
}
if (this.source instanceof window.AnimationSequence)
offset += groupChildDuration(child);
}
};
window.Animation = scope.Animation;
window.Element.prototype.getAnimationPlayers = function() {
return document.timeline.getAnimationPlayers().filter(function(player) {
return player.source !== null && player.source.target == this;
}.bind(this));
};
scope.groupChildDuration = groupChildDuration;
}(webAnimationsShared, webAnimationsNext, webAnimationsTesting));
// Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
(function(shared, scope) {
scope.AnimationNode = function(timing) {
var timeFraction = 0;
var activeDuration = shared.calculateActiveDuration(timing);
var animationNode = function(localTime) {
return shared.calculateTimeFraction(activeDuration, localTime, timing);
};
animationNode._totalDuration = timing.delay + activeDuration + timing.endDelay;
animationNode._isCurrent = function(localTime) {
var phase = shared.calculatePhase(activeDuration, localTime, timing);
return phase === PhaseActive || phase === PhaseBefore;
};
return animationNode;
};
})(webAnimationsShared, webAnimations1);
// Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
(function(shared, scope, testing) {
scope.Animation = function(target, effectInput, timingInput) {
var animationNode = scope.AnimationNode(shared.normalizeTimingInput(timingInput));
var effect = scope.convertEffectInput(effectInput);
var timeFraction;
var animation = function() {
WEB_ANIMATIONS_TESTING && console.assert(typeof timeFraction !== 'undefined');
effect(target, timeFraction);
};
// Returns whether the animation is in effect or not after the timing update.
animation._update = function(localTime) {
timeFraction = animationNode(localTime);
return timeFraction !== null;
};
animation._clear = function() {
effect(target, null);
};
animation._hasSameTarget = function(otherTarget) {
return target === otherTarget;
};
animation._isCurrent = animationNode._isCurrent;
animation._totalDuration = animationNode._totalDuration;
return animation;
};
scope.NullAnimation = function(clear) {
var nullAnimation = function() {
if (clear) {
clear();
clear = null;
}
};
nullAnimation._update = function() {
return null;
};
nullAnimation._totalDuration = 0;
nullAnimation._isCurrent = function() {
return false;
};
nullAnimation._hasSameTarget = function() {
return false;
};
return nullAnimation;
};
if (WEB_ANIMATIONS_TESTING) {
testing.webAnimations1Animation = scope.Animation;
}
})(webAnimationsShared, webAnimations1, webAnimationsTesting);
// Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
(function(scope, testing) {
var styleAttributes = {
cssText: 1,
length: 1,
parentRule: 1,
};
var styleMethods = {
getPropertyCSSValue: 1,
getPropertyPriority: 1,
getPropertyValue: 1,
item: 1,
removeProperty: 1,
setProperty: 1,
};
var styleMutatingMethods = {
removeProperty: 1,
setProperty: 1,
};
function configureProperty(object, property, descriptor) {
descriptor.enumerable = true;
descriptor.configurable = true;
Object.defineProperty(object, property, descriptor);
}
function AnimatedCSSStyleDeclaration(element) {
WEB_ANIMATIONS_TESTING && console.assert(!(element.style instanceof AnimatedCSSStyleDeclaration),
'Element must not already have an animated style attached.');
// Stores the inline style of the element on its behalf while the
// polyfill uses the element's inline style to simulate web animations.
// This is needed to fake regular inline style CSSOM access on the element.
this._surrogateStyle = document.createElementNS('http://www.w3.org/1999/xhtml', 'div').style;
this._style = element.style;
this._length = 0;
this._isAnimatedProperty = {};
// Copy the inline style contents over to the surrogate.
for (var i = 0; i < this._style.length; i++) {
var property = this._style[i];
this._surrogateStyle[property] = this._style[property];
}
this._updateIndices();
}
AnimatedCSSStyleDeclaration.prototype = {
get cssText() {
return this._surrogateStyle.cssText;
},
set cssText(text) {
var isAffectedProperty = {};
for (var i = 0; i < this._surrogateStyle.length; i++) {
isAffectedProperty[this._surrogateStyle[i]] = true;
}
this._surrogateStyle.cssText = text;
this._updateIndices();
for (var i = 0; i < this._surrogateStyle.length; i++) {
isAffectedProperty[this._surrogateStyle[i]] = true;
}
for (var property in isAffectedProperty) {
if (!this._isAnimatedProperty[property]) {
this._style.setProperty(property, this._surrogateStyle.getPropertyValue(property));
}
}
},
get length() {
return this._surrogateStyle.length;
},
get parentRule() {
return this._style.parentRule;
},
// Mirror the indexed getters and setters of the surrogate style.
_updateIndices: function() {
while (this._length < this._surrogateStyle.length) {
Object.defineProperty(this, this._length, {
configurable: true,
enumerable: false,
get: (function(index) {
return function() { return this._surrogateStyle[index]; };
})(this._length)
});
this._length++;
}
while (this._length > this._surrogateStyle.length) {
this._length--;
Object.defineProperty(this, this._length, {
configurable: true,
enumerable: false,
value: undefined
});
}
},
_set: function(property, value) {
this._style[property] = value;
this._isAnimatedProperty[property] = true;
},
_clear: function(property) {
this._style[property] = this._surrogateStyle[property];
delete this._isAnimatedProperty[property];
},
};
// Wrap the style methods.
for (var method in styleMethods) {
AnimatedCSSStyleDeclaration.prototype[method] = (function(method, modifiesStyle) {
return function() {
var result = this._surrogateStyle[method].apply(this._surrogateStyle, arguments);
if (modifiesStyle) {
if (!this._isAnimatedProperty[arguments[0]])
this._style[method].apply(this._style, arguments);
this._updateIndices();
}
return result;
}
})(method, method in styleMutatingMethods);
}
// Wrap the style.cssProperty getters and setters.
for (var property in document.documentElement.style) {
if (property in styleAttributes || property in styleMethods) {
continue;
}
(function(property) {
configureProperty(AnimatedCSSStyleDeclaration.prototype, property, {
get: function() {
return this._surrogateStyle[property];
},
set: function(value) {
this._surrogateStyle[property] = value;
this._updateIndices();
if (!this._isAnimatedProperty[property])
this._style[property] = value;
}
});
})(property);
}
function ensureStyleIsPatched(element) {
if (element._webAnimationsPatchedStyle)
return;
var animatedStyle = new AnimatedCSSStyleDeclaration(element);
try {
configureProperty(element, 'style', { get: function() { return animatedStyle; } });
} catch (_) {
// iOS and older versions of Safari (pre v7) do not support overriding an element's
// style object. Animations will clobber any inline styles as a result.
element.style._set = function(property, value) {
element.style[property] = value;
};
element.style._clear = function(property) {
element.style[property] = '';
};
}
// We must keep a handle on the patched style to prevent it from getting GC'd.
element._webAnimationsPatchedStyle = element.style;
}
scope.apply = function(element, property, value) {
ensureStyleIsPatched(element);
element.style._set(scope.propertyName(property), value);
};
scope.clear = function(element, property) {
if (element._webAnimationsPatchedStyle) {
element.style._clear(scope.propertyName(property));
}
};
if (WEB_ANIMATIONS_TESTING)
testing.ensureStyleIsPatched = ensureStyleIsPatched;
})(webAnimations1, webAnimationsTesting);
// Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
(function(scope, testing) {
scope.apply = function(element, property, value) {
element.style[scope.propertyName(property)] = value;
};
scope.clear = function(element, property) {
element.style[scope.propertyName(property)] = '';
};
})(webAnimations1, webAnimationsTesting);
// Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
(function(scope, testing) {
function consumeLengthPercentOrAuto(string) {
return scope.consumeLengthOrPercent(string) || scope.consumeToken(/^auto/, string);
}
function parseBox(string) {
var result = scope.consumeList([
scope.ignore(scope.consumeToken.bind(null, /^rect/)),
scope.ignore(scope.consumeToken.bind(null, /^\(/)),
scope.consumeRepeated.bind(null, consumeLengthPercentOrAuto, /^,/),
scope.ignore(scope.consumeToken.bind(null, /^\)/)),
], string);
if (result && result[0].length == 4) {
return result[0];
}
}
function mergeComponent(left, right) {
if (left == 'auto' || right == 'auto') {
return [true, false, function(t) {
var result = t ? left : right;
if (result == 'auto') {
return 'auto';
}
// FIXME: There's probably a better way to turn a dimension back into a string.
var merged = scope.mergeDimensions(result, result);
return merged[2](merged[0]);
}];
}
return scope.mergeDimensions(left, right);
}
function wrap(result) {
return 'rect(' + result + ')';
}
var mergeBoxes = scope.mergeWrappedNestedRepeated.bind(null, wrap, mergeComponent, ', ');
scope.parseBox = parseBox;
scope.mergeBoxes = mergeBoxes;
scope.addPropertiesHandler(parseBox, mergeBoxes, ['clip']);
})(webAnimations1, webAnimationsTesting);
// Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
(function(scope, testing) {
var canvas = document.createElementNS('http://www.w3.org/1999/xhtml', 'canvas');
canvas.width = canvas.height = 1;
var context = canvas.getContext('2d');
function parseColor(string) {
string = string.trim();
// The context ignores invalid colors
context.fillStyle = '#000';
context.fillStyle = string;
var contextSerializedFillStyle = context.fillStyle;
context.fillStyle = '#fff';
context.fillStyle = string;
if (contextSerializedFillStyle != context.fillStyle)
return;
context.fillRect(0, 0, 1, 1);
var pixelColor = context.getImageData(0, 0, 1, 1).data;
context.clearRect(0, 0, 1, 1);
var alpha = pixelColor[3] / 255;
return [pixelColor[0] * alpha, pixelColor[1] * alpha, pixelColor[2] * alpha, alpha];
}
function mergeColors(left, right) {
return [left, right, function(x) {
function clamp(v) {
return Math.max(0, Math.min(255, v));
}
if (x[3]) {
for (var i = 0; i < 3; i++)
x[i] = Math.round(clamp(x[i] / x[3]));
}
x[3] = scope.numberToString(scope.clamp(0, 1, x[3]));
return 'rgba(' + x.join(',') + ')';
}];
}
scope.addPropertiesHandler(parseColor, mergeColors,
['background-color', 'border-bottom-color', 'border-left-color', 'border-right-color',
'border-top-color', 'color', 'outline-color', 'text-decoration-color']);
scope.consumeColor = scope.consumeParenthesised.bind(null, parseColor);
scope.mergeColors = mergeColors;
if (WEB_ANIMATIONS_TESTING) {
testing.parseColor = parseColor;
}
})(webAnimations1, webAnimationsTesting);
// Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
(function(shared) {
var silenced = {};
shared.isDeprecated = function(feature, date, advice, plural) {
var auxVerb = plural ? 'are' : 'is';
var today = new Date();
var expiry = new Date(date);
expiry.setMonth(expiry.getMonth() + 3); // 3 months grace period
if (today < expiry) {
if (!(feature in silenced)) {
console.warn('Web Animations: ' + feature + ' ' + auxVerb + ' deprecated and will stop working on ' + expiry.toDateString() + '. ' + advice);
}
silenced[feature] = true;
return false;
} else {
return true;
}
};
shared.deprecated = function(feature, date, advice, plural) {
if (shared.isDeprecated(feature, date, advice, plural)) {
throw new Error(feature + ' ' + auxVerb + ' no longer supported. ' + advice);
}
};
})(webAnimationsShared);
// Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
var WEB_ANIMATIONS_TESTING = false;
var webAnimationsTesting = null;
// Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
(function(scope, testing) {
function parseDimension(unitRegExp, string) {
string = string.trim().toLowerCase();
if (string == '0' && 'px'.search(unitRegExp) >= 0)
return {px: 0};
// If we have parenthesis, we're a calc and need to start with 'calc'.
if (!/^[^(]*$|^calc/.test(string))
return;
string = string.replace(/calc\(/g, '(');
// We tag units by prefixing them with 'U' (note that we are already
// lowercase) to prevent problems with types which are substrings of
// each other (although prefixes may be problematic!)
var matchedUnits = {};
string = string.replace(unitRegExp, function(match) {
matchedUnits[match] = null;
return 'U' + match;
});
var taggedUnitRegExp = 'U(' + unitRegExp.source + ')';
// Validating input is simply applying as many reductions as we can.
var typeCheck = string.replace(/[-+]?(\d*\.)?\d+/g, 'N')
.replace(new RegExp('N' + taggedUnitRegExp, 'g'), 'D')
.replace(/\s[+-]\s/g, 'O')
.replace(/\s/g, '');
var reductions = [/N\*(D)/g, /(N|D)[*/]N/g, /(N|D)O\1/g, /\((N|D)\)/g];
var i = 0;
while (i < reductions.length) {
if (reductions[i].test(typeCheck)) {
typeCheck = typeCheck.replace(reductions[i], '$1');
i = 0;
} else {
i++;
}
}
if (typeCheck != 'D')
return;
for (var unit in matchedUnits) {
var result = eval(string.replace(new RegExp('U' + unit, 'g'), '').replace(new RegExp(taggedUnitRegExp, 'g'), '*0'));
if (!isFinite(result))
return;
matchedUnits[unit] = result;
}
return matchedUnits;
}
function mergeDimensionsNonNegative(left, right) {
return mergeDimensions(left, right, true);
}
function mergeDimensions(left, right, nonNegative) {
var units = [], unit;
for (unit in left)
units.push(unit);
for (unit in right) {
if (units.indexOf(unit) < 0)
units.push(unit);
}
left = units.map(function(unit) { return left[unit] || 0; });
right = units.map(function(unit) { return right[unit] || 0; });
return [left, right, function(values) {
var result = values.map(function(value, i) {
if (values.length == 1 && nonNegative) {
value = Math.max(value, 0);
}
// Scientific notation (e.g. 1e2) is not yet widely supported by browser vendors.
return scope.numberToString(value) + units[i];
}).join(' + ');
return values.length > 1 ? 'calc(' + result + ')' : result;
}];
}
var lengthUnits = 'px|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc';
var parseLength = parseDimension.bind(null, new RegExp(lengthUnits, 'g'));
var parseLengthOrPercent = parseDimension.bind(null, new RegExp(lengthUnits + '|%', 'g'));
var parseAngle = parseDimension.bind(null, /deg|rad|grad|turn/g);
scope.parseLength = parseLength;
scope.parseLengthOrPercent = parseLengthOrPercent;
scope.consumeLengthOrPercent = scope.consumeParenthesised.bind(null, parseLengthOrPercent);
scope.parseAngle = parseAngle;
scope.mergeDimensions = mergeDimensions;
var consumeLength = scope.consumeParenthesised.bind(null, parseLength);
var consumeSizePair = scope.consumeRepeated.bind(undefined, consumeLength, /^/);
var consumeSizePairList = scope.consumeRepeated.bind(undefined, consumeSizePair, /^,/);
scope.consumeSizePairList = consumeSizePairList;
var parseSizePairList = function(input) {
var result = consumeSizePairList(input);
if (result && result[1] == '') {
return result[0];
}
};
var mergeNonNegativeSizePair = scope.mergeNestedRepeated.bind(undefined, mergeDimensionsNonNegative, ' ');
var mergeNonNegativeSizePairList = scope.mergeNestedRepeated.bind(undefined, mergeNonNegativeSizePair, ',');
scope.mergeNonNegativeSizePair = mergeNonNegativeSizePair;
scope.addPropertiesHandler(parseSizePairList, mergeNonNegativeSizePairList, [
'background-size'
]);
scope.addPropertiesHandler(parseLengthOrPercent, mergeDimensionsNonNegative, [
'border-bottom-width',
'border-image-width',
'border-left-width',
'border-right-width',
'border-top-width',
'flex-basis',
'font-size',
'height',
'line-height',
'max-height',
'max-width',
'outline-width',
'width',
]);
scope.addPropertiesHandler(parseLengthOrPercent, mergeDimensions, [
'border-bottom-left-radius',
'border-bottom-right-radius',
'border-top-left-radius',
'border-top-right-radius',
'bottom',
'left',
'letter-spacing',
'margin-bottom',
'margin-left',
'margin-right',
'margin-top',
'min-height',
'min-width',
'outline-offset',
'padding-bottom',
'padding-left',
'padding-right',
'padding-top',
'perspective',
'right',
'shape-margin',
'text-indent',
'top',
'vertical-align',
'word-spacing',
]);
})(webAnimations1, webAnimationsTesting);
// Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
(function(shared, scope, testing) {
var nullTarget = document.createElementNS('http://www.w3.org/1999/xhtml', 'div');
var sequenceNumber = 0;
scope.bindPlayerForCustomEffect = function(player) {
var target = player.source.target;
var effect = player.source.effect;
var timing = player.source.timing;
var last = undefined;
timing = shared.normalizeTimingInput(timing);
var callback = function() {
var t = callback._player ? callback._player.currentTime : null;
if (t !== null) {
t = shared.calculateTimeFraction(shared.calculateActiveDuration(timing), t, timing);
if (isNaN(t))
t = null;
}
// FIXME: There are actually more conditions under which the effect
// should be called.
if (t !== last)
effect(t, target, player.source);
last = t;
};
callback._player = player;
callback._registered = false;
callback._sequenceNumber = sequenceNumber++;
player._callback = callback;
register(callback);
};
var callbacks = [];
var ticking = false;
function register(callback) {
if (callback._registered)
return;
callback._registered = true;
callbacks.push(callback);
if (!ticking) {
ticking = true;
requestAnimationFrame(tick);
}
}
function tick(t) {
var updating = callbacks;
callbacks = [];
updating.sort(function(left, right) {
return left._sequenceNumber - right._sequenceNumber;
});
updating.filter(function(callback) {
callback();
if (!callback._player || callback._player.finished || callback._player.paused)
callback._registered = false;
return callback._registered;
});
callbacks.push.apply(callbacks, updating);
if (callbacks.length) {
ticking = true;
requestAnimationFrame(tick);
} else {
ticking = false;
}
}
scope.Player.prototype._register = function() {
if (this._callback)
register(this._callback);
};
})(webAnimationsShared, webAnimationsNext, webAnimationsTesting);
// Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
(function(shared, scope, testing) {
scope.convertEffectInput = function(effectInput) {
var keyframeEffect = shared.normalizeKeyframes(effectInput);
var propertySpecificKeyframeGroups = makePropertySpecificKeyframeGroups(keyframeEffect);
var interpolations = makeInterpolations(propertySpecificKeyframeGroups);
return function(target, fraction) {
if (fraction != null) {
interpolations.filter(function(interpolation) {
return (fraction <= 0 && interpolation.startTime == 0) ||
(fraction >= 1 && interpolation.endTime == 1) ||
(fraction >= interpolation.startTime && fraction <= interpolation.endTime);
}).forEach(function(interpolation) {
var offsetFraction = fraction - interpolation.startTime;
var localDuration = interpolation.endTime - interpolation.startTime;
var scaledLocalTime = localDuration == 0 ? 0 : interpolation.easing(offsetFraction / localDuration);
scope.apply(target, interpolation.property, interpolation.interpolation(scaledLocalTime));
});
} else {
for (var property in propertySpecificKeyframeGroups)
if (property != 'offset' && property != 'easing' && property != 'composite')
scope.clear(target, property);
}
};
};
function makePropertySpecificKeyframeGroups(keyframeEffect) {
var propertySpecificKeyframeGroups = {};
for (var i = 0; i < keyframeEffect.length; i++) {
for (var member in keyframeEffect[i]) {
if (member != 'offset' && member != 'easing' && member != 'composite') {
var propertySpecificKeyframe = {
offset: keyframeEffect[i].offset,
easing: keyframeEffect[i].easing,
value: keyframeEffect[i][member]
};
propertySpecificKeyframeGroups[member] = propertySpecificKeyframeGroups[member] || [];
propertySpecificKeyframeGroups[member].push(propertySpecificKeyframe);
}
}
}
for (var groupName in propertySpecificKeyframeGroups) {
var group = propertySpecificKeyframeGroups[groupName];
if (group[0].offset != 0 || group[group.length - 1].offset != 1) {
throw {
type: DOMException.NOT_SUPPORTED_ERR,
name: 'NotSupportedError',
message: 'Partial keyframes are not supported'
};
}
}
return propertySpecificKeyframeGroups;
}
function makeInterpolations(propertySpecificKeyframeGroups) {
var interpolations = [];
for (var groupName in propertySpecificKeyframeGroups) {
var group = propertySpecificKeyframeGroups[groupName];
for (var i = 0; i < group.length - 1; i++) {
var startTime = group[i].offset;
var endTime = group[i + 1].offset;
var startValue = group[i].value;
var endValue = group[i + 1].value;
if (startTime == endTime) {
if (endTime == 1) {
startValue = endValue;
} else {
endValue = startValue;
}
}
interpolations.push({
startTime: startTime,
endTime: endTime,
easing: group[i].easing,
property: groupName,
interpolation: scope.propertyInterpolation(groupName, startValue, endValue)
});
}
}
interpolations.sort(function(leftInterpolation, rightInterpolation) {
return leftInterpolation.startTime - rightInterpolation.startTime;
});
return interpolations;
}
if (WEB_ANIMATIONS_TESTING) {
testing.makePropertySpecificKeyframeGroups = makePropertySpecificKeyframeGroups;
testing.makeInterpolations = makeInterpolations;
}
})(webAnimationsShared, webAnimations1, webAnimationsTesting);
// Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
(function(scope) {
window.Element.prototype.animate = function(effectInput, timingInput) {
return scope.timeline._play(scope.Animation(this, effectInput, timingInput));
};
})(webAnimations1);
// Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
(function(scope) {
function parse(string) {
var out = Number(string);
if (isNaN(out) || out < 100 || out > 900 || out % 100 !== 0) {
return;
}
return out;
}
function toCss(value) {
value = Math.round(value / 100) * 100;
value = scope.clamp(100, 900, value);
if (value === 400) {
return 'normal';
}
if (value === 700) {
return 'bold';
}
return String(value);
}
function merge(left, right) {
return [left, right, toCss];
}
scope.addPropertiesHandler(parse, merge, ['font-weight']);
})(webAnimations1);
// Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
(function(shared, scope, testing) {
function constructor(children, timingInput) {
this.children = children || [];
this._timing = shared.normalizeTimingInput(timingInput, true);
this.timing = shared.makeTiming(timingInput, true);
if (this._timing.duration === 'auto')
this._timing.duration = this.activeDuration;
}
window.AnimationSequence = function() {
constructor.apply(this, arguments);
};
window.AnimationGroup = function() {
constructor.apply(this, arguments);
};
window.AnimationSequence.prototype = {
get activeDuration() {
var total = 0;
this.children.forEach(function(child) {
total += scope.groupChildDuration(child);
});
return Math.max(total, 0);
}
};
window.AnimationGroup.prototype = {
get activeDuration() {
var max = 0;
this.children.forEach(function(child) {
max = Math.max(max, scope.groupChildDuration(child));
});
return max;
}
};
scope.newUnderlyingPlayerForGroup = function(group) {
var underlyingPlayer;
var ticker = function(tf) {
var player = underlyingPlayer._wrapper;
if (!player.source)
return;
if (tf == null) {
player._removePlayers();
return;
}
if (player.startTime === null)
return;
player._updateChildren();
};
underlyingPlayer = scope.timeline.play(new scope.Animation(null, ticker, group._timing));
return underlyingPlayer;
};
scope.bindPlayerForGroup = function(player) {
player._player._wrapper = player;
player._isGroup = true;
scope.awaitStartTime(player);
player._updateChildren();
};
})(webAnimationsShared, webAnimationsNext, webAnimationsTesting);
// Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
(function(scope) {
// consume* functions return a 2 value array of [parsed-data, '' or not-yet consumed input]
// Regex should be anchored with /^
function consumeToken(regex, string) {
var result = regex.exec(string);
if (result) {
result = regex.ignoreCase ? result[0].toLowerCase() : result[0];
return [result, string.substr(result.length)];
}
}
function consumeTrimmed(consumer, string) {
string = string.replace(/^\s*/, '');
var result = consumer(string);
if (result) {
return [result[0], result[1].replace(/^\s*/, '')];
}
}
function consumeRepeated(consumer, separator, string) {
consumer = consumeTrimmed.bind(null, consumer);
var list = [];
while (true) {
var result = consumer(string);
if (!result) {
return [list, string];
}
list.push(result[0]);
string = result[1];
result = consumeToken(separator, string);
if (!result || result[1] == '') {
return [list, string];
}
string = result[1];
}
}
// Consumes a token or expression with balanced parentheses
function consumeParenthesised(parser, string) {
var nesting = 0;
for (var n = 0; n < string.length; n++) {
if (/\s|,/.test(string[n]) && nesting == 0) {
break;
} else if (string[n] == '(') {
nesting++;
} else if (string[n] == ')') {
nesting--;
if (nesting == 0)
n++;
if (nesting <= 0)
break;
}
}
var parsed = parser(string.substr(0, n));
return parsed == undefined ? undefined : [parsed, string.substr(n)];
}
function lcm(a, b) {
var c = a;
var d = b;
while (c && d)
c > d ? c %= d : d %= c;
c = (a * b) / (c + d);
return c;
}
function ignore(value) {
return function(input) {
var result = value(input);
if (result)
result[0] = undefined;
return result;
}
}
function optional(value, defaultValue) {
return function(input) {
var result = value(input);
if (result)
return result;
return [defaultValue, input];
}
}
function consumeList(list, input) {
var output = [];
for (var i = 0; i < list.length; i++) {
var result = scope.consumeTrimmed(list[i], input);
if (!result || result[0] == '')
return;
if (result[0] !== undefined)
output.push(result[0]);
input = result[1];
}
if (input == '') {
return output;
}
}
function mergeWrappedNestedRepeated(wrap, nestedMerge, separator, left, right) {
var matchingLeft = [];
var matchingRight = [];
var reconsititution = [];
var length = lcm(left.length, right.length);
for (var i = 0; i < length; i++) {
var thing = nestedMerge(left[i % left.length], right[i % right.length]);
if (!thing) {
return;
}
matchingLeft.push(thing[0]);
matchingRight.push(thing[1]);
reconsititution.push(thing[2]);
}
return [matchingLeft, matchingRight, function(positions) {
var result = positions.map(function(position, i) {
return reconsititution[i](position);
}).join(separator);
return wrap ? wrap(result) : result;
}];
}
function mergeList(left, right, list) {
var lefts = [];
var rights = [];
var functions = [];
var j = 0;
for (var i = 0; i < list.length; i++) {
if (typeof list[i] == 'function') {
var result = list[i](left[j], right[j++]);
lefts.push(result[0]);
rights.push(result[1]);
functions.push(result[2]);
} else {
(function(pos) {
lefts.push(false);
rights.push(false);
functions.push(function() { return list[pos]; });
})(i);
}
}
return [lefts, rights, function(results) {
var result = '';
for (var i = 0; i < results.length; i++) {
result += functions[i](results[i]);
}
return result;
}];
}
scope.consumeToken = consumeToken;
scope.consumeTrimmed = consumeTrimmed;
scope.consumeRepeated = consumeRepeated;
scope.consumeParenthesised = consumeParenthesised;
scope.ignore = ignore;
scope.optional = optional;
scope.consumeList = consumeList;
scope.mergeNestedRepeated = mergeWrappedNestedRepeated.bind(null, null);
scope.mergeWrappedNestedRepeated = mergeWrappedNestedRepeated;
scope.mergeList = mergeList;
})(webAnimations1);
// Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
(function(scope, testing) {
function interpolate(from, to, f) {
if ((typeof from == 'number') && (typeof to == 'number')) {
return from * (1 - f) + to * f;
}
if ((typeof from == 'boolean') && (typeof to == 'boolean')) {
return f < 0.5 ? from : to;
}
WEB_ANIMATIONS_TESTING && console.assert(
Array.isArray(from) && Array.isArray(to),
'If interpolation arguments are not numbers or bools they must be arrays');
if (from.length == to.length) {
var r = [];
for (var i = 0; i < from.length; i++) {
r.push(interpolate(from[i], to[i], f));
}
return r;
}
throw 'Mismatched interpolation arguments ' + from + ':' + to;
}
scope.Interpolation = function(from, to, convertToString) {
return function(f) {
return convertToString(interpolate(from, to, f));
}
};
if (WEB_ANIMATIONS_TESTING) {
testing.interpolate = interpolate;
}
})(webAnimations1, webAnimationsTesting);
// Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
(function(scope, testing) {
var composeMatrix = (function() {
function multiply(a, b) {
var result = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]];
for (var i = 0; i < 4; i++) {
for (var j = 0; j < 4; j++) {
for (var k = 0; k < 4; k++) {
result[i][j] += b[i][k] * a[k][j];
}
}
}
return result;
}
function is2D(m) {
return (
m[0][2] == 0 &&
m[0][3] == 0 &&
m[1][2] == 0 &&
m[1][3] == 0 &&
m[2][0] == 0 &&
m[2][1] == 0 &&
m[2][2] == 1 &&
m[2][3] == 0 &&
m[3][2] == 0 &&
m[3][3] == 1);
}
function composeMatrix(translate, scale, skew, quat, perspective) {
var matrix = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]];
for (var i = 0; i < 4; i++) {
matrix[i][3] = perspective[i];
}
for (var i = 0; i < 3; i++) {
for (var j = 0; j < 3; j++) {
matrix[3][i] += translate[j] * matrix[j][i];
}
}
var x = quat[0], y = quat[1], z = quat[2], w = quat[3];
var rotMatrix = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]];
rotMatrix[0][0] = 1 - 2 * (y * y + z * z);
rotMatrix[0][1] = 2 * (x * y - z * w);
rotMatrix[0][2] = 2 * (x * z + y * w);
rotMatrix[1][0] = 2 * (x * y + z * w);
rotMatrix[1][1] = 1 - 2 * (x * x + z * z);
rotMatrix[1][2] = 2 * (y * z - x * w);
rotMatrix[2][0] = 2 * (x * z - y * w);
rotMatrix[2][1] = 2 * (y * z + x * w);
rotMatrix[2][2] = 1 - 2 * (x * x + y * y);
matrix = multiply(matrix, rotMatrix);
var temp = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]];
if (skew[2]) {
temp[2][1] = skew[2];
matrix = multiply(matrix, temp);
}
if (skew[1]) {
temp[2][1] = 0;
temp[2][0] = skew[0];
matrix = multiply(matrix, temp);
}
if (skew[0]) {
temp[2][0] = 0;
temp[1][0] = skew[0];
matrix = multiply(matrix, temp);
}
for (var i = 0; i < 3; i++) {
for (var j = 0; j < 3; j++) {
matrix[i][j] *= scale[i];
}
}
if (is2D(matrix)) {
return [matrix[0][0], matrix[0][1], matrix[1][0], matrix[1][1], matrix[3][0], matrix[3][1]];
}
return matrix[0].concat(matrix[1], matrix[2], matrix[3]);
}
return composeMatrix;
})();
function clamp(x, min, max) {
return Math.max(Math.min(x, max), min);
};
function quat(fromQ, toQ, f) {
var product = scope.dot(fromQ, toQ);
product = clamp(product, -1.0, 1.0);
var quat = [];
if (product === 1.0) {
quat = fromQ;
} else {
var theta = Math.acos(product);
var w = Math.sin(f * theta) * 1 / Math.sqrt(1 - product * product);
for (var i = 0; i < 4; i++) {
quat.push(fromQ[i] * (Math.cos(f * theta) - product * w) +
toQ[i] * w);
}
}
return quat;
}
scope.composeMatrix = composeMatrix;
scope.quat = quat;
})(webAnimations1, webAnimationsTesting);
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment