Skip to content

Commit

Permalink
Merge pull request #4230 from OpenShot/move-clips-exception
Browse files Browse the repository at this point in the history
Add default case form move_clips
  • Loading branch information
JacksonRG authored Aug 11, 2021
2 parents 81bca85 + ae16ed9 commit 6893278
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
12 changes: 10 additions & 2 deletions src/timeline/js/directives/clip.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,16 @@ App.directive("tlClip", function ($timeout) {

// Move all other selected clips with this one if we have more than one clip
$(".ui-selected").each(function () {
var newY = move_clips[$(this).attr("id")]["top"] + y_offset;
var newX = move_clips[$(this).attr("id")]["left"] + x_offset;
clip_name = $(this).attr("id");
var newX, newY;
if (move_clips[clip_name] && ( move_clips[clip_name]['top'] && move_clips[clip_name]['left'] )) {
newY = move_clips[clip_name]['top'] + y_offset;
newX = move_clips[clip_name]['left'] + x_offset;
} else {
move_clips[clip_name] = {};
newY = this.style.top + y_offset;
newX = this.style.left + x_offset;
}
//update the clip location in the array
move_clips[$(this).attr("id")]["top"] = newY;
move_clips[$(this).attr("id")]["left"] = newX;
Expand Down
21 changes: 14 additions & 7 deletions src/timeline/js/directives/transition.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,21 @@ App.directive("tlTransition", function () {

// Move all other selected transitions with this one
$(".ui-selected").each(function () {
var newY = move_transitions[$(this).attr("id")]["top"] + y_offset;
var newX = move_transitions[$(this).attr("id")]["left"] + x_offset;

//update the transition location in the array
transition_name = $(this).attr("id");
var newX, newY;
if (move_clips[transition_name] && ( move_clips[transition_name]['top'] && move_clips[clip_name]['left'] )) {
newY = move_clips[transition_name]['top'] + y_offset;
newX = move_clips[transition_name]['left'] + x_offset;
} else {
// If this transition is not yet in move_clips, add it.
move_clips[transition_name] = {};
newY = this.style.top + y_offset;
newX = this.style.left + x_offset;
}
// Update the transition location in the array
move_transitions[$(this).attr("id")]["top"] = newY;
move_transitions[$(this).attr("id")]["left"] = newX;

//change the element location
// Change the element location
$(this).css("left", newX);
$(this).css("top", newY);

Expand All @@ -294,7 +301,7 @@ App.directive("tlTransition", function () {
},
revert: function (valid) {
if (!valid) {
//the drop spot was invalid, so we're going to move all transitions to their original position
// The drop spot was invalid, so we're going to move all transitions to their original position
$(".ui-selected").each(function () {
var oldY = start_transitions[$(this).attr("id")]["top"];
var oldX = start_transitions[$(this).attr("id")]["left"];
Expand Down

0 comments on commit 6893278

Please sign in to comment.