Fixed #242: row stays highlighted when dragging outside editor

This commit is contained in:
jos 2015-12-28 12:41:12 +01:00
parent 4d91d26695
commit 862aa388c7
2 changed files with 14 additions and 11 deletions

View File

@ -26,6 +26,7 @@ https://github.com/josdejong/jsoneditor
- Fixed: disabled `Ctrl+L` quick key to go to a line, instead use the default
browser behavior of selecting the address bar.
- Fixed #38: clear search results after a new JSON object is set.
- Fixed #242: row stays highlighted when dragging outside editor.
## 2015-06-13, version 4.2.1

View File

@ -1214,17 +1214,15 @@ Node.prototype.getDom = function() {
Node.prototype._onDragStart = function (event) {
var node = this;
if (!this.mousemove) {
this.mousemove = util.addEventListener(document, 'mousemove',
function (event) {
node._onDrag(event);
});
this.mousemove = util.addEventListener(window, 'mousemove', function (event) {
node._onDrag(event);
});
}
if (!this.mouseup) {
this.mouseup = util.addEventListener(document, 'mouseup',
function (event ) {
node._onDragEnd(event);
});
this.mouseup = util.addEventListener(window, 'mouseup',function (event ) {
node._onDragEnd(event);
});
}
this.editor.highlighter.lock();
@ -1403,13 +1401,17 @@ Node.prototype._onDragEnd = function (event) {
document.body.style.cursor = this.drag.oldCursor;
this.editor.highlighter.unlock();
if (event.target !== this.dom.drag && event.target !== this.dom.menu) {
this.editor.highlighter.unhighlight();
}
delete this.drag;
if (this.mousemove) {
util.removeEventListener(document, 'mousemove', this.mousemove);
delete this.mousemove;}
util.removeEventListener(window, 'mousemove', this.mousemove);
delete this.mousemove;
}
if (this.mouseup) {
util.removeEventListener(document, 'mouseup', this.mouseup);
util.removeEventListener(window, 'mouseup', this.mouseup);
delete this.mouseup;
}