OpenShot Video Editor  2.0.0
playhead.js
Go to the documentation of this file.
1 /**
2  * @file
3  * @brief Playhead directives (dragging functionality, etc...)
4  * @author Jonathan Thomas <jonathan@openshot.org>
5  * @author Cody Parker <cody@yourcodepro.com>
6  *
7  * @section LICENSE
8  *
9  * Copyright (c) 2008-2014 OpenShot Studios, LLC
10  * <http://www.openshotstudios.com/>. This file is part of
11  * OpenShot Video Editor, an open-source project dedicated to
12  * delivering high quality video editing and animation solutions to the
13  * world. For more information visit <http://www.openshot.org/>.
14  *
15  * OpenShot Video Editor is free software: you can redistribute it
16  * and/or modify it under the terms of the GNU General Public License
17  * as published by the Free Software Foundation, either version 3 of the
18  * License, or (at your option) any later version.
19  *
20  * OpenShot Video Editor is distributed in the hope that it will be
21  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
27  */
28 
29 
30 // Handles the playhead dragging
31 var playhead_y_max = null;
32 var playhead_x_min = null;
33 
34 App.directive('tlPlayhead', function(){
35  return {
36  link: function(scope, element, attrs) {
37  // get the default top position so we can lock it in place vertically
38  playhead_y_max = element.position().top;
39 
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")) - 8.0; // I'm not sure why I need to remove another 8 pixels here
42  scope.playheadOffset = 0.0 - (playhead_top_w / 2.0);
43 
44  // Move playhead to new position (if it's not currently being animated)
45  element.on('mousemove', function(e){
46  if (e.which == 1 && !scope.playhead_animating) { // left button
47  var playhead_seconds = (e.pageX - $("#ruler").offset().left) / scope.pixelsPerSecond;
48  scope.MovePlayhead(playhead_seconds);
49  scope.PreviewFrame(playhead_seconds);
50  }
51  });
52 
53  }
54  };
55 });
56 
57 
var playhead_y_max
Definition: playhead.js:31
var playhead_x_min
Definition: playhead.js:32
var App
Definition: app.js:31
var a[b] e