@@ -160,63 +160,36 @@ App.directive("tlRuler", function ($timeout) {
160
160
}
161
161
} ) ;
162
162
163
- drawTicks = ( ) => {
164
- /* Remove all divs in ruler and readraw along the full length
165
- * Only needed when timeline length changes.
166
- */
167
-
168
- ruler = $ ( "#ruler" ) ;
169
- $ ( '#ruler div' ) . remove ( ) ;
170
- width = ruler . width ( ) ;
171
- for ( var x = 0 ; x < width ; x += 50 ) {
172
- d = $ ( '<div>' ) ;
173
- d . addClass ( 'on_ruler' ) ;
174
- d . addClass ( ( x % 100 == 0 ) ? 'ruler_tick_long' : 'ruler_tick' ) ;
175
- d [ 0 ] . style = "left: " + x + 'px;' ;
176
- console . log ( d [ 0 ] ) ;
177
- ruler . append ( d ) ;
178
- }
179
- }
180
-
181
163
drawTimes = ( ) => {
182
164
console . log ( scope . scrollLeft ) ;
183
165
ruler = $ ( "#ruler" ) ;
184
166
width = $ ( "body" ) . width ( ) ;
185
167
$ ( "#ruler span" ) . remove ( ) ;
186
- start = Math . max ( scope . scrollLeft - width , 0 ) ;
168
+ start = Math . max ( scope . scrollLeft - width , 100 ) ;
187
169
end = Math . min ( scope . scrollLeft + ( 2 * width ) , $ ( '#ruler' ) . width ( ) ) ;
170
+
171
+ scale = scope . project . scale ;
188
172
for ( var i = start - ( start % 50 ) ; i < end ; i += 100 ) {
173
+ /* create and format span */
189
174
s = $ ( '<span>' ) ;
190
175
s . addClass ( "tick_time" ) ;
191
- s [ 0 ] . innerText = "00:00" ;
192
176
s [ 0 ] . style = "left: " + i + "px;" ;
177
+
178
+ /* Calculate Time */
179
+ var time = i / scope . pixelsPerSecond ;
180
+ var text_time = secondsToTime ( time , scope . project . fps . num , scope . project . fps . den ) ;
181
+ s [ 0 ] . innerText = text_time [ "hour" ] + ":" + text_time [ "min" ] + ":" + text_time [ "sec" ] ;
182
+
193
183
ruler . append ( s ) ;
194
184
}
195
185
}
196
186
197
- //watch the scale value so it will be able to draw the ruler after changes,
198
- //otherwise the canvas is just reset to blank
199
- scope . $watch ( "project.scale + project.duration" , function ( val ) {
200
- if ( val ) {
201
- $timeout ( function ( ) {
202
- $ ( '#ruler' ) . scrollLeft = $ ( '#scrolling_tracks' ) . scrollLeft ;
203
- drawTimes ( ) ;
204
- return ;
205
- }
206
- , 0 ) ;
207
- }
208
- } ) ;
209
-
210
- scope . $watch ( "scrollLeft" , function ( val ) {
187
+ scope . $watch ( "project.scale + markers.length + project.duration + scrollLeft" , function ( val ) {
211
188
if ( val ) {
212
189
$timeout ( function ( ) {
213
- // $('#ruler').scrollLeft = $('#scrolling_tracks').scrollLeft;
214
190
drawTimes ( ) ;
215
- //reposition the spans at every visible multiple of 50 pixels
216
- //Plus a screen width before and after for scrolling
217
191
return ;
218
- }
219
- , 0 ) ;
192
+ } , 0 ) ;
220
193
}
221
194
} ) ;
222
195
0 commit comments