diff options
Diffstat (limited to 'node_modules/montage/ui/flow.reel/flow.js')
-rw-r--r-- | node_modules/montage/ui/flow.reel/flow.js | 348 |
1 files changed, 348 insertions, 0 deletions
diff --git a/node_modules/montage/ui/flow.reel/flow.js b/node_modules/montage/ui/flow.reel/flow.js new file mode 100644 index 00000000..c0a6b32f --- /dev/null +++ b/node_modules/montage/ui/flow.reel/flow.js | |||
@@ -0,0 +1,348 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | |||
7 | var Montage = require("montage").Montage, | ||
8 | Component = require("ui/component").Component; | ||
9 | |||
10 | var Flow = exports.Flow = Montage.create(Component, { | ||
11 | |||
12 | _path: { | ||
13 | enumerable: false, | ||
14 | value: { | ||
15 | value: function (slide) { | ||
16 | return { | ||
17 | translateX: slide.time, | ||
18 | translateY: 0, | ||
19 | translateZ: 0, | ||
20 | scale: 1, | ||
21 | rotateX: 0, | ||
22 | rotateY: 0, | ||
23 | rotateZ: 0, | ||
24 | transformOriginX: 0, | ||
25 | transformOriginY: 0, | ||
26 | transformOriginZ: 0, | ||
27 | style: {} | ||
28 | }; | ||
29 | } | ||
30 | } | ||
31 | }, | ||
32 | |||
33 | path: { | ||
34 | get: function () { | ||
35 | return this._path; | ||
36 | }, | ||
37 | set: function (value) { | ||
38 | this._path = value; | ||
39 | this.needsDraw = true; | ||
40 | } | ||
41 | }, | ||
42 | |||
43 | _rotationOrder: { | ||
44 | enumerable: false, | ||
45 | value: "xyz" | ||
46 | }, | ||
47 | |||
48 | rotationOrder: { | ||
49 | get: function () { | ||
50 | return this._rotationOrder; | ||
51 | }, | ||
52 | set: function (value) { | ||
53 | switch (value) { | ||
54 | case "xzy": | ||
55 | case "yxz": | ||
56 | case "yzx": | ||
57 | case "zxy": | ||
58 | case "zyx": | ||
59 | this._rotationOrder=value; | ||
60 | break; | ||
61 | default: | ||
62 | this._rotationOrder="xyz"; | ||
63 | break; | ||
64 | } | ||
65 | this.needsDraw = true; | ||
66 | } | ||
67 | }, | ||
68 | |||
69 | numberOfNodes: { | ||
70 | value: null | ||
71 | }, | ||
72 | |||
73 | _nodeOffset: { | ||
74 | enumerable: false, | ||
75 | value: { | ||
76 | value: function (nodeNumber) { | ||
77 | return { | ||
78 | time: nodeNumber*100, | ||
79 | speed: 0 | ||
80 | } | ||
81 | } | ||
82 | } | ||
83 | }, | ||
84 | |||
85 | nodeOffset: { | ||
86 | get: function () { | ||
87 | return this._nodeOffset; | ||
88 | }, | ||
89 | set: function (value) { | ||
90 | this._nodeOffset = value; | ||
91 | this.needsDraw = true; | ||
92 | } | ||
93 | }, | ||
94 | |||
95 | _width: { | ||
96 | enumerable: false, | ||
97 | value: null | ||
98 | }, | ||
99 | |||
100 | _height: { | ||
101 | enumerable: false, | ||
102 | value: null | ||
103 | }, | ||
104 | |||
105 | _repetitionComponents: { | ||
106 | enumerable: false, | ||
107 | value: null | ||
108 | }, | ||
109 | |||
110 | prepareForDraw: { | ||
111 | enumerable: false, | ||
112 | value: function () { | ||
113 | this._repetitionComponents=this._repetition._childComponents; | ||
114 | } | ||
115 | }, | ||
116 | |||
117 | draw: { | ||
118 | enumerable: false, | ||
119 | value: function () { | ||
120 | var i, | ||
121 | length = this.numberOfNodes, | ||
122 | slide={ | ||
123 | index: null, | ||
124 | time: null, | ||
125 | speed: null | ||
126 | }, | ||
127 | transform, | ||
128 | origin, | ||
129 | iPath, | ||
130 | j, | ||
131 | jPath, | ||
132 | iOffset, | ||
133 | iStyle; | ||
134 | |||
135 | for (i=0; i<length; i++) { | ||
136 | iStyle=this._repetitionComponents[i].element.style; | ||
137 | iOffset=this._nodeOffset.value(i); | ||
138 | slide.index=i; | ||
139 | slide.time=iOffset.time; | ||
140 | slide.speed=iOffset.speed; | ||
141 | iPath=this._path.value(slide); | ||
142 | if (typeof iPath.translateX==="undefined") { | ||
143 | iPath.translateX=0; | ||
144 | } | ||
145 | if (typeof iPath.translateY==="undefined") { | ||
146 | iPath.translateY=0; | ||
147 | } | ||
148 | if (typeof iPath.translateZ==="undefined") { | ||
149 | iPath.translateZ=0; | ||
150 | } | ||
151 | transform="translate3d("; | ||
152 | transform+=(typeof iPath.translateX==="number")?iPath.translateX+"px,":iPath.translateX+","; | ||
153 | transform+=(typeof iPath.translateY==="number")?iPath.translateY+"px,":iPath.translateY+","; | ||
154 | transform+=(typeof iPath.translateZ==="number")?iPath.translateZ+"px) ":iPath.translateZ+") "; | ||
155 | transform+=(typeof iPath.scale!=="undefined")?"scale("+iPath.scale+") ":""; | ||
156 | switch (this._rotationOrder) { | ||
157 | case "xyz": | ||
158 | transform+=(typeof iPath.rotateZ!=="undefined")?"rotateZ("+iPath.rotateZ+"rad) ":""; | ||
159 | transform+=(typeof iPath.rotateY!=="undefined")?"rotateY("+iPath.rotateY+"rad) ":""; | ||
160 | transform+=(typeof iPath.rotateX!=="undefined")?"rotateX("+iPath.rotateX+"rad) ":""; | ||
161 | break; | ||
162 | case "xzy": | ||
163 | transform+=(typeof iPath.rotateY!=="undefined")?"rotateY("+iPath.rotateY+"rad) ":""; | ||
164 | transform+=(typeof iPath.rotateZ!=="undefined")?"rotateZ("+iPath.rotateZ+"rad) ":""; | ||
165 | transform+=(typeof iPath.rotateX!=="undefined")?"rotateX("+iPath.rotateX+"rad) ":""; | ||
166 | break; | ||
167 | case "yxz": | ||
168 | transform+=(typeof iPath.rotateZ!=="undefined")?"rotateZ("+iPath.rotateZ+"rad) ":""; | ||
169 | transform+=(typeof iPath.rotateX!=="undefined")?"rotateX("+iPath.rotateX+"rad) ":""; | ||
170 | transform+=(typeof iPath.rotateY!=="undefined")?"rotateY("+iPath.rotateY+"rad) ":""; | ||
171 | break; | ||
172 | case "yzx": | ||
173 | transform+=(typeof iPath.rotateX!=="undefined")?"rotateX("+iPath.rotateX+"rad) ":""; | ||
174 | transform+=(typeof iPath.rotateZ!=="undefined")?"rotateZ("+iPath.rotateZ+"rad) ":""; | ||
175 | transform+=(typeof iPath.rotateY!=="undefined")?"rotateY("+iPath.rotateY+"rad) ":""; | ||
176 | break; | ||
177 | case "zxy": | ||
178 | transform+=(typeof iPath.rotateY!=="undefined")?"rotateY("+iPath.rotateY+"rad) ":""; | ||
179 | transform+=(typeof iPath.rotateX!=="undefined")?"rotateX("+iPath.rotateX+"rad) ":""; | ||
180 | transform+=(typeof iPath.rotateZ!=="undefined")?"rotateZ("+iPath.rotateZ+"rad) ":""; | ||
181 | break; | ||
182 | case "zyx": | ||
183 | transform+=(typeof iPath.rotateX!=="undefined")?"rotateX("+iPath.rotateX+"rad) ":""; | ||
184 | transform+=(typeof iPath.rotateY!=="undefined")?"rotateY("+iPath.rotateY+"rad) ":""; | ||
185 | transform+=(typeof iPath.rotateZ!=="undefined")?"rotateZ("+iPath.rotateZ+"rad) ":""; | ||
186 | break; | ||
187 | } | ||
188 | iStyle.webkitTransform=transform; | ||
189 | if (typeof iPath.transformOriginX==="undefined") { | ||
190 | iPath.transformOriginX="50%"; | ||
191 | } | ||
192 | if (typeof iPath.transformOriginY==="undefined") { | ||
193 | iPath.transformOriginY="50%"; | ||
194 | } | ||
195 | if (typeof iPath.transformOriginZ==="undefined") { | ||
196 | iPath.transformOriginZ=0; | ||
197 | } | ||
198 | origin=(typeof iPath.transformOriginX==="number")?iPath.transformOriginX+"px ":iPath.transformOriginX+" "; | ||
199 | origin+=(typeof iPath.transformOriginY==="number")?iPath.transformOriginY+"px ":iPath.transformOriginY+" "; | ||
200 | origin+=(typeof iPath.transformOriginZ==="number")?iPath.transformOriginZ+"px":iPath.transformOriginZ; | ||
201 | iStyle.webkitTransformOrigin=origin; | ||
202 | if (typeof iPath.style!=="undefined") { | ||
203 | for (j in iPath.style) { | ||
204 | if ((iPath.style.hasOwnProperty(j))&&(iStyle[j]!==iPath.style[j])) { | ||
205 | iStyle[j]=iPath.style[j]; | ||
206 | } | ||
207 | } | ||
208 | } | ||
209 | } | ||
210 | } | ||
211 | }, | ||
212 | |||
213 | /////////////////////////////// Almost Copy/Pasted from List /////////////////////////// | ||
214 | |||
215 | _orphanedChildren: { | ||
216 | enumerable: false, | ||
217 | value: null | ||
218 | }, | ||
219 | |||
220 | _objectsForRepetition: { | ||
221 | enumerable: false, | ||
222 | value: null | ||
223 | }, | ||