diff --git a/addon/scroll/simplescrollbars.js b/addon/scroll/simplescrollbars.js index 739aa7beb4c8fba61ae6d1380df7df14232ce978..bb06adb86a11a8f29f640d9e637e36dd5ee1c5c1 100644 --- a/addon/scroll/simplescrollbars.js +++ b/addon/scroll/simplescrollbars.js @@ -27,14 +27,16 @@ CodeMirror.e_preventDefault(e); var axis = self.orientation == "horizontal" ? "pageX" : "pageY"; var start = e[axis], startpos = self.pos; + function done() { + CodeMirror.off(document, "mousemove", move); + CodeMirror.off(document, "mouseup", done); + } function move(e) { - if (e.which != 1) { - CodeMirror.off(document, "mousemove", move); - return; - } + if (e.which != 1) return done(); self.moveTo(startpos + (e[axis] - start) * (self.total / self.size)); } CodeMirror.on(document, "mousemove", move); + CodeMirror.on(document, "mouseup", done); }); CodeMirror.on(this.node, "click", function(e) {