Skip to content

Commit 9296c19

Browse files
committed
timeline: Eliminate playheadOffset
- By styling the playhead_top div with `margin-left: -12px` and adjusting the position of the other playhead components accordingly, the need for a `playheadOffset` scope variable can be completely eliminated. All of its positioning code becomes slightly simpler.
1 parent 7a9ba71 commit 9296c19

File tree

5 files changed

+9
-14
lines changed

5 files changed

+9
-14
lines changed

src/timeline/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<!-- RULER (right of screen) -->
4545
<div id="scrolling_ruler">
4646
<!-- PLAYHEAD TOP -->
47-
<div tl-playhead class="playhead playhead-top" ng-right-click="showPlayheadMenu(project.playhead_position)" style="left:{{(project.playhead_position * pixelsPerSecond) + playheadOffset}}px;">
47+
<div tl-playhead class="playhead playhead-top" ng-right-click="showPlayheadMenu(project.playhead_position)" style="left:{{project.playhead_position * pixelsPerSecond}}px;">
4848
<div class="playhead-line-small"></div>
4949
</div>
5050
<!-- Ruler extends beyond tracks area at least for a width of vertical scroll bar (or more, like 50px here) -->
@@ -122,7 +122,7 @@
122122
</div>
123123

124124
<!-- FLOATING PLAYHEAD LINE -->
125-
<div class="playhead playhead-line" style="height: {{ playhead_height }}px; left:{{(project.playhead_position * pixelsPerSecond) + playheadOffset}}px;"></div>
125+
<div class="playhead playhead-line" style="height: {{ playhead_height }}px; left:{{project.playhead_position * pixelsPerSecond}}px;"></div>
126126

127127
<!-- SNAPPING HINT LINE -->
128128
<div ng-show="snapline" class="snapping-line" style="height: {{ playhead_height }}px; left:{{ snapline_position}}px;"></div>
@@ -140,7 +140,7 @@
140140
</div>
141141

142142
<div ng-show="debug" class="debug-window ui-corner-all">
143-
<div class="debug-text ui-corner-all" style="width: 20%;">PROJECT DATA: <pre>pixels per second: {{pixelsPerSecond}} <br> playhead offset: {{playheadOffset}} <br> {{project | json}}</pre></div>
143+
<div class="debug-text ui-corner-all" style="width: 20%;">PROJECT DATA: <pre>pixels per second: {{pixelsPerSecond}}<br> {{project | json}}</pre></div>
144144
<div class="debug-text ui-corner-all" style="width: 70%;">ACTIONS:<br><br>
145145
<div>
146146
<p>Add Clips:</p>

src/timeline/js/controllers.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ App.controller("TimelineCtrl", function ($scope) {
5656

5757
// Additional variables used to control the rendering of HTML
5858
$scope.pixelsPerSecond = parseFloat($scope.project.tick_pixels) / parseFloat($scope.project.scale);
59-
$scope.playheadOffset = 0;
6059
$scope.playhead_animating = false;
6160
$scope.playhead_height = 300;
6261
$scope.playheadTime = secondsToTime($scope.project.playhead_position, $scope.project.fps.num, $scope.project.fps.den);
@@ -93,8 +92,8 @@ App.controller("TimelineCtrl", function ($scope) {
9392
$scope.playheadTime = secondsToTime(position_seconds, $scope.project.fps.num, $scope.project.fps.den);
9493

9594
// Use JQuery to move playhead (for performance reasons) - scope.apply is too expensive here
96-
$(".playhead-top").css("left", (($scope.project.playhead_position * $scope.pixelsPerSecond) + $scope.playheadOffset) + "px");
97-
$(".playhead-line").css("left", (($scope.project.playhead_position * $scope.pixelsPerSecond) + $scope.playheadOffset) + "px");
95+
$(".playhead-top").css("left", ($scope.project.playhead_position * $scope.pixelsPerSecond) + "px");
96+
$(".playhead-line").css("left", ($scope.project.playhead_position * $scope.pixelsPerSecond) + "px");
9897
$("#ruler_time").text($scope.playheadTime.hour + ":" + $scope.playheadTime.min + ":" + $scope.playheadTime.sec + ":" + $scope.playheadTime.frame);
9998
};
10099

src/timeline/js/directives/playhead.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ App.directive("tlPlayhead", function () {
3737
// get the default top position so we can lock it in place vertically
3838
playhead_y_max = element.position().top;
3939

40-
// get the size of the playhead and line so we can determine the offset
41-
var playhead_top_w = parseInt($(".playhead-top").css("width"), 10);
42-
scope.playheadOffset = 0.0 - (playhead_top_w / 2.0);
43-
4440
// Move playhead to new position (if it's not currently being animated)
4541
element.on("mousemove", function (e) {
4642
if (e.which === 1 && !scope.playhead_animating) { // left button

src/timeline/js/directives/ruler.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ App.directive("tlRuler", function ($timeout) {
121121

122122
// Animate to new position (and then update scope)
123123
scope.playhead_animating = true;
124-
$(".playhead-line").animate({left: playhead_left + scope.playheadOffset}, 200);
125-
$(".playhead-top").animate({left: playhead_left + scope.playheadOffset}, 200, function () {
124+
$(".playhead-line").animate({left: playhead_left}, 200);
125+
$(".playhead-top").animate({left: playhead_left}, 200, function () {
126126
// Update playhead
127127
scope.movePlayhead(playhead_seconds);
128128

src/timeline/media/css/main.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ img {
6363
.track { height: 64px; background-color: #000; margin-bottom: 8px; background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(50,50,50,1)), color-stop(100%,rgba(6,6,6,1))); border-top: 1px solid #4b92ad; border-bottom: 1px solid #4b92ad; border-right: 1px solid #4B92AD; border-top-right-radius: 8px; border-bottom-right-radius: 8px; box-shadow: 0px 0px 10px #000; }
6464

6565
/* Playhead */
66-
.playhead-line { z-index: 9998; position: absolute; height:316px; top:0px; margin-left: 12px; width:1px; background-color:#ff0024; opacity:1;}
66+
.playhead-line { z-index: 9998; position: absolute; height:316px; top:0px; width:1px; background-color:#ff0024; opacity:1;}
6767
.playhead-line-small { z-index: 9999; position: absolute; height:20px; top:32px;; margin-left: 12px; width:1px; background-color:#ff0024; opacity:1;}
68-
.playhead-top { cursor:move; z-index: 9999; position: absolute; margin-left: 0px; margin-top: 12px; width:25px; height:32px; background-image: url(../images/play_head.png); opacity:1;}
68+
.playhead-top { cursor:move; z-index: 9999; position: absolute; margin-left: -12px; margin-top: 12px; width:25px; height:32px; background-image: url(../images/play_head.png); opacity:1;}
6969
.marker {position:absolute; top:30px;}
7070

7171
/* Clips */

0 commit comments

Comments
 (0)