diff options
Diffstat (limited to 'js/panels/Timeline/Tween.reel/Tween.js')
-rw-r--r-- | js/panels/Timeline/Tween.reel/Tween.js | 123 |
1 files changed, 80 insertions, 43 deletions
diff --git a/js/panels/Timeline/Tween.reel/Tween.js b/js/panels/Timeline/Tween.reel/Tween.js index dda06028..49cfa9c9 100644 --- a/js/panels/Timeline/Tween.reel/Tween.js +++ b/js/panels/Timeline/Tween.reel/Tween.js | |||
@@ -6,6 +6,8 @@ | |||
6 | 6 | ||
7 | var Montage = require("montage/core/core").Montage; | 7 | var Montage = require("montage/core/core").Montage; |
8 | var Component = require("montage/ui/component").Component; | 8 | var Component = require("montage/ui/component").Component; |
9 | var ElementsMediator = require("js/mediators/element-mediator").ElementMediator; | ||
10 | |||
9 | 11 | ||
10 | var Tween = exports.Tween = Montage.create(Component, { | 12 | var Tween = exports.Tween = Montage.create(Component, { |
11 | 13 | ||
@@ -138,7 +140,20 @@ var Tween = exports.Tween = Montage.create(Component, { | |||
138 | this._isTweenAnimated = value; | 140 | this._isTweenAnimated = value; |
139 | } | 141 | } |
140 | }, | 142 | }, |
141 | 143 | ||
144 | _isDragging: { | ||
145 | value: false | ||
146 | }, | ||
147 | isDragging: { | ||
148 | serializable: true, | ||
149 | get:function () { | ||
150 | return this._isDragging; | ||
151 | }, | ||
152 | set:function (newVal) { | ||
153 | this._isDragging = newVal; | ||
154 | } | ||
155 | |||
156 | }, | ||
142 | 157 | ||
143 | draw:{ | 158 | draw:{ |
144 | value:function () { | 159 | value:function () { |
@@ -170,62 +185,77 @@ var Tween = exports.Tween = Montage.create(Component, { | |||
170 | var useAbsolute = true; | 185 | var useAbsolute = true; |
171 | 186 | ||
172 | if (event.detail.source && event.detail.source !== "tween") { | 187 | if (event.detail.source && event.detail.source !== "tween") { |
173 | // check for correct element selection | 188 | |
174 | if (this.application.ninja.selectedElements[0] != this.parentComponent.parentComponent.animatedElement) { | 189 | if(this.parentComponent.parentComponent.isSubproperty){ |
175 | console.log("Wrong element selected for this keyframe track"); | 190 | this.setStyleTweenProperty(event.detail); |
176 | } else { | 191 | } else { |
177 | if(useAbsolute){ | 192 | // check for correct element selection |
178 | this.setAbsoluteTweenProperties(event.detail); | 193 | if (this.application.ninja.selectedElements[0] != this.parentComponent.parentComponent.animatedElement) { |
194 | console.log("Wrong element selected for this keyframe track"); | ||
179 | } else { | 195 | } else { |
180 | this.setRelativeTweenProperties(event.detail); | 196 | this.setTweenProperties(event.detail); |
181 | } | 197 | } |
182 | } | 198 | } |
183 | } | 199 | } |
184 | } | 200 | } |
185 | }, | 201 | }, |
186 | 202 | ||
187 | setAbsoluteTweenProperties:{ | 203 | setTweenProperties:{ |
188 | value:function (eventDetail) { | 204 | value:function (eventDetail) { |
189 | //console.log(eventDetail); | ||
190 | |||
191 | // top | ||
192 | if(this.parentComponent.parentComponent.animatedElement.offsetTop != this.tweenedProperties["top"]){ | 205 | if(this.parentComponent.parentComponent.animatedElement.offsetTop != this.tweenedProperties["top"]){ |
193 | this.tweenedProperties["top"] = this.parentComponent.parentComponent.animatedElement.offsetTop; | 206 | this.tweenedProperties["top"] = this.parentComponent.parentComponent.animatedElement.offsetTop + "px"; |
194 | } | 207 | } |
195 | |||
196 | // left | ||
197 | if(this.parentComponent.parentComponent.animatedElement.offsetLeft != this.tweenedProperties["left"]){ | 208 | if(this.parentComponent.parentComponent.animatedElement.offsetLeft != this.tweenedProperties["left"]){ |
198 | this.tweenedProperties["left"] = this.parentComponent.parentComponent.animatedElement.offsetLeft; | 209 | this.tweenedProperties["left"] = this.parentComponent.parentComponent.animatedElement.offsetLeft + "px"; |
199 | } | 210 | } |
200 | |||
201 | // width | ||
202 | if (this.parentComponent.parentComponent.animatedElement.offsetWidth != this.tweenedProperties["width"]){ | 211 | if (this.parentComponent.parentComponent.animatedElement.offsetWidth != this.tweenedProperties["width"]){ |
203 | this.tweenedProperties["width"] = this.parentComponent.parentComponent.animatedElement.offsetWidth; | 212 | this.tweenedProperties["width"] = this.parentComponent.parentComponent.animatedElement.offsetWidth + "px"; |
204 | } | 213 | } |
205 | |||
206 | // height | ||
207 | if (this.parentComponent.parentComponent.animatedElement.offsetHeight != this.tweenedProperties["height"]){ | 214 | if (this.parentComponent.parentComponent.animatedElement.offsetHeight != this.tweenedProperties["height"]){ |
208 | this.tweenedProperties["height"] = this.parentComponent.parentComponent.animatedElement.offsetHeight; | 215 | this.tweenedProperties["height"] = this.parentComponent.parentComponent.animatedElement.offsetHeight + "px"; |
209 | } | 216 | } |
210 | |||
211 | // skewX | ||
212 | |||
213 | // skewY | ||
214 | |||
215 | // rotation | ||
216 | |||
217 | // tell track to update css rule | 217 | // tell track to update css rule |
218 | this.parentComponent.parentComponent.updateKeyframeRule(); | 218 | this.parentComponent.parentComponent.updateKeyframeRule(); |
219 | |||
220 | // highlight the tween's span | ||
221 | this.tweenspan.highlightSpan(); | ||
222 | this.isTweenAnimated = true; | 219 | this.isTweenAnimated = true; |
223 | } | 220 | } |
224 | }, | 221 | }, |
225 | 222 | ||
226 | setRelativeTweenProperties:{ | 223 | setStyleTweenProperty:{ |
227 | value:function(eventDetail){ | 224 | value:function (eventDetail) { |
225 | //console.log("Setting style tween properties for: " + this.parentComponent.parentComponent.trackEditorProperty); | ||
228 | //console.log(eventDetail); | 226 | //console.log(eventDetail); |
227 | if(eventDetail.type == "setProperties"){ | ||
228 | // need to ignore top, left, width, and height | ||
229 | //console.log(eventDetail.data.value[0]); | ||
230 | this.tweenedProperties[this.parentComponent.parentComponent.trackEditorProperty] = eventDetail.data.value[0]; | ||
231 | this.parentComponent.parentComponent.updatePropKeyframeRule(); | ||
232 | |||
233 | } else if(eventDetail.type == "setColor"){ | ||
234 | var prop = this.parentComponent.parentComponent.trackEditorProperty; | ||
235 | this.tweenedProperties[prop] = eventDetail.data.value.color.css; | ||
236 | this.parentComponent.parentComponent.updatePropKeyframeRule(); | ||
237 | |||
238 | } else if(eventDetail.type == "setProperty"){ | ||
239 | // need to ignore top, left, width, and height | ||
240 | //console.log(eventDetail.data.value[0]); | ||
241 | this.tweenedProperties[this.parentComponent.parentComponent.trackEditorProperty] = eventDetail.data.value[0]; | ||
242 | this.parentComponent.parentComponent.updatePropKeyframeRule(); | ||
243 | |||
244 | }else { | ||
245 | console.log("TWEEN Unhandled type - setStyleTweenProperty : " + eventDetail.type); | ||
246 | } | ||
247 | } | ||
248 | }, | ||
249 | |||
250 | setKeyframeEase:{ | ||
251 | value:function(easeType){ | ||
252 | // easeTypes - ease, ease-out, ease-in, ease-in-out, linear, cubic-bezier(x1, y1, x2, y2) | ||
253 | this.tweenedProperties["-webkit-animation-timing-function"] = easeType; | ||
254 | if(this.parentComponent.parentComponent.isSubproperty){ | ||
255 | this.parentComponent.parentComponent.updatePropKeyframeRule(); | ||
256 | } else { | ||
257 | this.parentComponent.parentComponent.updateKeyframeRule(); | ||
258 | } | ||
229 | } | 259 | } |
230 | }, | 260 | }, |
231 | 261 | ||
@@ -238,7 +268,7 @@ var Tween = exports.Tween = Montage.create(Component, { | |||
238 | var selectIndex = this.application.ninja.timeline.getLayerIndexByID(this.parentComponent.parentComponent.trackID); | 268 | var selectIndex = this.application.ninja.timeline.getLayerIndexByID(this.parentComponent.parentComponent.trackID); |
239 | this.application.ninja.timeline.selectLayer(selectIndex, true); | 269 | this.application.ninja.timeline.selectLayer(selectIndex, true); |
240 | 270 | ||
241 | // tell timeline to deselect all other tweens and push this one as the currentSelectedTweens in timeline | 271 | // tell timeline to deselect all other tweens and push this one into the selectedTweens in timeline |
242 | this.application.ninja.timeline.deselectTweens(); | 272 | this.application.ninja.timeline.deselectTweens(); |
243 | this.application.ninja.timeline.selectedTweens.push(this); | 273 | this.application.ninja.timeline.selectedTweens.push(this); |
244 | 274 | ||
@@ -249,13 +279,22 @@ var Tween = exports.Tween = Montage.create(Component, { | |||
249 | var currentMillisec = currentMillisecPerPixel * this.keyFramePosition; | 279 | var currentMillisec = currentMillisecPerPixel * this.keyFramePosition; |
250 | this.application.ninja.timeline.updateTimeText(currentMillisec); | 280 | this.application.ninja.timeline.updateTimeText(currentMillisec); |
251 | 281 | ||
252 | // move animated element to correct position on stage | 282 | if(this.parentComponent.parentComponent.isSubproperty){ |
253 | var currentTop = this.tweenedProperties["top"] + "px"; | 283 | // set property specific style on element |
254 | var currentLeft = this.tweenedProperties["left"] + "px"; | 284 | var currentValue = this.tweenedProperties[this.parentComponent.parentComponent.trackEditorProperty]; |
255 | 285 | this.application.ninja.elementMediator.setProperty([this.parentComponent.parentComponent.animatedElement], this.parentComponent.parentComponent.trackEditorProperty, [currentValue], "Change", "tween"); | |
256 | this.application.ninja.elementMediator.setProperty([this.parentComponent.parentComponent.animatedElement], "top", [currentTop], "Change", "tween"); | 286 | } else { |
257 | this.application.ninja.elementMediator.setProperty([this.parentComponent.parentComponent.animatedElement], "left", [currentLeft], "Change", "tween"); | 287 | // move animated element to correct position on stage |
258 | 288 | var currentTop = this.tweenedProperties["top"]; | |
289 | var currentLeft = this.tweenedProperties["left"]; | ||
290 | var currentWidth = this.tweenedProperties["width"]; | ||
291 | var currentHeight = this.tweenedProperties["height"]; | ||
292 | |||
293 | this.application.ninja.elementMediator.setProperty([this.parentComponent.parentComponent.animatedElement], "top", [currentTop], "Change", "tween"); | ||
294 | this.application.ninja.elementMediator.setProperty([this.parentComponent.parentComponent.animatedElement], "left", [currentLeft], "Change", "tween"); | ||
295 | this.application.ninja.elementMediator.setProperty([this.parentComponent.parentComponent.animatedElement], "width", [currentWidth], "Change", "tween"); | ||
296 | this.application.ninja.elementMediator.setProperty([this.parentComponent.parentComponent.animatedElement], "height", [currentHeight], "Change", "tween"); | ||
297 | } | ||
259 | } | 298 | } |
260 | }, | 299 | }, |
261 | 300 | ||
@@ -263,10 +302,8 @@ var Tween = exports.Tween = Montage.create(Component, { | |||
263 | value:function(){ | 302 | value:function(){ |
264 | // turn off event listener for element change | 303 | // turn off event listener for element change |
265 | this.eventManager.removeEventListener("elementChange", this, false); | 304 | this.eventManager.removeEventListener("elementChange", this, false); |
266 | |||
267 | // deselect the keyframe for this tween | 305 | // deselect the keyframe for this tween |
268 | this.keyframe.deselectKeyframe(); | 306 | this.keyframe.deselectKeyframe(); |
269 | } | 307 | } |
270 | } | 308 | } |
271 | |||
272 | }); | 309 | }); |