|
1 | | -var Clone = require('../utils/object/Clone'); |
2 | 1 | var GetValue = require('../utils/object/GetValue'); |
3 | 2 | var GetAdvancedValue = require('../utils/object/GetAdvancedValue'); |
4 | 3 | var Tween = require('./Tween'); |
@@ -64,20 +63,21 @@ var GetProps = function (config) |
64 | 63 | var GetValueOp = function (key, value) |
65 | 64 | { |
66 | 65 | var valueCallback; |
| 66 | + var t = typeof(value); |
67 | 67 |
|
68 | | - if (typeof value === 'number') |
| 68 | + if (t === 'number') |
69 | 69 | { |
70 | 70 | // props: { |
71 | 71 | // x: 400, |
72 | 72 | // y: 300 |
73 | 73 | // } |
74 | 74 |
|
75 | | - valueCallback = function (i) |
| 75 | + valueCallback = function () |
76 | 76 | { |
77 | 77 | return value; |
78 | 78 | }; |
79 | 79 | } |
80 | | - else if (typeof value === 'string') |
| 80 | + else if (t === 'string') |
81 | 81 | { |
82 | 82 | // props: { |
83 | 83 | // x: '+=400', |
@@ -126,7 +126,7 @@ var GetValueOp = function (key, value) |
126 | 126 | }; |
127 | 127 | } |
128 | 128 | } |
129 | | - else if (typeof value === 'function') |
| 129 | + else if (t === 'function') |
130 | 130 | { |
131 | 131 | // Technically this could return a number, string or object |
132 | 132 | // props: { |
@@ -158,7 +158,8 @@ var TweenBuilder = function (manager, config) |
158 | 158 | var targetKeys = {}; |
159 | 159 | var tweenKeys = {}; |
160 | 160 |
|
161 | | - props.forEach(function (p) { |
| 161 | + props.forEach(function (p) |
| 162 | + { |
162 | 163 | targetKeys[p.key] = { start: 0, current: 0, end: 0 }; |
163 | 164 | tweenKeys[p.key] = { current: null, list: [] }; |
164 | 165 | }); |
@@ -190,59 +191,24 @@ var TweenBuilder = function (manager, config) |
190 | 191 | for (var p = 0; p < props.length; p++) |
191 | 192 | { |
192 | 193 | var key = props[p].key; |
193 | | - var values = props[p].value; |
194 | | - |
195 | | - if (!Array.isArray(values)) |
196 | | - { |
197 | | - values = [ values ]; |
198 | | - } |
199 | | - |
200 | | - var prev = null; |
201 | | - |
202 | | - // Loop through every value for the property, i.e.: x: [ 200, 300, 400 ] |
203 | | - for (var i = 0; i < values.length; i++) |
204 | | - { |
205 | | - var value = values[i]; |
206 | | - |
207 | | - var tweenData = TweenData( |
208 | | - key, |
209 | | - GetValueOp(key, value), |
210 | | - GetEaseFunction(GetValue(value, 'ease', ease)), |
211 | | - GetAdvancedValue(value, 'delay', delay), |
212 | | - GetAdvancedValue(value, 'duration', duration), |
213 | | - GetAdvancedValue(value, 'hold', hold), |
214 | | - GetAdvancedValue(value, 'repeat', repeat), |
215 | | - GetAdvancedValue(value, 'repeatDelay', repeatDelay), |
216 | | - GetAdvancedValue(value, 'startAt', startAt), |
217 | | - GetValue(value, 'yoyo', yoyo) |
218 | | - ); |
219 | | - |
220 | | - // Calculate total duration |
221 | | - |
222 | | - // Duration is derived from: |
223 | | - // TweenData.duration |
224 | | - // TweenData.delay |
225 | | - // TweenData.hold |
226 | | - // x TweenData.repeat |
227 | | - |
228 | | - // var totalDuration = 0; |
229 | | - |
230 | | - // var playThruDuration = tweenData.duration * tweenData.repeat; |
231 | | - |
232 | | - // totalDuration |
233 | | - // tweenData.totalDuration = |
234 | | - |
235 | | - tweenData.prev = prev; |
236 | | - |
237 | | - if (prev) |
238 | | - { |
239 | | - prev.next = tweenData; |
240 | | - } |
241 | | - |
242 | | - tween.data[key].list.push(tweenData); |
243 | | - |
244 | | - prev = tweenData; |
245 | | - } |
| 194 | + var value = props[p].value; |
| 195 | + |
| 196 | + var tweenData = TweenData( |
| 197 | + key, |
| 198 | + GetValueOp(key, value), |
| 199 | + GetEaseFunction(GetValue(value, 'ease', ease)), |
| 200 | + GetAdvancedValue(value, 'delay', delay), |
| 201 | + GetAdvancedValue(value, 'duration', duration), |
| 202 | + GetAdvancedValue(value, 'hold', hold), |
| 203 | + GetAdvancedValue(value, 'repeat', repeat), |
| 204 | + GetAdvancedValue(value, 'repeatDelay', repeatDelay), |
| 205 | + GetAdvancedValue(value, 'startAt', startAt), |
| 206 | + GetValue(value, 'yoyo', yoyo) |
| 207 | + ); |
| 208 | + |
| 209 | + // TODO: Calculate total duration |
| 210 | + |
| 211 | + tween.data[key] = tweenData; |
246 | 212 | } |
247 | 213 |
|
248 | 214 | return tween; |
|
0 commit comments