Skip to content

Commit b3a5c0c

Browse files
JacksonJacksonRG
Jackson
authored andcommitted
Coppied changes from playhead-bug branch
1 parent 0674d97 commit b3a5c0c

File tree

3 files changed

+73
-24
lines changed

3 files changed

+73
-24
lines changed

src/timeline/index.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@
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 is width of the timeline -->
53+
<!-- Ruler extends beyond tracks area at least for a width of vertical scroll bar (or more, like 50px here) -->
5454
<div tl-ruler id="ruler" style="width: {{project.duration * pixelsPerSecond}}px;">
5555
</div>
5656

5757
<!-- MARKERS -->
58+
5859
<span class="ruler_marker" id="marker_for_{{marker.id}}">
5960
<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"/>
6061
</span>

src/timeline/js/directives/ruler.js

+44-15
Original file line numberDiff line numberDiff line change
@@ -160,34 +160,63 @@ 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+
163181
drawTimes = () => {
182+
console.log(scope.scrollLeft);
164183
ruler = $("#ruler");
165184
width = $("body").width();
166185
$("#ruler span").remove();
167-
start = Math.max(scope.scrollLeft - width, 100);
186+
start = Math.max(scope.scrollLeft - width, 0);
168187
end = Math.min(scope.scrollLeft + (2*width), $('#ruler').width());
169-
170-
scale = scope.project.scale;
171-
for (var i = start - (start % 100) ; i < end; i += 100) {
172-
/* create and format span */
173-
s = $('<span style="left: ' + i + 'px;">');
174-
s.addClass("ruler_time");
175-
176-
/* Calculate Time */
177-
var time = i / scope.pixelsPerSecond;
178-
var text_time = secondsToTime(time, scope.project.fps.num, scope.project.fps.den);
179-
s[0].innerText= text_time["hour"] + ":" + text_time["min"] + ":" + text_time["sec"];
180-
188+
for (var i = start - (start % 50) ; i < end; i += 100) {
189+
s = $('<span>');
190+
s.addClass("tick_time");
191+
s[0].innerText= "00:00";
192+
s[0].style = "left: " + i + "px;";
181193
ruler.append(s);
182194
}
183195
}
184196

185-
scope.$watch("project.scale + project.duration + scrollLeft", function (val) {
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) {
186211
if (val) {
187212
$timeout(function () {
213+
// $('#ruler').scrollLeft = $('#scrolling_tracks').scrollLeft;
188214
drawTimes();
215+
//reposition the spans at every visible multiple of 50 pixels
216+
//Plus a screen width before and after for scrolling
189217
return;
190-
} , 0);
218+
}
219+
, 0);
191220
}
192221
});
193222

src/timeline/media/css/main.css

+27-8
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,41 @@ img {
4343
}
4444

4545
/* Ruler */
46-
#scrolling_ruler { overflow: hidden; position: relative; line-height: 4px; height:43px;}
46+
#scrolling_ruler { overflow: hidden; position: relative;line-height: 4px; height:43px;}
4747
#scrolling_tracks { height: 316px; overflow: scroll; position: relative; }
4848
#ruler_label { height: 39px; width: 140px; float: left; margin-bottom: 4px; }
49-
#ruler_time { font-size: 13pt; color: #999; padding-top: 14px; padding-left: 17px; }
50-
#progress{ position: absolute; bottom: 0;}
49+
#ruler_time { font-size: 13pt; color: #c8c8c8; padding-top: 14px; padding-left: 17px; }
50+
#progress_container {margin-left:140px; overflow: hidden; height: 13px;}
5151
.drag_cursor { cursor: move; }
5252
#ruler {
5353
position: relative;
54-
height: 39px;
54+
height: 100%;
5555
background-image: url(../images/ruler-tick.svg);
56-
background-position: -50px;
5756
}
58-
.ruler_time {
59-
color: #c8c8c8;
60-
top: 6px;
57+
.on_ruler{
58+
position: absolute;
59+
color: white;
6160
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;
77+
}
78+
.tick_time {
79+
color: white;
80+
top: 5px;
6281
position: absolute;
6382
transform: translate(-50%,0);
6483
}

0 commit comments

Comments
 (0)