Skip to content

Commit f7051c9

Browse files
committed
Remove Droppable Track from Angular timeline code. Replace with static function called on Draggable End (to update UI data). Allows for clips to be dragged to edge of timeline without resetting back to original positions. Also fixed a race condition (on Web Engine) that caused a ng-click to happen after a drag (randomly) clearing selections.
1 parent e707721 commit f7051c9

File tree

6 files changed

+143
-226
lines changed

6 files changed

+143
-226
lines changed

src/timeline/index.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<script type="text/javascript" src="js/controllers.js"></script>
2727
<script type="text/javascript" src="js/directives/ruler.js"></script>
2828
<script type="text/javascript" src="js/directives/playhead.js"></script>
29-
<script type="text/javascript" src="js/directives/track.js"></script>
3029
<script type="text/javascript" src="js/directives/clip.js"></script>
3130
<script type="text/javascript" src="js/directives/transition.js"></script>
3231
<script type="text/javascript" src="js/directives/misc.js"></script>
@@ -78,7 +77,7 @@
7877
</div>
7978
<!-- TRACKS CONTAINER (right of screen) -->
8079
<div tl-scrollable-tracks id="scrolling_tracks">
81-
<div id="track-container" tl-track tl-multi-selectable style="width: {{getTimelineWidth(0) - 6}}px; padding-bottom: 2px;">
80+
<div id="track-container" tl-multi-selectable style="width: {{getTimelineWidth(0) - 6}}px; padding-bottom: 2px;">
8281
<!-- TRACKS -->
8382
<div ng-repeat="layer in project.layers.slice().reverse()" id="track_{{layer.number}}" ng-right-click="showTimelineMenu($event, layer.number)" class="{{getTrackStyle(layer.lock)}}" style="width:{{getTimelineWidth(0) - 6}}px;">
8483
<div class="banding-overlay"></div>

src/timeline/js/controllers.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -400,12 +400,6 @@ App.controller("TimelineCtrl", function ($scope) {
400400
$scope.setSnappingMode = function (enable_snapping) {
401401
$scope.$apply(function () {
402402
$scope.enable_snapping = enable_snapping;
403-
if (enable_snapping) {
404-
$(".droppable").draggable("option", "snapTolerance", 20);
405-
}
406-
else {
407-
$(".droppable").draggable("option", "snapTolerance", 0);
408-
}
409403
});
410404
};
411405

@@ -580,6 +574,11 @@ App.controller("TimelineCtrl", function ($scope) {
580574

581575
// Select item (either clip or transition)
582576
$scope.selectItem = function (item_id, item_type, clear_selections, event, force_ripple) {
577+
if ($scope.dragging) {
578+
timeline.qt_log("DEBUG", "Skip selection due to dragging...");
579+
return;
580+
}
581+
583582
// Trim item_id
584583
var id = item_id.replace(`${item_type}_`, "");
585584

src/timeline/js/directives/clip.js

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*/
2828

2929

30-
/*global setSelections, setBoundingBox, moveBoundingBox, bounding_box, drawAudio */
30+
/*global setSelections, setBoundingBox, moveBoundingBox, bounding_box, drawAudio, updateDraggables */
3131
// Init variables
3232
var dragging = false;
3333
var resize_disabled = false;
@@ -323,9 +323,11 @@ App.directive("tlClip", function ($timeout) {
323323
// Hide snapline (if any)
324324
scope.hideSnapline();
325325

326+
// Call the shared function for drag stop
327+
updateDraggables(scope, ui, 'clip');
328+
326329
// Clear previous drag position
327330
previous_drag_position = null;
328-
scope.setDragging(false);
329331
},
330332
drag: function (e, ui) {
331333
// Retrieve the initial cursor offset
@@ -368,18 +370,6 @@ App.directive("tlClip", function ($timeout) {
368370
$(this).css("top", newY);
369371
}
370372
});
371-
},
372-
revert: function (valid) {
373-
if (!valid) {
374-
//the drop spot was invalid, so we're going to move all clips to their original position
375-
$(".ui-selected").each(function () {
376-
var oldY = start_clips[$(this).attr("id")]["top"];
377-
var oldX = start_clips[$(this).attr("id")]["left"];
378-
379-
$(this).css("left", oldX);
380-
$(this).css("top", oldY);
381-
});
382-
}
383373
}
384374
});
385375
}

src/timeline/js/directives/track.js

Lines changed: 0 additions & 189 deletions
This file was deleted.

src/timeline/js/directives/transition.js

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*/
2828

2929

30-
/*global setSelections, setBoundingBox, moveBoundingBox, bounding_box */
30+
/*global setSelections, setBoundingBox, moveBoundingBox, bounding_box, updateDraggables */
3131
// Init Variables
3232
var resize_disabled = false;
3333
var previous_drag_position = null;
@@ -266,10 +266,11 @@ App.directive("tlTransition", function () {
266266
// Hide snapline (if any)
267267
scope.hideSnapline();
268268

269+
// Call the shared function for drag stop
270+
updateDraggables(scope, ui, 'transition');
271+
269272
// Clear previous drag position
270273
previous_drag_position = null;
271-
scope.setDragging(false);
272-
273274
},
274275
drag: function (e, ui) {
275276
// Retrieve the initial cursor offset
@@ -313,18 +314,6 @@ App.directive("tlTransition", function () {
313314
}
314315
});
315316

316-
},
317-
revert: function (valid) {
318-
if (!valid) {
319-
// The drop spot was invalid, so we're going to move all transitions to their original position
320-
$(".ui-selected").each(function () {
321-
var oldY = start_transitions[$(this).attr("id")]["top"];
322-
var oldX = start_transitions[$(this).attr("id")]["left"];
323-
324-
$(this).css("left", oldX);
325-
$(this).css("top", oldY);
326-
});
327-
}
328317
}
329318
});
330319

0 commit comments

Comments
 (0)