[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 /* 2 YUI 3.17.2 (build 9c3c78e) 3 Copyright 2014 Yahoo! Inc. All rights reserved. 4 Licensed under the BSD License. 5 http://yuilibrary.com/license/ 6 */ 7 8 YUI.add('anim-shape', function (Y, NAME) { 9 10 /** 11 * Adds support for the <code>transform</code> attribute of <code>Graphic</code> 12 * <code>Shape</code> instances. 13 * @module anim 14 * @submodule anim-shape-transform 15 * @deprecated Use anim-shape instead. 16 */ 17 /** 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. 21 * 22 * @module anim 23 * @submodule anim-shape 24 */ 25 var NUM = Number, 26 TO, 27 TOSTRING, 28 COLOR = "color", 29 STOPS = "stops", 30 TYPE = "type", 31 GETUPDATEDSTOPS = function(anim, from, to, elapsed, duration, fn) 32 { 33 var i = 0, 34 getUpdatedColorValue = Y.Anim.getUpdatedColorValue, 35 toStop, 36 fromStop, 37 prop, 38 len = to.length, 39 stops = [], 40 stop; 41 for(; i < len; i = i + 1) 42 { 43 toStop = to[i]; 44 fromStop = from[i]; 45 stop = {}; 46 for(prop in toStop) 47 { 48 if(toStop.hasOwnProperty(prop)) 49 { 50 if(prop === COLOR) 51 { 52 stop[prop] = Y.Color.toHex(getUpdatedColorValue( 53 Y.Color.toHex(fromStop[prop]), 54 Y.Color.toHex(toStop[prop]), 55 elapsed, 56 duration, 57 fn 58 )); 59 } 60 else 61 { 62 stop[prop] = fn(elapsed, NUM(fromStop[prop]), NUM(toStop[prop]) - NUM(fromStop[prop]), duration); 63 } 64 } 65 } 66 stops.push(stop); 67 } 68 return stops; 69 }, 70 FILLANDSTROKEBEHAVIOR = { 71 set: function(anim, att, from, to, elapsed, duration, fn) { 72 var i, 73 updated = {}, 74 getUpdatedColorValue = Y.Anim.getUpdatedColorValue, 75 getUpdatedStops = GETUPDATEDSTOPS; 76 for(i in to) 77 { 78 if(to.hasOwnProperty(i) && i !== TYPE) 79 { 80 switch(i) 81 { 82 case COLOR : 83 updated[i] = getUpdatedColorValue(from[i], to[i], elapsed, duration, fn); 84 break; 85 case STOPS : 86 updated[i] = getUpdatedStops(anim, from[i], to[i], elapsed, duration, fn); 87 break; 88 default : 89 updated[i] = fn(elapsed, NUM(from[i]), NUM(to[i]) - NUM(from[i]), duration); 90 break; 91 } 92 } 93 } 94 anim._node.set(att, updated); 95 } 96 }; 97 Y.Anim.behaviors.fill = FILLANDSTROKEBEHAVIOR; 98 Y.Anim.behaviors.stroke = FILLANDSTROKEBEHAVIOR; 99 100 Y.Anim.behaviors.transform = { 101 set: function(anim, att, from, to, elapsed, duration, fn) { 102 var node = anim._node, 103 transform = "", 104 transformTo, 105 transformFrom, 106 toArgs, 107 fromArgs, 108 i = 0, 109 j, 110 argLen, 111 len; 112 to = TO; 113 len = TO.length; 114 for(; i < len; ++i) 115 { 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) 123 { 124 transform += fn(elapsed, NUM(fromArgs[j]), NUM(toArgs[j]) - NUM(fromArgs[j]), duration); 125 if(j < argLen - 1) 126 { 127 transform += ", "; 128 } 129 } 130 transform += ");"; 131 } 132 if(transform) 133 { 134 node.set('transform', transform); 135 } 136 node._transform = TOSTRING; 137 }, 138 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, 146 toMatrix, 147 i, 148 len, 149 transformFunction, 150 from; 151 if(toArray) 152 { 153 if(!fromArray || fromArray.length < 1) 154 { 155 fromArray = []; 156 len = toArray.length; 157 for(i = 0; i < len; ++i) 158 { 159 transformFunction = toArray[i][0]; 160 fromArray[i] = Y.MatrixUtil.getTransformFunctionArray(transformFunction); 161 } 162 TO = toArray; 163 from = fromArray; 164 } 165 else if(Y.MatrixUtil.compareTransformSequence(toArray, fromArray)) 166 { 167 TO = toArray; 168 from = fromArray; 169 } 170 else 171 { 172 toMatrix = new Y.Matrix(); 173 len = toArray.length; 174 for(i = 0; i < len; ++i) 175 { 176 transformFunction = toArray[i].shift(); 177 transformFunction = transformFunction === "matrix" ? "multiply" : transformFunction; 178 toMatrix[transformFunction].apply(toMatrix, toArray[i]); 179 } 180 181 TO = toMatrix.decompose(); 182 from = fromMatrix.decompose(); 183 } 184 } 185 TOSTRING = toString; 186 return from; 187 } 188 }; 189 190 191 192 }, '3.17.2', {"requires": ["anim-base", "anim-easing", "anim-color", "matrix"]});
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |