polymer-paper-rails 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -18
- data/app/assets/components/core-a11y-keys/core-a11y-keys.html +4 -4
- data/app/assets/components/core-animation/web-animations.html +1 -1
- data/app/assets/components/core-collapse/core-collapse.html +1 -1
- data/app/assets/components/core-drawer-panel/core-drawer-panel.css +14 -6
- data/app/assets/components/core-drawer-panel/core-drawer-panel.html +32 -8
- data/app/assets/components/core-dropdown/core-dropdown.html +8 -2
- data/app/assets/components/core-icon/core-icon.html +0 -2
- data/app/assets/components/core-icons/av-icons.html +2 -9
- data/app/assets/components/core-icons/communication-icons.html +39 -42
- data/app/assets/components/core-icons/core-icons.html +231 -235
- data/app/assets/components/core-icons/device-icons.html +75 -90
- data/app/assets/components/core-icons/editor-icons.html +52 -52
- data/app/assets/components/core-icons/hardware-icons.html +40 -41
- data/app/assets/components/core-icons/image-icons.html +133 -137
- data/app/assets/components/core-icons/maps-icons.html +55 -57
- data/app/assets/components/core-icons/notification-icons.html +34 -34
- data/app/assets/components/core-icons/social-icons.html +23 -37
- data/app/assets/components/core-menu/core-menu.html +8 -3
- data/app/assets/components/core-menu/core-submenu.html +2 -2
- data/app/assets/components/core-overlay/core-key-helper.html +3 -0
- data/app/assets/components/core-overlay/core-overlay-layer.html +3 -0
- data/app/assets/components/core-overlay/core-overlay.html +20 -4
- data/app/assets/components/core-resizable/core-resizable.html +248 -0
- data/app/assets/components/core-scroll-header-panel/core-scroll-header-panel.html +14 -3
- data/app/assets/components/core-selection/core-selection.html +1 -1
- data/app/assets/components/core-selector/core-selector.html +26 -26
- data/app/assets/components/core-style/core-style.html +1 -1
- data/app/assets/components/core-toolbar/core-toolbar.html +1 -1
- data/app/assets/components/paper-button/paper-button-base.html +56 -12
- data/app/assets/components/paper-button/paper-button.html +22 -5
- data/app/assets/components/paper-checkbox/paper-checkbox.css +65 -184
- data/app/assets/components/paper-checkbox/paper-checkbox.html +47 -55
- data/app/assets/components/paper-dialog/paper-action-dialog.html +3 -3
- data/app/assets/components/paper-dialog/paper-dialog.html +2 -2
- data/app/assets/components/paper-dropdown-menu/paper-dropdown-menu.html +4 -1
- data/app/assets/components/{core-elements → paper-elements}/metadata.html +0 -0
- data/app/assets/components/{core-elements → paper-elements}/paper-elements.html +1 -0
- data/app/assets/components/paper-fab/paper-fab.html +2 -2
- data/app/assets/components/paper-input/paper-autogrow-textarea.html +8 -3
- data/app/assets/components/paper-input/paper-char-counter.html +121 -0
- data/app/assets/components/paper-input/paper-input-decorator.css +1 -21
- data/app/assets/components/paper-input/paper-input-decorator.html +130 -51
- data/app/assets/components/paper-input/paper-input.html +31 -5
- data/app/assets/components/paper-item/paper-item.html +1 -2
- data/app/assets/components/paper-progress/paper-progress.html +1 -1
- data/app/assets/components/paper-radio-button/paper-radio-button.css +16 -12
- data/app/assets/components/paper-radio-button/paper-radio-button.html +9 -3
- data/app/assets/components/paper-ripple/paper-ripple.html +2 -1
- data/app/assets/components/paper-shadow/paper-shadow.css +10 -10
- data/app/assets/components/paper-shadow/paper-shadow.html +8 -1
- data/app/assets/components/paper-slider/paper-slider.html +28 -4
- data/app/assets/components/paper-spinner/paper-spinner.css +35 -23
- data/app/assets/components/paper-spinner/paper-spinner.html +46 -5
- data/app/assets/components/paper-tabs/paper-tabs.css +5 -0
- data/app/assets/components/paper-tabs/paper-tabs.html +32 -7
- data/app/assets/components/paper-toggle-button/paper-toggle-button.css +58 -30
- data/app/assets/components/paper-toggle-button/paper-toggle-button.html +69 -44
- data/app/assets/components/sampler-scaffold/sampler-scaffold.css +1 -1
- data/app/assets/components/web-animations-js/web-animations-next-lite.min.js +17 -0
- data/app/assets/components/web-animations-js/web-animations-next.min.js +17 -0
- data/app/assets/components/web-animations-js/web-animations.min.js +17 -0
- data/app/assets/components/webcomponentsjs/CustomElements.js +634 -0
- data/app/assets/components/webcomponentsjs/CustomElements.min.js +11 -0
- data/app/assets/components/webcomponentsjs/HTMLImports.js +764 -0
- data/app/assets/components/webcomponentsjs/HTMLImports.min.js +11 -0
- data/app/assets/components/webcomponentsjs/ShadowDOM.js +4277 -0
- data/app/assets/components/webcomponentsjs/ShadowDOM.min.js +13 -0
- data/app/assets/components/webcomponentsjs/package.json +31 -0
- data/app/assets/components/webcomponentsjs/webcomponents-lite.js +1728 -0
- data/app/assets/components/webcomponentsjs/webcomponents-lite.min.js +11 -0
- data/app/assets/components/webcomponentsjs/webcomponents.js +6114 -0
- data/app/assets/components/webcomponentsjs/webcomponents.min.js +14 -0
- data/lib/polymer-paper-rails/version.rb +1 -1
- metadata +20 -71
- data/app/assets/components/core-dropdown/metadata.html +0 -62
- data/app/assets/components/core-icons/png-icons.html +0 -19
- data/app/assets/components/core-label/core-label.html +0 -124
- data/app/assets/components/core-overlay/tests/html/core-overlay-basic.html +0 -127
- data/app/assets/components/core-overlay/tests/html/core-overlay-positioning-margin.html +0 -153
- data/app/assets/components/core-overlay/tests/html/core-overlay-positioning.html +0 -167
- data/app/assets/components/core-overlay/tests/html/core-overlay-scroll.html +0 -130
- data/app/assets/components/core-overlay/tests/js/htmltests.js +0 -6
- data/app/assets/components/core-overlay/tests/runner.html +0 -14
- data/app/assets/components/core-overlay/tests/tests.json +0 -6
- data/app/assets/components/core-popup-menu/core-popup-menu.css +0 -28
- data/app/assets/components/core-popup-menu/core-popup-menu.html +0 -198
- data/app/assets/components/core-popup-menu/core-popup-overlay.html +0 -111
- data/app/assets/components/core-popup-menu/metadata.html +0 -62
- data/app/assets/components/paper-focusable/paper-focusable.html +0 -146
- data/app/assets/components/platform/platform.js +0 -16
- data/app/assets/components/web-animations-js/web-animations.js +0 -5529
- data/app/assets/components/web-animations-next/Gruntfile.js +0 -279
- data/app/assets/components/web-animations-next/History.md +0 -76
- data/app/assets/components/web-animations-next/package.json +0 -33
- data/app/assets/components/web-animations-next/src/animation-constructor.js +0 -139
- data/app/assets/components/web-animations-next/src/animation-node.js +0 -31
- data/app/assets/components/web-animations-next/src/animation.js +0 -65
- data/app/assets/components/web-animations-next/src/apply-preserving-inline-style.js +0 -192
- data/app/assets/components/web-animations-next/src/apply.js +0 -25
- data/app/assets/components/web-animations-next/src/box-handler.js +0 -57
- data/app/assets/components/web-animations-next/src/color-handler.js +0 -62
- data/app/assets/components/web-animations-next/src/deprecation.js +0 -42
- data/app/assets/components/web-animations-next/src/dev.js +0 -16
- data/app/assets/components/web-animations-next/src/dimension-handler.js +0 -167
- data/app/assets/components/web-animations-next/src/effect-callback.js +0 -86
- data/app/assets/components/web-animations-next/src/effect.js +0 -110
- data/app/assets/components/web-animations-next/src/element-animatable.js +0 -19
- data/app/assets/components/web-animations-next/src/font-weight-handler.js +0 -42
- data/app/assets/components/web-animations-next/src/group-constructors.js +0 -81
- data/app/assets/components/web-animations-next/src/handler-utils.js +0 -177
- data/app/assets/components/web-animations-next/src/interpolation.js +0 -49
- data/app/assets/components/web-animations-next/src/matrix-decomposition.js +0 -452
- data/app/assets/components/web-animations-next/src/matrix-interpolation.js +0 -130
- data/app/assets/components/web-animations-next/src/maxifill-player.js +0 -162
- data/app/assets/components/web-animations-next/src/normalize-keyframes.js +0 -259
- data/app/assets/components/web-animations-next/src/number-handler.js +0 -72
- data/app/assets/components/web-animations-next/src/player.js +0 -193
- data/app/assets/components/web-animations-next/src/position-handler.js +0 -117
- data/app/assets/components/web-animations-next/src/property-interpolation.js +0 -62
- data/app/assets/components/web-animations-next/src/property-names.js +0 -35
- data/app/assets/components/web-animations-next/src/scope.js +0 -20
- data/app/assets/components/web-animations-next/src/shadow-handler.js +0 -108
- data/app/assets/components/web-animations-next/src/shape-handler.js +0 -85
- data/app/assets/components/web-animations-next/src/tick.js +0 -148
- data/app/assets/components/web-animations-next/src/timeline.js +0 -77
- data/app/assets/components/web-animations-next/src/timing-utilities.js +0 -242
- data/app/assets/components/web-animations-next/src/transform-handler.js +0 -262
- data/app/assets/components/web-animations-next/src/visibility-handler.js +0 -29
- data/app/assets/components/web-animations-next/target-config.js +0 -124
- data/app/assets/components/web-animations-next/target-loader.js +0 -13
- data/app/assets/components/web-animations-next/templates/boilerplate +0 -13
- data/app/assets/components/web-animations-next/templates/runner.html +0 -26
- data/app/assets/components/web-animations-next/templates/web-animations.html +0 -18
- data/app/assets/components/web-animations-next/templates/web-animations.js +0 -21
- data/app/assets/components/web-animations-next/web-animations-next-lite.dev.html +0 -44
- data/app/assets/components/web-animations-next/web-animations-next-lite.dev.js +0 -21
- data/app/assets/components/web-animations-next/web-animations-next.dev.html +0 -49
- data/app/assets/components/web-animations-next/web-animations-next.dev.js +0 -21
- data/app/assets/components/web-animations-next/web-animations.dev.html +0 -44
- data/app/assets/components/web-animations-next/web-animations.dev.js +0 -21
- data/app/assets/components/web-animations-next/web-animations.html +0 -50
@@ -1,177 +0,0 @@
|
|
1
|
-
// Copyright 2014 Google Inc. All rights reserved.
|
2
|
-
//
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
// you may not use this file except in compliance with the License.
|
5
|
-
// You may obtain a copy of the License at
|
6
|
-
//
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
//
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
// See the License for the specific language governing permissions and
|
13
|
-
// limitations under the License.
|
14
|
-
|
15
|
-
(function(scope) {
|
16
|
-
|
17
|
-
// consume* functions return a 2 value array of [parsed-data, '' or not-yet consumed input]
|
18
|
-
|
19
|
-
// Regex should be anchored with /^
|
20
|
-
function consumeToken(regex, string) {
|
21
|
-
var result = regex.exec(string);
|
22
|
-
if (result) {
|
23
|
-
result = regex.ignoreCase ? result[0].toLowerCase() : result[0];
|
24
|
-
return [result, string.substr(result.length)];
|
25
|
-
}
|
26
|
-
}
|
27
|
-
|
28
|
-
function consumeTrimmed(consumer, string) {
|
29
|
-
string = string.replace(/^\s*/, '');
|
30
|
-
var result = consumer(string);
|
31
|
-
if (result) {
|
32
|
-
return [result[0], result[1].replace(/^\s*/, '')];
|
33
|
-
}
|
34
|
-
}
|
35
|
-
|
36
|
-
function consumeRepeated(consumer, separator, string) {
|
37
|
-
consumer = consumeTrimmed.bind(null, consumer);
|
38
|
-
var list = [];
|
39
|
-
while (true) {
|
40
|
-
var result = consumer(string);
|
41
|
-
if (!result) {
|
42
|
-
return [list, string];
|
43
|
-
}
|
44
|
-
list.push(result[0]);
|
45
|
-
string = result[1];
|
46
|
-
result = consumeToken(separator, string);
|
47
|
-
if (!result || result[1] == '') {
|
48
|
-
return [list, string];
|
49
|
-
}
|
50
|
-
string = result[1];
|
51
|
-
}
|
52
|
-
}
|
53
|
-
|
54
|
-
// Consumes a token or expression with balanced parentheses
|
55
|
-
function consumeParenthesised(parser, string) {
|
56
|
-
var nesting = 0;
|
57
|
-
for (var n = 0; n < string.length; n++) {
|
58
|
-
if (/\s|,/.test(string[n]) && nesting == 0) {
|
59
|
-
break;
|
60
|
-
} else if (string[n] == '(') {
|
61
|
-
nesting++;
|
62
|
-
} else if (string[n] == ')') {
|
63
|
-
nesting--;
|
64
|
-
if (nesting == 0)
|
65
|
-
n++;
|
66
|
-
if (nesting <= 0)
|
67
|
-
break;
|
68
|
-
}
|
69
|
-
}
|
70
|
-
var parsed = parser(string.substr(0, n));
|
71
|
-
return parsed == undefined ? undefined : [parsed, string.substr(n)];
|
72
|
-
}
|
73
|
-
|
74
|
-
function lcm(a, b) {
|
75
|
-
var c = a;
|
76
|
-
var d = b;
|
77
|
-
while (c && d)
|
78
|
-
c > d ? c %= d : d %= c;
|
79
|
-
c = (a * b) / (c + d);
|
80
|
-
return c;
|
81
|
-
}
|
82
|
-
|
83
|
-
function ignore(value) {
|
84
|
-
return function(input) {
|
85
|
-
var result = value(input);
|
86
|
-
if (result)
|
87
|
-
result[0] = undefined;
|
88
|
-
return result;
|
89
|
-
}
|
90
|
-
}
|
91
|
-
|
92
|
-
function optional(value, defaultValue) {
|
93
|
-
return function(input) {
|
94
|
-
var result = value(input);
|
95
|
-
if (result)
|
96
|
-
return result;
|
97
|
-
return [defaultValue, input];
|
98
|
-
}
|
99
|
-
}
|
100
|
-
|
101
|
-
function consumeList(list, input) {
|
102
|
-
var output = [];
|
103
|
-
for (var i = 0; i < list.length; i++) {
|
104
|
-
var result = scope.consumeTrimmed(list[i], input);
|
105
|
-
if (!result || result[0] == '')
|
106
|
-
return;
|
107
|
-
if (result[0] !== undefined)
|
108
|
-
output.push(result[0]);
|
109
|
-
input = result[1];
|
110
|
-
}
|
111
|
-
if (input == '') {
|
112
|
-
return output;
|
113
|
-
}
|
114
|
-
}
|
115
|
-
|
116
|
-
function mergeWrappedNestedRepeated(wrap, nestedMerge, separator, left, right) {
|
117
|
-
var matchingLeft = [];
|
118
|
-
var matchingRight = [];
|
119
|
-
var reconsititution = [];
|
120
|
-
var length = lcm(left.length, right.length);
|
121
|
-
for (var i = 0; i < length; i++) {
|
122
|
-
var thing = nestedMerge(left[i % left.length], right[i % right.length]);
|
123
|
-
if (!thing) {
|
124
|
-
return;
|
125
|
-
}
|
126
|
-
matchingLeft.push(thing[0]);
|
127
|
-
matchingRight.push(thing[1]);
|
128
|
-
reconsititution.push(thing[2]);
|
129
|
-
}
|
130
|
-
return [matchingLeft, matchingRight, function(positions) {
|
131
|
-
var result = positions.map(function(position, i) {
|
132
|
-
return reconsititution[i](position);
|
133
|
-
}).join(separator);
|
134
|
-
return wrap ? wrap(result) : result;
|
135
|
-
}];
|
136
|
-
}
|
137
|
-
|
138
|
-
function mergeList(left, right, list) {
|
139
|
-
var lefts = [];
|
140
|
-
var rights = [];
|
141
|
-
var functions = [];
|
142
|
-
var j = 0;
|
143
|
-
for (var i = 0; i < list.length; i++) {
|
144
|
-
if (typeof list[i] == 'function') {
|
145
|
-
var result = list[i](left[j], right[j++]);
|
146
|
-
lefts.push(result[0]);
|
147
|
-
rights.push(result[1]);
|
148
|
-
functions.push(result[2]);
|
149
|
-
} else {
|
150
|
-
(function(pos) {
|
151
|
-
lefts.push(false);
|
152
|
-
rights.push(false);
|
153
|
-
functions.push(function() { return list[pos]; });
|
154
|
-
})(i);
|
155
|
-
}
|
156
|
-
}
|
157
|
-
return [lefts, rights, function(results) {
|
158
|
-
var result = '';
|
159
|
-
for (var i = 0; i < results.length; i++) {
|
160
|
-
result += functions[i](results[i]);
|
161
|
-
}
|
162
|
-
return result;
|
163
|
-
}];
|
164
|
-
}
|
165
|
-
|
166
|
-
scope.consumeToken = consumeToken;
|
167
|
-
scope.consumeTrimmed = consumeTrimmed;
|
168
|
-
scope.consumeRepeated = consumeRepeated;
|
169
|
-
scope.consumeParenthesised = consumeParenthesised;
|
170
|
-
scope.ignore = ignore;
|
171
|
-
scope.optional = optional;
|
172
|
-
scope.consumeList = consumeList;
|
173
|
-
scope.mergeNestedRepeated = mergeWrappedNestedRepeated.bind(null, null);
|
174
|
-
scope.mergeWrappedNestedRepeated = mergeWrappedNestedRepeated;
|
175
|
-
scope.mergeList = mergeList;
|
176
|
-
|
177
|
-
})(webAnimationsMinifill);
|
@@ -1,49 +0,0 @@
|
|
1
|
-
// Copyright 2014 Google Inc. All rights reserved.
|
2
|
-
//
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
// you may not use this file except in compliance with the License.
|
5
|
-
// You may obtain a copy of the License at
|
6
|
-
//
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
//
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
// See the License for the specific language governing permissions and
|
13
|
-
// limitations under the License.
|
14
|
-
|
15
|
-
(function(scope, testing) {
|
16
|
-
|
17
|
-
function interpolate(from, to, f) {
|
18
|
-
if ((typeof from == 'number') && (typeof to == 'number')) {
|
19
|
-
return from * (1 - f) + to * f;
|
20
|
-
}
|
21
|
-
if ((typeof from == 'boolean') && (typeof to == 'boolean')) {
|
22
|
-
return f < 0.5 ? from : to;
|
23
|
-
}
|
24
|
-
|
25
|
-
WEB_ANIMATIONS_TESTING && console.assert(
|
26
|
-
Array.isArray(from) && Array.isArray(to),
|
27
|
-
'If interpolation arguments are not numbers or bools they must be arrays');
|
28
|
-
|
29
|
-
if (from.length == to.length) {
|
30
|
-
var r = [];
|
31
|
-
for (var i = 0; i < from.length; i++) {
|
32
|
-
r.push(interpolate(from[i], to[i], f));
|
33
|
-
}
|
34
|
-
return r;
|
35
|
-
}
|
36
|
-
throw 'Mismatched interpolation arguments ' + from + ':' + to;
|
37
|
-
}
|
38
|
-
|
39
|
-
scope.Interpolation = function(from, to, convertToString) {
|
40
|
-
return function(f) {
|
41
|
-
return convertToString(interpolate(from, to, f));
|
42
|
-
}
|
43
|
-
};
|
44
|
-
|
45
|
-
if (WEB_ANIMATIONS_TESTING) {
|
46
|
-
testing.interpolate = interpolate;
|
47
|
-
}
|
48
|
-
|
49
|
-
})(webAnimationsMinifill, webAnimationsTesting);
|
@@ -1,452 +0,0 @@
|
|
1
|
-
// Copyright 2014 Google Inc. All rights reserved.
|
2
|
-
//
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
// you may not use this file except in compliance with the License.
|
5
|
-
// You may obtain a copy of the License at
|
6
|
-
//
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
//
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
// See the License for the specific language governing permissions and
|
13
|
-
// limitations under the License.
|
14
|
-
|
15
|
-
(function(scope, testing) {
|
16
|
-
var decomposeMatrix = (function() {
|
17
|
-
function determinant(m) {
|
18
|
-
return m[0][0] * m[1][1] * m[2][2] +
|
19
|
-
m[1][0] * m[2][1] * m[0][2] +
|
20
|
-
m[2][0] * m[0][1] * m[1][2] -
|
21
|
-
m[0][2] * m[1][1] * m[2][0] -
|
22
|
-
m[1][2] * m[2][1] * m[0][0] -
|
23
|
-
m[2][2] * m[0][1] * m[1][0];
|
24
|
-
}
|
25
|
-
|
26
|
-
// from Wikipedia:
|
27
|
-
//
|
28
|
-
// [A B]^-1 = [A^-1 + A^-1B(D - CA^-1B)^-1CA^-1 -A^-1B(D - CA^-1B)^-1]
|
29
|
-
// [C D] [-(D - CA^-1B)^-1CA^-1 (D - CA^-1B)^-1 ]
|
30
|
-
//
|
31
|
-
// Therefore
|
32
|
-
//
|
33
|
-
// [A [0]]^-1 = [A^-1 [0]]
|
34
|
-
// [C 1 ] [ -CA^-1 1 ]
|
35
|
-
function inverse(m) {
|
36
|
-
var iDet = 1 / determinant(m);
|
37
|
-
var a = m[0][0], b = m[0][1], c = m[0][2];
|
38
|
-
var d = m[1][0], e = m[1][1], f = m[1][2];
|
39
|
-
var g = m[2][0], h = m[2][1], k = m[2][2];
|
40
|
-
var Ainv = [
|
41
|
-
[(e * k - f * h) * iDet, (c * h - b * k) * iDet,
|
42
|
-
(b * f - c * e) * iDet, 0],
|
43
|
-
[(f * g - d * k) * iDet, (a * k - c * g) * iDet,
|
44
|
-
(c * d - a * f) * iDet, 0],
|
45
|
-
[(d * h - e * g) * iDet, (g * b - a * h) * iDet,
|
46
|
-
(a * e - b * d) * iDet, 0]
|
47
|
-
];
|
48
|
-
var lastRow = [];
|
49
|
-
for (var i = 0; i < 3; i++) {
|
50
|
-
var val = 0;
|
51
|
-
for (var j = 0; j < 3; j++) {
|
52
|
-
val += m[3][j] * Ainv[j][i];
|
53
|
-
}
|
54
|
-
lastRow.push(val);
|
55
|
-
}
|
56
|
-
lastRow.push(1);
|
57
|
-
Ainv.push(lastRow);
|
58
|
-
return Ainv;
|
59
|
-
}
|
60
|
-
|
61
|
-
function transposeMatrix4(m) {
|
62
|
-
return [[m[0][0], m[1][0], m[2][0], m[3][0]],
|
63
|
-
[m[0][1], m[1][1], m[2][1], m[3][1]],
|
64
|
-
[m[0][2], m[1][2], m[2][2], m[3][2]],
|
65
|
-
[m[0][3], m[1][3], m[2][3], m[3][3]]];
|
66
|
-
}
|
67
|
-
|
68
|
-
function multVecMatrix(v, m) {
|
69
|
-
var result = [];
|
70
|
-
for (var i = 0; i < 4; i++) {
|
71
|
-
var val = 0;
|
72
|
-
for (var j = 0; j < 4; j++) {
|
73
|
-
val += v[j] * m[j][i];
|
74
|
-
}
|
75
|
-
result.push(val);
|
76
|
-
}
|
77
|
-
return result;
|
78
|
-
}
|
79
|
-
|
80
|
-
function normalize(v) {
|
81
|
-
var len = length(v);
|
82
|
-
return [v[0] / len, v[1] / len, v[2] / len];
|
83
|
-
}
|
84
|
-
|
85
|
-
function length(v) {
|
86
|
-
return Math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
|
87
|
-
}
|
88
|
-
|
89
|
-
function combine(v1, v2, v1s, v2s) {
|
90
|
-
return [v1s * v1[0] + v2s * v2[0], v1s * v1[1] + v2s * v2[1],
|
91
|
-
v1s * v1[2] + v2s * v2[2]];
|
92
|
-
}
|
93
|
-
|
94
|
-
function cross(v1, v2) {
|
95
|
-
return [v1[1] * v2[2] - v1[2] * v2[1],
|
96
|
-
v1[2] * v2[0] - v1[0] * v2[2],
|
97
|
-
v1[0] * v2[1] - v1[1] * v2[0]];
|
98
|
-
}
|
99
|
-
|
100
|
-
// TODO: Implement 2D matrix decomposition.
|
101
|
-
// http://dev.w3.org/csswg/css-transforms/#decomposing-a-2d-matrix
|
102
|
-
function decomposeMatrix(matrix) {
|
103
|
-
var m3d = [
|
104
|
-
matrix.slice(0, 4),
|
105
|
-
matrix.slice(4, 8),
|
106
|
-
matrix.slice(8, 12),
|
107
|
-
matrix.slice(12, 16)
|
108
|
-
];
|
109
|
-
|
110
|
-
// skip normalization step as m3d[3][3] should always be 1
|
111
|
-
if (m3d[3][3] !== 1) {
|
112
|
-
return null;
|
113
|
-
}
|
114
|
-
|
115
|
-
var perspectiveMatrix = [];
|
116
|
-
for (var i = 0; i < 4; i++) {
|
117
|
-
perspectiveMatrix.push(m3d[i].slice());
|
118
|
-
}
|
119
|
-
|
120
|
-
for (var i = 0; i < 3; i++) {
|
121
|
-
perspectiveMatrix[i][3] = 0;
|
122
|
-
}
|
123
|
-
|
124
|
-
if (determinant(perspectiveMatrix) === 0) {
|
125
|
-
return false;
|
126
|
-
}
|
127
|
-
|
128
|
-
var rhs = [];
|
129
|
-
|
130
|
-
var perspective;
|
131
|
-
if (m3d[0][3] || m3d[1][3] || m3d[2][3]) {
|
132
|
-
rhs.push(m3d[0][3]);
|
133
|
-
rhs.push(m3d[1][3]);
|
134
|
-
rhs.push(m3d[2][3]);
|
135
|
-
rhs.push(m3d[3][3]);
|
136
|
-
|
137
|
-
var inversePerspectiveMatrix = inverse(perspectiveMatrix);
|
138
|
-
var transposedInversePerspectiveMatrix =
|
139
|
-
transposeMatrix4(inversePerspectiveMatrix);
|
140
|
-
perspective = multVecMatrix(rhs, transposedInversePerspectiveMatrix);
|
141
|
-
} else {
|
142
|
-
perspective = [0, 0, 0, 1];
|
143
|
-
}
|
144
|
-
|
145
|
-
var translate = m3d[3].slice(0, 3);
|
146
|
-
|
147
|
-
var row = [];
|
148
|
-
row.push(m3d[0].slice(0, 3));
|
149
|
-
var scale = [];
|
150
|
-
scale.push(length(row[0]));
|
151
|
-
row[0] = normalize(row[0]);
|
152
|
-
|
153
|
-
var skew = [];
|
154
|
-
row.push(m3d[1].slice(0, 3));
|
155
|
-
skew.push(dot(row[0], row[1]));
|
156
|
-
row[1] = combine(row[1], row[0], 1.0, -skew[0]);
|
157
|
-
|
158
|
-
scale.push(length(row[1]));
|
159
|
-
row[1] = normalize(row[1]);
|
160
|
-
skew[0] /= scale[1];
|
161
|
-
|
162
|
-
row.push(m3d[2].slice(0, 3));
|
163
|
-
skew.push(dot(row[0], row[2]));
|
164
|
-
row[2] = combine(row[2], row[0], 1.0, -skew[1]);
|
165
|
-
skew.push(dot(row[1], row[2]));
|
166
|
-
row[2] = combine(row[2], row[1], 1.0, -skew[2]);
|
167
|
-
|
168
|
-
scale.push(length(row[2]));
|
169
|
-
row[2] = normalize(row[2]);
|
170
|
-
skew[1] /= scale[2];
|
171
|
-
skew[2] /= scale[2];
|
172
|
-
|
173
|
-
var pdum3 = cross(row[1], row[2]);
|
174
|
-
if (dot(row[0], pdum3) < 0) {
|
175
|
-
for (var i = 0; i < 3; i++) {
|
176
|
-
scale[i] *= -1;
|
177
|
-
row[i][0] *= -1;
|
178
|
-
row[i][1] *= -1;
|
179
|
-
row[i][2] *= -1;
|
180
|
-
}
|
181
|
-
}
|
182
|
-
|
183
|
-
var t = row[0][0] + row[1][1] + row[2][2] + 1;
|
184
|
-
var s;
|
185
|
-
var quaternion;
|
186
|
-
|
187
|
-
if (t > 1e-4) {
|
188
|
-
s = 0.5 / Math.sqrt(t);
|
189
|
-
quaternion = [
|
190
|
-
(row[2][1] - row[1][2]) * s,
|
191
|
-
(row[0][2] - row[2][0]) * s,
|
192
|
-
(row[1][0] - row[0][1]) * s,
|
193
|
-
0.25 / s
|
194
|
-
];
|
195
|
-
} else if (row[0][0] > row[1][1] && row[0][0] > row[2][2]) {
|
196
|
-
s = Math.sqrt(1 + row[0][0] - row[1][1] - row[2][2]) * 2.0;
|
197
|
-
quaternion = [
|
198
|
-
0.25 * s,
|
199
|
-
(row[0][1] + row[1][0]) / s,
|
200
|
-
(row[0][2] + row[2][0]) / s,
|
201
|
-
(row[2][1] - row[1][2]) / s
|
202
|
-
];
|
203
|
-
} else if (row[1][1] > row[2][2]) {
|
204
|
-
s = Math.sqrt(1.0 + row[1][1] - row[0][0] - row[2][2]) * 2.0;
|
205
|
-
quaternion = [
|
206
|
-
(row[0][1] + row[1][0]) / s,
|
207
|
-
0.25 * s,
|
208
|
-
(row[1][2] + row[2][1]) / s,
|
209
|
-
(row[0][2] - row[2][0]) / s
|
210
|
-
];
|
211
|
-
} else {
|
212
|
-
s = Math.sqrt(1.0 + row[2][2] - row[0][0] - row[1][1]) * 2.0;
|
213
|
-
quaternion = [
|
214
|
-
(row[0][2] + row[2][0]) / s,
|
215
|
-
(row[1][2] + row[2][1]) / s,
|
216
|
-
0.25 * s,
|
217
|
-
(row[1][0] - row[0][1]) / s
|
218
|
-
];
|
219
|
-
}
|
220
|
-
|
221
|
-
return [translate, scale, skew, quaternion, perspective];
|
222
|
-
}
|
223
|
-
return decomposeMatrix;
|
224
|
-
})();
|
225
|
-
|
226
|
-
function dot(v1, v2) {
|
227
|
-
var result = 0;
|
228
|
-
for (var i = 0; i < v1.length; i++) {
|
229
|
-
result += v1[i] * v2[i];
|
230
|
-
}
|
231
|
-
return result;
|
232
|
-
}
|
233
|
-
|
234
|
-
function multiplyMatrices(a, b) {
|
235
|
-
return [
|
236
|
-
a[0] * b[0] + a[4] * b[1] + a[8] * b[2] + a[12] * b[3],
|
237
|
-
a[1] * b[0] + a[5] * b[1] + a[9] * b[2] + a[13] * b[3],
|
238
|
-
a[2] * b[0] + a[6] * b[1] + a[10] * b[2] + a[14] * b[3],
|
239
|
-
a[3] * b[0] + a[7] * b[1] + a[11] * b[2] + a[15] * b[3],
|
240
|
-
|
241
|
-
a[0] * b[4] + a[4] * b[5] + a[8] * b[6] + a[12] * b[7],
|
242
|
-
a[1] * b[4] + a[5] * b[5] + a[9] * b[6] + a[13] * b[7],
|
243
|
-
a[2] * b[4] + a[6] * b[5] + a[10] * b[6] + a[14] * b[7],
|
244
|
-
a[3] * b[4] + a[7] * b[5] + a[11] * b[6] + a[15] * b[7],
|
245
|
-
|
246
|
-
a[0] * b[8] + a[4] * b[9] + a[8] * b[10] + a[12] * b[11],
|
247
|
-
a[1] * b[8] + a[5] * b[9] + a[9] * b[10] + a[13] * b[11],
|
248
|
-
a[2] * b[8] + a[6] * b[9] + a[10] * b[10] + a[14] * b[11],
|
249
|
-
a[3] * b[8] + a[7] * b[9] + a[11] * b[10] + a[15] * b[11],
|
250
|
-
|
251
|
-
a[0] * b[12] + a[4] * b[13] + a[8] * b[14] + a[12] * b[15],
|
252
|
-
a[1] * b[12] + a[5] * b[13] + a[9] * b[14] + a[13] * b[15],
|
253
|
-
a[2] * b[12] + a[6] * b[13] + a[10] * b[14] + a[14] * b[15],
|
254
|
-
a[3] * b[12] + a[7] * b[13] + a[11] * b[14] + a[15] * b[15]
|
255
|
-
];
|
256
|
-
}
|
257
|
-
|
258
|
-
// TODO: This can probably be made smaller.
|
259
|
-
function convertItemToMatrix(item) {
|
260
|
-
switch (item.t) {
|
261
|
-
// TODO: Handle units other than rads and degs.
|
262
|
-
case 'rotatex':
|
263
|
-
var rads = item.d[0].rad || 0;
|
264
|
-
var degs = item.d[0].deg || 0;
|
265
|
-
var angle = (degs * Math.PI / 180) + rads;
|
266
|
-
return [1, 0, 0, 0,
|
267
|
-
0, Math.cos(angle), Math.sin(angle), 0,
|
268
|
-
0, -Math.sin(angle), Math.cos(angle), 0,
|
269
|
-
0, 0, 0, 1];
|
270
|
-
case 'rotatey':
|
271
|
-
var rads = item.d[0].rad || 0;
|
272
|
-
var degs = item.d[0].deg || 0;
|
273
|
-
var angle = (degs * Math.PI / 180) + rads;
|
274
|
-
return [Math.cos(angle), 0, -Math.sin(angle), 0,
|
275
|
-
0, 1, 0, 0,
|
276
|
-
Math.sin(angle), 0, Math.cos(angle), 0,
|
277
|
-
0, 0, 0, 1];
|
278
|
-
case 'rotate':
|
279
|
-
case 'rotatez':
|
280
|
-
var rads = item.d[0].rad || 0;
|
281
|
-
var degs = item.d[0].deg || 0;
|
282
|
-
var angle = (degs * Math.PI / 180) + rads;
|
283
|
-
return [Math.cos(angle), Math.sin(angle), 0, 0,
|
284
|
-
-Math.sin(angle), Math.cos(angle), 0, 0,
|
285
|
-
0, 0, 1, 0,
|
286
|
-
0, 0, 0, 1];
|
287
|
-
case 'rotate3d':
|
288
|
-
var x = item.d[0];
|
289
|
-
var y = item.d[1];
|
290
|
-
var z = item.d[2];
|
291
|
-
var rads = item.d[3].rad || 0;
|
292
|
-
var degs = item.d[3].deg || 0;
|
293
|
-
var angle = (degs * Math.PI / 180) + rads;
|
294
|
-
|
295
|
-
var sqrLength = x * x + y * y + z * z;
|
296
|
-
if (sqrLength === 0) {
|
297
|
-
x = 1;
|
298
|
-
y = 0;
|
299
|
-
z = 0;
|
300
|
-
} else if (sqrLength !== 1) {
|
301
|
-
var length = Math.sqrt(sqrLength);
|
302
|
-
x /= length;
|
303
|
-
y /= length;
|
304
|
-
z /= length;
|
305
|
-
}
|
306
|
-
|
307
|
-
var s = Math.sin(angle / 2);
|
308
|
-
var sc = s * Math.cos(angle / 2);
|
309
|
-
var sq = s * s;
|
310
|
-
return [
|
311
|
-
1 - 2 * (y * y + z * z) * sq,
|
312
|
-
2 * (x * y * sq + z * sc),
|
313
|
-
2 * (x * z * sq - y * sc),
|
314
|
-
0,
|
315
|
-
|
316
|
-
2 * (x * y * sq - z * sc),
|
317
|
-
1 - 2 * (x * x + z * z) * sq,
|
318
|
-
2 * (y * z * sq + x * sc),
|
319
|
-
0,
|
320
|
-
|
321
|
-
2 * (x * z * sq + y * sc),
|
322
|
-
2 * (y * z * sq - x * sc),
|
323
|
-
1 - 2 * (x * x + y * y) * sq,
|
324
|
-
0,
|
325
|
-
|
326
|
-
0, 0, 0, 1
|
327
|
-
];
|
328
|
-
case 'scale':
|
329
|
-
return [item.d[0], 0, 0, 0,
|
330
|
-
0, item.d[1], 0, 0,
|
331
|
-
0, 0, 1, 0,
|
332
|
-
0, 0, 0, 1];
|
333
|
-
case 'scalex':
|
334
|
-
return [item.d[0], 0, 0, 0,
|
335
|
-
0, 1, 0, 0,
|
336
|
-
0, 0, 1, 0,
|
337
|
-
0, 0, 0, 1];
|
338
|
-
case 'scaley':
|
339
|
-
return [1, 0, 0, 0,
|
340
|
-
0, item.d[0], 0, 0,
|
341
|
-
0, 0, 1, 0,
|
342
|
-
0, 0, 0, 1];
|
343
|
-
case 'scalez':
|
344
|
-
return [1, 0, 0, 0,
|
345
|
-
0, 1, 0, 0,
|
346
|
-
0, 0, item.d[0], 0,
|
347
|
-
0, 0, 0, 1];
|
348
|
-
case 'scale3d':
|
349
|
-
return [item.d[0], 0, 0, 0,
|
350
|
-
0, item.d[1], 0, 0,
|
351
|
-
0, 0, item.d[2], 0,
|
352
|
-
0, 0, 0, 1];
|
353
|
-
// FIXME: Skew behaves differently in Blink, FireFox and here. Need to work out why.
|
354
|
-
case 'skew':
|
355
|
-
var xDegs = item.d[0].deg || 0;
|
356
|
-
var xRads = item.d[0].rad || 0;
|
357
|
-
var yDegs = item.d[1].deg || 0;
|
358
|
-
var yRads = item.d[1].rad || 0;
|
359
|
-
var xAngle = (xDegs * Math.PI / 180) + xRads;
|
360
|
-
var yAngle = (yDegs * Math.PI / 180) + yRads;
|
361
|
-
return [1, Math.tan(yAngle), 0, 0,
|
362
|
-
Math.tan(xAngle), 1, 0, 0,
|
363
|
-
0, 0, 1, 0,
|
364
|
-
0, 0, 0, 1];
|
365
|
-
case 'skewx':
|
366
|
-
var rads = item.d[0].rad || 0;
|
367
|
-
var degs = item.d[0].deg || 0;
|
368
|
-
var angle = (degs * Math.PI / 180) + rads;
|
369
|
-
return [1, 0, 0, 0,
|
370
|
-
Math.tan(angle), 1, 0, 0,
|
371
|
-
0, 0, 1, 0,
|
372
|
-
0, 0, 0, 1];
|
373
|
-
case 'skewy':
|
374
|
-
var rads = item.d[0].rad || 0;
|
375
|
-
var degs = item.d[0].deg || 0;
|
376
|
-
var angle = (degs * Math.PI / 180) + rads;
|
377
|
-
return [1, Math.tan(angle), 0, 0,
|
378
|
-
0, 1, 0, 0,
|
379
|
-
0, 0, 1, 0,
|
380
|
-
0, 0, 0, 1];
|
381
|
-
// TODO: Work out what to do with non-px values.
|
382
|
-
case 'translate':
|
383
|
-
var x = item.d[0].px || 0;
|
384
|
-
var y = item.d[1].px || 0;
|
385
|
-
return [1, 0, 0, 0,
|
386
|
-
0, 1, 0, 0,
|
387
|
-
0, 0, 1, 0,
|
388
|
-
x, y, 0, 1];
|
389
|
-
case 'translatex':
|
390
|
-
var x = item.d[0].px || 0;
|
391
|
-
return [1, 0, 0, 0,
|
392
|
-
0, 1, 0, 0,
|
393
|
-
0, 0, 1, 0,
|
394
|
-
x, 0, 0, 1];
|
395
|
-
case 'translatey':
|
396
|
-
var y = item.d[0].px || 0;
|
397
|
-
return [1, 0, 0, 0,
|
398
|
-
0, 1, 0, 0,
|
399
|
-
0, 0, 1, 0,
|
400
|
-
0, y, 0, 1];
|
401
|
-
case 'translatez':
|
402
|
-
var z = item.d[0].px || 0;
|
403
|
-
return [1, 0, 0, 0,
|
404
|
-
0, 1, 0, 0,
|
405
|
-
0, 0, 1, 0,
|
406
|
-
0, 0, z, 1];
|
407
|
-
case 'translate3d':
|
408
|
-
var x = item.d[0].px || 0;
|
409
|
-
var y = item.d[1].px || 0;
|
410
|
-
var z = item.d[2].px || 0;
|
411
|
-
return [1, 0, 0, 0,
|
412
|
-
0, 1, 0, 0,
|
413
|
-
0, 0, 1, 0,
|
414
|
-
x, y, z, 1];
|
415
|
-
case 'perspective':
|
416
|
-
var p = item.d[0].px ? (-1 / item.d[0].px) : 0;
|
417
|
-
return [
|
418
|
-
1, 0, 0, 0,
|
419
|
-
0, 1, 0, 0,
|
420
|
-
0, 0, 1, p,
|
421
|
-
0, 0, 0, 1];
|
422
|
-
case 'matrix':
|
423
|
-
return [item.d[0], item.d[1], 0, 0,
|
424
|
-
item.d[2], item.d[3], 0, 0,
|
425
|
-
0, 0, 1, 0,
|
426
|
-
item.d[4], item.d[5], 0, 1];
|
427
|
-
case 'matrix3d':
|
428
|
-
return item.d;
|
429
|
-
default:
|
430
|
-
WEB_ANIMATIONS_TESTING && console.assert(false, 'Transform item type ' + item.t +
|
431
|
-
' conversion to matrix not yet implemented.');
|
432
|
-
}
|
433
|
-
}
|
434
|
-
|
435
|
-
function convertToMatrix(transformList) {
|
436
|
-
if (transformList.length === 0) {
|
437
|
-
return [1, 0, 0, 0,
|
438
|
-
0, 1, 0, 0,
|
439
|
-
0, 0, 1, 0,
|
440
|
-
0, 0, 0, 1];
|
441
|
-
}
|
442
|
-
return transformList.map(convertItemToMatrix).reduce(multiplyMatrices);
|
443
|
-
}
|
444
|
-
|
445
|
-
function makeMatrixDecomposition(transformList) {
|
446
|
-
return [decomposeMatrix(convertToMatrix(transformList))];
|
447
|
-
}
|
448
|
-
|
449
|
-
scope.dot = dot;
|
450
|
-
scope.makeMatrixDecomposition = makeMatrixDecomposition;
|
451
|
-
|
452
|
-
})(webAnimationsMinifill, webAnimationsTesting);
|