diff options
Diffstat (limited to 'js/panels/Timeline/Tween.reel/Tween.js')
-rw-r--r-- | js/panels/Timeline/Tween.reel/Tween.js | 105 |
1 files changed, 56 insertions, 49 deletions
diff --git a/js/panels/Timeline/Tween.reel/Tween.js b/js/panels/Timeline/Tween.reel/Tween.js index 0d189fba..85fdfdc9 100644 --- a/js/panels/Timeline/Tween.reel/Tween.js +++ b/js/panels/Timeline/Tween.reel/Tween.js | |||
@@ -1,8 +1,32 @@ | |||
1 | /* <copyright> | 1 | /* <copyright> |
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | 2 | Copyright (c) 2012, Motorola Mobility, Inc |
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | 3 | All Rights Reserved. |
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | 4 | BSD License. |
5 | </copyright> */ | 5 | |
6 | Redistribution and use in source and binary forms, with or without | ||
7 | modification, are permitted provided that the following conditions are met: | ||
8 | |||
9 | - Redistributions of source code must retain the above copyright notice, | ||
10 | this list of conditions and the following disclaimer. | ||
11 | - Redistributions in binary form must reproduce the above copyright | ||
12 | notice, this list of conditions and the following disclaimer in the | ||
13 | documentation and/or other materials provided with the distribution. | ||
14 | - Neither the name of Motorola Mobility nor the names of its contributors | ||
15 | may be used to endorse or promote products derived from this software | ||
16 | without specific prior written permission. | ||
17 | |||
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||
22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
25 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
26 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
27 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
28 | POSSIBILITY OF SUCH DAMAGE. | ||
29 | </copyright> */ | ||
6 | 30 | ||
7 | var Montage = require("montage/core/core").Montage; | 31 | var Montage = require("montage/core/core").Montage; |
8 | var Component = require("montage/ui/component").Component; | 32 | var Component = require("montage/ui/component").Component; |
@@ -11,6 +35,7 @@ var ElementsMediator = require("js/mediators/element-mediator").ElementMediator; | |||
11 | 35 | ||
12 | var Tween = exports.Tween = Montage.create(Component, { | 36 | var Tween = exports.Tween = Montage.create(Component, { |
13 | 37 | ||
38 | // ==== Begin Models | ||
14 | keyframe: { | 39 | keyframe: { |
15 | value: null, | 40 | value: null, |
16 | serializable: true | 41 | serializable: true |
@@ -184,6 +209,23 @@ var Tween = exports.Tween = Montage.create(Component, { | |||
184 | } | 209 | } |
185 | }, | 210 | }, |
186 | 211 | ||
212 | setData:{ | ||
213 | value:function(){ | ||
214 | this.spanWidth = this.tweenData.spanWidth; | ||
215 | this.keyFramePosition = this.tweenData.keyFramePosition; | ||
216 | this.spanPosition = this.tweenData.spanPosition; | ||
217 | this.keyFrameMillisec = this.tweenData.keyFrameMillisec; | ||
218 | this.tweenID = this.tweenData.tweenID; | ||
219 | this.tweenedProperties = this.tweenData.tweenedProperties; | ||
220 | this.isTweenAnimated = this.tweenData.isTweenAnimated; | ||
221 | this.easing = this.tweenData.easing; | ||
222 | this.initSelect = this.tweenData.initSelect; | ||
223 | this.needsDraw = true; | ||
224 | } | ||
225 | }, | ||
226 | // ==== End Models | ||
227 | |||
228 | // ==== Begin Draw cycle methods | ||
187 | prepareForDraw:{ | 229 | prepareForDraw:{ |
188 | value:function(){ | 230 | value:function(){ |
189 | if(this.initSelect){ | 231 | if(this.initSelect){ |
@@ -206,37 +248,19 @@ var Tween = exports.Tween = Montage.create(Component, { | |||
206 | } | 248 | } |
207 | } | 249 | } |
208 | }, | 250 | }, |
251 | // ==== End Draw cycle methods | ||
209 | 252 | ||
210 | setData:{ | 253 | // ==== Begin Event handlers |
211 | value:function(){ | ||
212 | this.spanWidth = this.tweenData.spanWidth; | ||
213 | this.keyFramePosition = this.tweenData.keyFramePosition; | ||
214 | this.spanPosition = this.tweenData.spanPosition; | ||
215 | this.keyFrameMillisec = this.tweenData.keyFrameMillisec; | ||
216 | this.tweenID = this.tweenData.tweenID; | ||
217 | this.tweenedProperties = this.tweenData.tweenedProperties; | ||
218 | this.isTweenAnimated = this.tweenData.isTweenAnimated; | ||
219 | this.easing = this.tweenData.easing; | ||
220 | this.initSelect = this.tweenData.initSelect; | ||
221 | this.needsDraw = true; | ||
222 | } | ||
223 | }, | ||
224 | |||
225 | handleElementChange:{ | 254 | handleElementChange:{ |
226 | value:function (event) { | 255 | value:function (event) { |
227 | // temp - testing var | ||
228 | var useAbsolute = true; | ||
229 | |||
230 | if(event.detail.type === "cssChange"){ | 256 | if(event.detail.type === "cssChange"){ |
231 | event.detail.source="cssPanelChange" | 257 | event.detail.source="cssPanelChange" |
232 | } | 258 | } |
233 | |||
234 | if (event.detail.source && event.detail.source !== "tween") { | 259 | if (event.detail.source && event.detail.source !== "tween") { |
235 | 260 | ||
236 | if(this.parentComponent.parentComponent.isSubproperty){ | 261 | if(this.parentComponent.parentComponent.isSubproperty){ |
237 | this.setStyleTweenProperty(event.detail); | 262 | this.setStyleTweenProperty(event.detail); |
238 | } else { | 263 | } else { |
239 | // check for correct element selection | ||
240 | if (this.application.ninja.selectedElements[0] != this.parentComponent.parentComponent.animatedElement) { | 264 | if (this.application.ninja.selectedElements[0] != this.parentComponent.parentComponent.animatedElement) { |
241 | console.log("Wrong element selected for this keyframe track"); | 265 | console.log("Wrong element selected for this keyframe track"); |
242 | } else { | 266 | } else { |
@@ -246,10 +270,11 @@ var Tween = exports.Tween = Montage.create(Component, { | |||
246 | } | 270 | } |
247 | } | 271 | } |
248 | }, | 272 | }, |
273 | // ==== End Event handlers | ||
249 | 274 | ||
275 | // ==== Begin Controllers | ||
250 | setTweenProperties:{ | 276 | setTweenProperties:{ |
251 | value:function (eventDetail) { | 277 | value:function (eventDetail) { |
252 | |||
253 | if (eventDetail.source === "SelectionTool" || eventDetail.source === "timeline" || eventDetail.source === "pi" || eventDetail.source === "cssPanelChange") { | 278 | if (eventDetail.source === "SelectionTool" || eventDetail.source === "timeline" || eventDetail.source === "pi" || eventDetail.source === "cssPanelChange") { |
254 | if(this.parentComponent.parentComponent.animatedElement.offsetTop != this.tweenedProperties["top"]){ | 279 | if(this.parentComponent.parentComponent.animatedElement.offsetTop != this.tweenedProperties["top"]){ |
255 | this.tweenedProperties["top"] = this.parentComponent.parentComponent.animatedElement.offsetTop + "px"; | 280 | this.tweenedProperties["top"] = this.parentComponent.parentComponent.animatedElement.offsetTop + "px"; |
@@ -263,7 +288,7 @@ var Tween = exports.Tween = Montage.create(Component, { | |||
263 | if (this.parentComponent.parentComponent.animatedElement.offsetHeight != this.tweenedProperties["height"]){ | 288 | if (this.parentComponent.parentComponent.animatedElement.offsetHeight != this.tweenedProperties["height"]){ |
264 | this.tweenedProperties["height"] = this.parentComponent.parentComponent.animatedElement.offsetHeight + "px"; | 289 | this.tweenedProperties["height"] = this.parentComponent.parentComponent.animatedElement.offsetHeight + "px"; |
265 | } | 290 | } |
266 | // tell track to update css rule | 291 | |
267 | this.parentComponent.parentComponent.updateKeyframeRule(); | 292 | this.parentComponent.parentComponent.updateKeyframeRule(); |
268 | this.isTweenAnimated = true; | 293 | this.isTweenAnimated = true; |
269 | } | 294 | } |
@@ -281,26 +306,17 @@ var Tween = exports.Tween = Montage.create(Component, { | |||
281 | 306 | ||
282 | setStyleTweenProperty:{ | 307 | setStyleTweenProperty:{ |
283 | value:function (eventDetail) { | 308 | value:function (eventDetail) { |
284 | //console.log("Setting style tween properties for: " + this.parentComponent.parentComponent.trackEditorProperty); | ||
285 | //console.log(eventDetail); | ||
286 | if(eventDetail.type == "setProperties"){ | 309 | if(eventDetail.type == "setProperties"){ |
287 | // need to ignore top, left, width, and height | ||
288 | //console.log(eventDetail.data.value[0]); | ||
289 | this.tweenedProperties[this.parentComponent.parentComponent.trackEditorProperty] = eventDetail.data.value[0]; | 310 | this.tweenedProperties[this.parentComponent.parentComponent.trackEditorProperty] = eventDetail.data.value[0]; |
290 | this.parentComponent.parentComponent.updatePropKeyframeRule(); | 311 | this.parentComponent.parentComponent.updatePropKeyframeRule(); |
291 | |||
292 | } else if(eventDetail.type == "setColor"){ | 312 | } else if(eventDetail.type == "setColor"){ |
293 | var prop = this.parentComponent.parentComponent.trackEditorProperty; | 313 | var prop = this.parentComponent.parentComponent.trackEditorProperty; |
294 | this.tweenedProperties[prop] = eventDetail.data.value.color.css; | 314 | this.tweenedProperties[prop] = eventDetail.data.value.color.css; |
295 | this.parentComponent.parentComponent.updatePropKeyframeRule(); | 315 | this.parentComponent.parentComponent.updatePropKeyframeRule(); |
296 | |||
297 | } else if(eventDetail.type == "setProperty"){ | 316 | } else if(eventDetail.type == "setProperty"){ |
298 | // need to ignore top, left, width, and height | ||
299 | //console.log(eventDetail.data.value[0]); | ||
300 | this.tweenedProperties[this.parentComponent.parentComponent.trackEditorProperty] = eventDetail.data.value[0]; | 317 | this.tweenedProperties[this.parentComponent.parentComponent.trackEditorProperty] = eventDetail.data.value[0]; |
301 | this.parentComponent.parentComponent.updatePropKeyframeRule(); | 318 | this.parentComponent.parentComponent.updatePropKeyframeRule(); |
302 | 319 | } else { | |
303 | }else { | ||
304 | console.log("TWEEN Unhandled type - setStyleTweenProperty : " + eventDetail.type); | 320 | console.log("TWEEN Unhandled type - setStyleTweenProperty : " + eventDetail.type); |
305 | } | 321 | } |
306 | } | 322 | } |
@@ -308,7 +324,6 @@ var Tween = exports.Tween = Montage.create(Component, { | |||
308 | 324 | ||
309 | setKeyframeEase:{ | 325 | setKeyframeEase:{ |
310 | value:function(easeType){ | 326 | value:function(easeType){ |
311 | // easeTypes - ease, ease-out, ease-in, ease-in-out, linear, cubic-bezier(x1, y1, x2, y2) | ||
312 | this.tweenedProperties["-webkit-animation-timing-function"] = easeType; | 327 | this.tweenedProperties["-webkit-animation-timing-function"] = easeType; |
313 | if(this.parentComponent.parentComponent.isSubproperty){ | 328 | if(this.parentComponent.parentComponent.isSubproperty){ |
314 | if(this.parentComponent.parentComponent.trackType == "position"){ | 329 | if(this.parentComponent.parentComponent.trackType == "position"){ |
@@ -323,18 +338,13 @@ var Tween = exports.Tween = Montage.create(Component, { | |||
323 | 338 | ||
324 | selectTween:{ | 339 | selectTween:{ |
325 | value: function(){ | 340 | value: function(){ |
326 | // turn on event listener for element change | ||
327 | this.eventManager.addEventListener("elementChange", this, false); | 341 | this.eventManager.addEventListener("elementChange", this, false); |
328 | |||
329 | // select the containing layer | ||
330 | var selectIndex = this.application.ninja.timeline.getLayerIndexByID(this.parentComponent.parentComponent.trackID); | 342 | var selectIndex = this.application.ninja.timeline.getLayerIndexByID(this.parentComponent.parentComponent.trackID); |
331 | this.application.ninja.timeline.selectLayer(selectIndex, true); | 343 | // this.application.ninja.timeline.selectLayer(selectIndex, true); // deprecated |
332 | 344 | this.application.ninja.timeline.selectLayers([selectIndex]); | |
333 | // tell timeline to deselect all other tweens and push this one into the selectedTweens in timeline | 345 | this.application.ninja.timeline.updateStageSelection(); |
334 | this.application.ninja.timeline |