Skip to content

Commit afac763

Browse files
committed
listen for mouseleave to end dragging
1 parent d755af2 commit afac763

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

src/timeline/js/directives/ruler.js

+18-11
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,6 @@ App.directive("tlScrollableTracks", function () {
7171

7272
});
7373

74-
// Initialize panning when middle mouse is clicked
75-
element.on("mousedown", function (e) {
76-
if (e.which === 2) { // middle button
77-
e.preventDefault();
78-
is_scrolling = true;
79-
starting_scrollbar = {x: element.scrollLeft(), y: element.scrollTop()};
80-
starting_mouse_position = {x: e.pageX, y: e.pageY};
81-
element.addClass("drag_cursor");
82-
}
83-
});
84-
8574
// Pans the timeline (on middle mouse clip and drag)
8675
element.on("mousemove", function (e) {
8776
if (is_scrolling) {
@@ -112,6 +101,24 @@ App.directive("tlBody", function () {
112101
element.on("mouseup", function (e) {
113102
if (e.which === 2) { // middle button
114103
is_scrolling = false;
104+
element.removeClass("drag_cursor");
105+
}
106+
});
107+
108+
// Stop scrolling if mouse leaves timeline
109+
element.on("mouseleave", function (e) {
110+
is_scrolling = false;
111+
element.removeClass("drag_cursor");
112+
})
113+
114+
// Initialize panning when middle mouse is clicked
115+
element.on("mousedown", function (e) {
116+
if (e.which === 2) { // middle button
117+
e.preventDefault();
118+
is_scrolling = true;
119+
starting_scrollbar = {x: element.scrollLeft(), y: element.scrollTop()};
120+
starting_mouse_position = {x: e.pageX, y: e.pageY};
121+
element.addClass("drag_cursor");
115122
}
116123
});
117124

0 commit comments

Comments
 (0)