Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

listen for mouseleave to end dragging #4234

Merged
merged 1 commit into from
Jul 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions src/timeline/js/directives/ruler.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,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 @@ -112,6 +101,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");
})
Comment on lines +108 to +112

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New function looks good


// 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