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 - Fixed: disabled `Ctrl+L` quick key to go to a line, instead use the default
browser behavior of selecting the address bar. browser behavior of selecting the address bar.
- Fixed #38: clear search results after a new JSON object is set. - 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 ## 2015-06-13, version 4.2.1

View File

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