2 YUI 3.13.0 (build 508226d)
3 Copyright 2013 Yahoo! Inc. All rights reserved.
4 Licensed under the BSD License.
5 http://yuilibrary.com/license/
8 YUI.add('anim-shape', function (Y, NAME) {
11 * Adds support for the <code>transform</code> attribute of <code>Graphic</code>
12 * <code>Shape</code> instances.
14 * @submodule anim-shape-transform
15 * @deprecated Use anim-shape instead.
18 * Adds support for the <code>transform</code> and <code>fill</code> attributes of <code>Graphic</code>
19 * and <code>Shape</code> instances. The <code>anim-shape</code> submodule can be used for all animations
20 * involving <code>Graphic</code> <code>Shape</code> attributes.
23 * @submodule anim-shape
31 GETUPDATEDSTOPS = function(anim, from, to, elapsed, duration, fn)
34 getUpdatedColorValue = Y.Anim.getUpdatedColorValue,
41 for(; i < len; i = i + 1)
48 if(toStop.hasOwnProperty(prop))
52 stop[prop] = Y.Color.toHex(getUpdatedColorValue(
53 Y.Color.toHex(fromStop[prop]),
54 Y.Color.toHex(toStop[prop]),
62 stop[prop] = fn(elapsed, NUM(fromStop[prop]), NUM(toStop[prop]) - NUM(fromStop[prop]), duration);
70 FILLANDSTROKEBEHAVIOR = {
71 set: function(anim, att, from, to, elapsed, duration, fn) {
74 getUpdatedColorValue = Y.Anim.getUpdatedColorValue,
75 getUpdatedStops = GETUPDATEDSTOPS;
78 if(to.hasOwnProperty(i) && i !== TYPE)
83 updated[i] = getUpdatedColorValue(from[i], to[i], elapsed, duration, fn);
86 updated[i] = getUpdatedStops(anim, from[i], to[i], elapsed, duration, fn);
89 updated[i] = fn(elapsed, NUM(from[i]), NUM(to[i]) - NUM(from[i]), duration);
94 anim._node.set(att, updated);
97 Y.Anim.behaviors.fill = FILLANDSTROKEBEHAVIOR;
98 Y.Anim.behaviors.stroke = FILLANDSTROKEBEHAVIOR;
100 Y.Anim.behaviors.transform = {
101 set: function(anim, att, from, to, elapsed, duration, fn) {
102 var node = anim._node,
116 toArgs = to[i].concat();
117 fromArgs = from[i].concat();
118 transformTo = toArgs.shift();
119 transformFrom = fromArgs.shift();
120 argLen = toArgs.length;
121 transform += transformTo + "(";
122 for(j = 0; j < argLen; ++j)
124 transform += fn(elapsed, NUM(fromArgs[j]), NUM(toArgs[j]) - NUM(fromArgs[j]), duration);
134 node.set('transform', transform);
136 node._transform = TOSTRING;
139 get: function(anim) {
140 var node = anim._node,
141 fromMatrix = node.matrix,
142 toString = anim.get("to").transform,
143 fromString = node.get("transform"),
144 toArray = Y.MatrixUtil.getTransformArray(toString),
145 fromArray = fromString ? Y.MatrixUtil.getTransformArray(fromString) : null,
153 if(!fromArray || fromArray.length < 1)
156 len = toArray.length;
157 for(i = 0; i < len; ++i)
159 transformFunction = toArray[i][0];
160 fromArray[i] = Y.MatrixUtil.getTransformFunctionArray(transformFunction);
165 else if(Y.MatrixUtil.compareTransformSequence(toArray, fromArray))
172 toMatrix = new Y.Matrix();
173 len = toArray.length;
174 for(i = 0; i < len; ++i)
176 transformFunction = toArray[i].shift();
177 transformFunction = transformFunction === "matrix" ? "multiply" : transformFunction;
178 toMatrix[transformFunction].apply(toMatrix, toArray[i]);
181 TO = toMatrix.decompose();
182 from = fromMatrix.decompose();
192 }, '3.13.0', {"requires": ["anim-base", "anim-easing", "anim-color", "matrix"]});