aboutsummaryrefslogtreecommitdiff
path: root/js/panels/Timeline/PropertyTrack.reel/PropertyTrack.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/panels/Timeline/PropertyTrack.reel/PropertyTrack.js')
-rw-r--r--js/panels/Timeline/PropertyTrack.reel/PropertyTrack.js208
1 files changed, 208 insertions, 0 deletions
diff --git a/js/panels/Timeline/PropertyTrack.reel/PropertyTrack.js b/js/panels/Timeline/PropertyTrack.reel/PropertyTrack.js
index 175b77f9..f2dbd683 100644
--- a/js/panels/Timeline/PropertyTrack.reel/PropertyTrack.js
+++ b/js/panels/Timeline/PropertyTrack.reel/PropertyTrack.js
@@ -15,7 +15,215 @@ var PropertyTrack = exports.PropertyTrack = Montage.create(Component, {
15 15
16 prepareForDraw:{ 16 prepareForDraw:{
17 value:function(){ 17 value:function(){
18 this.element.addEventListener("click", this, false);
19 this.trackID = this.parentComponent.parentComponent.parentComponent.trackID;
20 this.animatedElement = this.parentComponent.parentComponent.parentComponent.animatedElement;
21 }
22 },
23
24 draw:{
25 value:function(){
26
27 }
28 },
29
30 trackEditorProperty:{
31 value:""
32 },
33
34 _propTweenRepetition:{
35 value:null
36 },
37
38 animatedElement:{
39 value:null
40 },
41
42 isSubproperty:{
43 value:true
44 },
45
46 propTweenRepetition:{
47 serializable:true,
48 get:function () {
49 return this._propTweenRepetition;
50 },
51 set:function (newVal) {
52 this._propTweenRepetition = newVal;
53 }
54 },
55
56 _propTweens:{
57 value:[]
58 },
59
60 propTweens:{
61 serializable:true,
62 get:function () {
63 return this._propTweens;
64 },
65 set:function (newVal) {
66 this._propTweens = newVal;
67 }
68 },
69
70 _propTrackData:{
71 value:false
72 },
73
74 propTrackData:{
75 serializable:true,
76 get:function () {
77 return this._propTrackData;
78 },
79 set:function (val) {
80 this._propTrackData = val;
81 if (this._propTrackData) {
82 this.setData();
83 }
84 }
85 },
86
87 nextKeyframe:{
88 value:1
89 },
90
91 _trackID:{
92 value:null
93 },
94
95 trackID:{
96 serializable:true,
97 get:function () {
98 return this._trackID;
99 },
100 set:function (value) {
101 if (value !== this._trackID) {
102 this._trackID = value;
103 }
104 }
105 },
106
107 _styleSelection:{
108 value:null
109 },
110
111 styleSelection:{
112 serializable:true,
113 get:function () {
114 return this._styleSelection;
115 },
116 set:function (value) {
117 if (value !== this._styleSelection) {
118 this._styleSelection = value;
119 }
120 }
121 },
122
123 _styleIndex:{
124 value:null
125 },
126
127 styleIndex:{
128 serializable:true,
129 get:function () {
130 return this._styleIndex;
131 },
132 set:function (value) {
133 if (value !== this._styleIndex) {
134 this._styleIndex = value;
135 }
136 }
137 },
138
139 setData:{
140 value:function () {
141 if (typeof(this.propTrackData) === "undefined") {
142 return;
143 }
144
145 this.styleIndex = this.propTrackData.styleIndex;
146 this.propTweens = this.propTrackData.propTweens;
147 this.styleSelection = this.propTrackData.styleSelection;
148 this.needsDraw = true;
149 }
150 },
151
152 handleClick:{
153 value:function(ev){
154 if (ev.shiftKey) {
155 if (this.propTweens.length < 1) {
156
157 // check if there is an editor property assigned yet
158 // get this property track's editor prop name from layer data arrays
159 var selectIndex = this.application.ninja.timeline.getLayerIndexByID(this.trackID);
160 console.log(this.application.ninja.timeline.arrLayers[selectIndex].layerData.arrLayerStyles);
161 console.log(this.styleIndex);
162
163 this.insertPropTween(0);
164 this.addPropAnimationRuleToElement(ev);
165 this.updatePropKeyframeRule();
166 } else {
167 this.handleNewPropTween(ev);
168 this.updatePropKeyframeRule();
169 }
170 }
171 }
172 },
173
174 handleNewPropTween:{
175 value:function(ev){
176 this.insertPropTween(ev.offsetX);
177 }
178 },
179
180 insertPropTween:{
181 value:function(clickPos){
182 var selectedIndex = this.application.ninja.timeline.getLayerIndexByID(this.trackID);
183 this.application.ninja.timeline.selectLayer(selectedIndex, true);
184
185 var currentMillisecPerPixel = Math.floor(this.application.ninja.timeline.millisecondsOffset / 80);
186 var currentMillisec = currentMillisecPerPixel * clickPos;
187
188 var newTween = {};
189 newTween.tweenData = {};
190
191 if (clickPos == 0) {
192 newTween.tweenData.spanWidth = 0;
193 newTween.tweenData.keyFramePosition = 0;
194 newTween.tweenData.keyFrameMillisec = 0;
195 newTween.tweenData.tweenID = 0;
196 newTween.tweenData.spanPosition = 0;
197 newTween.tweenData.tweenedProperties = [];
198
199 this.propTweens.push(newTween);
200
201 } else {
202 newTween.tweenData.spanWidth = clickPos - this.propTweens[this.propTweens.length - 1].tweenData.keyFramePosition;
203 newTween.tweenData.keyFramePosition = clickPos;
204 newTween.tweenData.keyFrameMillisec = currentMillisec;
205 newTween.tweenData.tweenID = this.nextKeyframe;
206 newTween.tweenData.spanPosition = clickPos - newTween.tweenData.spanWidth;
207 newTween.tweenData.tweenedProperties = [];
208
209 this.propTweens.push(newTween);
210
211 this.nextKeyframe += 1;
212 }
213
214 this.application.ninja.documentController.activeDocument.needsSave = true;
215 }
216 },
217
218 updatePropKeyframeRule:{
219 value:function(){
220
221 }
222 },
18 223
224 addPropAnimationRuleToElement:{
225 value:function(tweenEvent){
226 this.insertPropTween(tweenEvent.offsetX);
19 } 227 }
20 } 228 }
21}); 229});