Skip to content

Commit 2953274

Browse files
JacksonJacksonRG
Jackson
authored andcommitted
Cleaned up leftover code for PR
1 parent b3a5c0c commit 2953274

File tree

3 files changed

+14
-62
lines changed

3 files changed

+14
-62
lines changed

src/timeline/index.html

+1-2
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,11 @@
5050
<div tl-playhead class="playhead playhead-top" ng-right-click="showPlayheadMenu(project.playhead_position)" style="left:{{project.playhead_position * pixelsPerSecond}}px;">
5151
<div class="playhead-line-small"></div>
5252
</div>
53-
<!-- Ruler extends beyond tracks area at least for a width of vertical scroll bar (or more, like 50px here) -->
53+
<!-- Ruler is width of the timeline -->
5454
<div tl-ruler id="ruler" style="width: {{project.duration * pixelsPerSecond}}px;">
5555
</div>
5656

5757
<!-- MARKERS -->
58-
5958
<span class="ruler_marker" id="marker_for_{{marker.id}}">
6059
<img ng-repeat="marker in project.markers" id="marker_{{marker.id}}_{{$index}}" ng-right-click="showMarkerMenu(marker.id)" style="position: absolute; bottom: 0px; left: {{(marker.position * pixelsPerSecond) - 6 }}px;" class="marker_icon" ng-src="media/images/markers/{{ marker.icon }}" draggable="false"/>
6160
</span>

src/timeline/js/directives/ruler.js

+12-39
Original file line numberDiff line numberDiff line change
@@ -160,63 +160,36 @@ App.directive("tlRuler", function ($timeout) {
160160
}
161161
});
162162

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-
181163
drawTimes = () => {
182164
console.log(scope.scrollLeft);
183165
ruler = $("#ruler");
184166
width = $("body").width();
185167
$("#ruler span").remove();
186-
start = Math.max(scope.scrollLeft - width, 0);
168+
start = Math.max(scope.scrollLeft - width, 100);
187169
end = Math.min(scope.scrollLeft + (2*width), $('#ruler').width());
170+
171+
scale = scope.project.scale;
188172
for (var i = start - (start % 50) ; i < end; i += 100) {
173+
/* create and format span */
189174
s = $('<span>');
190175
s.addClass("tick_time");
191-
s[0].innerText= "00:00";
192176
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+
193183
ruler.append(s);
194184
}
195185
}
196186

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) {
211188
if (val) {
212189
$timeout(function () {
213-
// $('#ruler').scrollLeft = $('#scrolling_tracks').scrollLeft;
214190
drawTimes();
215-
//reposition the spans at every visible multiple of 50 pixels
216-
//Plus a screen width before and after for scrolling
217191
return;
218-
}
219-
, 0);
192+
} , 0);
220193
}
221194
});
222195

src/timeline/media/css/main.css

+1-21
Original file line numberDiff line numberDiff line change
@@ -53,27 +53,7 @@ img {
5353
position: relative;
5454
height: 100%;
5555
background-image: url(../images/ruler-tick.svg);
56-
}
57-
.on_ruler{
58-
position: absolute;
59-
color: white;
60-
font-size: 0.8em;
61-
}
62-
.ruler_tick_long {
63-
background-color: white;
64-
width: 5px;
65-
height: 20px;
66-
bottom: 0px;
67-
position: absolute;
68-
border-radius: 2px;
69-
}
70-
.ruler_tick {
71-
background-color: white;
72-
width: 5px;
73-
height: 10px;
74-
bottom: 0px;
75-
position: absolute;
76-
border-radius: 2px;
56+
background-position: -50px;
7757
}
7858
.tick_time {
7959
color: white;

0 commit comments

Comments
 (0)