Skip to content

Commit

Permalink
Merge pull request #4234 from OpenShot/end-drag-outside-timeline
Browse files Browse the repository at this point in the history
listen for mouseleave to end dragging
  • Loading branch information
JacksonRG authored Jul 29, 2021
2 parents 6ba194b + afac763 commit f654a7b
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions src/timeline/js/directives/ruler.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,6 @@ App.directive("tlScrollableTracks", function () {

});

// Initialize panning when middle mouse is clicked
element.on("mousedown", function (e) {
if (e.which === 2) { // middle button
e.preventDefault();
is_scrolling = true;
starting_scrollbar = {x: element.scrollLeft(), y: element.scrollTop()};
starting_mouse_position = {x: e.pageX, y: e.pageY};
element.addClass("drag_cursor");
}
});

// Pans the timeline (on middle mouse clip and drag)
element.on("mousemove", function (e) {
if (is_scrolling) {
Expand Down Expand Up @@ -115,6 +104,24 @@ App.directive("tlBody", function () {
element.on("mouseup", function (e) {
if (e.which === 2) { // middle button
is_scrolling = false;
element.removeClass("drag_cursor");
}
});

// Stop scrolling if mouse leaves timeline
element.on("mouseleave", function (e) {
is_scrolling = false;
element.removeClass("drag_cursor");
})

// Initialize panning when middle mouse is clicked
element.on("mousedown", function (e) {
if (e.which === 2) { // middle button
e.preventDefault();
is_scrolling = true;
starting_scrollbar = {x: element.scrollLeft(), y: element.scrollTop()};
starting_mouse_position = {x: e.pageX, y: e.pageY};
element.addClass("drag_cursor");
}
});

Expand Down

0 comments on commit f654a7b

Please sign in to comment.