ome drag&drop fixes

This commit is contained in:
Anton Lavrenov 2018-07-03 11:03:06 +07:00
parent 1c863ae389
commit e518e64935
7 changed files with 50 additions and 27 deletions

View File

@ -5,6 +5,12 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## [new version][unreleased] ## [new version][unreleased]
## [2.1.7][2018-07-03]
## Fixed
* Some drag&drop fixes
## [2.1.6][2018-06-16] ## [2.1.6][2018-06-16]
## Fixed ## Fixed

View File

@ -2,7 +2,7 @@
* Konva JavaScript Framework v2.1.6 * Konva JavaScript Framework v2.1.6
* http://konvajs.github.io/ * http://konvajs.github.io/
* Licensed under the MIT * Licensed under the MIT
* Date: Wed Jun 20 2018 * Date: Tue Jul 03 2018
* *
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS) * Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
* Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva) * Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
@ -2970,7 +2970,7 @@
}); });
}, },
/** /**
* remove self from parent, but don't destroy * remove self from parent, but don't destroy. You can reuse node later.
* @method * @method
* @memberof Konva.Node.prototype * @memberof Konva.Node.prototype
* @returns {Konva.Node} * @returns {Konva.Node}
@ -2997,7 +2997,7 @@
return this; return this;
}, },
/** /**
* remove and destroy self * remove and destroy a node. Kill it forever! You should not reuse node after destroy().
* @method * @method
* @memberof Konva.Node.prototype * @memberof Konva.Node.prototype
* @example * @example
@ -10632,9 +10632,12 @@
// always call preventDefault for desktop events because some browsers // always call preventDefault for desktop events because some browsers
// try to drag and drop the canvas element // try to drag and drop the canvas element
if (evt.cancelable) { // TODO: if we preventDefault() it will cancel event detection outside of window
evt.preventDefault(); // but we need it for better drag&drop
} // can we disable native drag&drop somehow differently?
// if (evt.cancelable) {
// evt.preventDefault();
// }
}, },
_mouseup: function(evt) { _mouseup: function(evt) {
// workaround for mobile IE to force touch event when unhandled pointer event elevates into a mouse event // workaround for mobile IE to force touch event when unhandled pointer event elevates into a mouse event
@ -13038,15 +13041,14 @@
*/ */
if (Konva.isBrowser) { if (Konva.isBrowser) {
var html = Konva.document.documentElement; window.addEventListener('mouseup', Konva.DD._endDragBefore, true);
html.addEventListener('mouseup', Konva.DD._endDragBefore, true); window.addEventListener('touchend', Konva.DD._endDragBefore, true);
html.addEventListener('touchend', Konva.DD._endDragBefore, true);
html.addEventListener('mousemove', Konva.DD._drag); window.addEventListener('mousemove', Konva.DD._drag);
html.addEventListener('touchmove', Konva.DD._drag); window.addEventListener('touchmove', Konva.DD._drag);
html.addEventListener('mouseup', Konva.DD._endDragAfter, false); window.addEventListener('mouseup', Konva.DD._endDragAfter, false);
html.addEventListener('touchend', Konva.DD._endDragAfter, false); window.addEventListener('touchend', Konva.DD._endDragAfter, false);
} }
})(); })();

4
konva.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -317,14 +317,13 @@
*/ */
if (Konva.isBrowser) { if (Konva.isBrowser) {
var html = Konva.document.documentElement; window.addEventListener('mouseup', Konva.DD._endDragBefore, true);
html.addEventListener('mouseup', Konva.DD._endDragBefore, true); window.addEventListener('touchend', Konva.DD._endDragBefore, true);
html.addEventListener('touchend', Konva.DD._endDragBefore, true);
html.addEventListener('mousemove', Konva.DD._drag); window.addEventListener('mousemove', Konva.DD._drag);
html.addEventListener('touchmove', Konva.DD._drag); window.addEventListener('touchmove', Konva.DD._drag);
html.addEventListener('mouseup', Konva.DD._endDragAfter, false); window.addEventListener('mouseup', Konva.DD._endDragAfter, false);
html.addEventListener('touchend', Konva.DD._endDragAfter, false); window.addEventListener('touchend', Konva.DD._endDragAfter, false);
} }
})(); })();

View File

@ -597,7 +597,7 @@
}); });
}, },
/** /**
* remove self from parent, but don't destroy * remove self from parent, but don't destroy. You can reuse node later.
* @method * @method
* @memberof Konva.Node.prototype * @memberof Konva.Node.prototype
* @returns {Konva.Node} * @returns {Konva.Node}
@ -624,7 +624,7 @@
return this; return this;
}, },
/** /**
* remove and destroy self * remove and destroy a node. Kill it forever! You should not reuse node after destroy().
* @method * @method
* @memberof Konva.Node.prototype * @memberof Konva.Node.prototype
* @example * @example

View File

@ -515,9 +515,12 @@
// always call preventDefault for desktop events because some browsers // always call preventDefault for desktop events because some browsers
// try to drag and drop the canvas element // try to drag and drop the canvas element
if (evt.cancelable) { // TODO: if we preventDefault() it will cancel event detection outside of window
evt.preventDefault(); // but we need it for better drag&drop
} // can we disable native drag&drop somehow differently?
// if (evt.cancelable) {
// evt.preventDefault();
// }
}, },
_mouseup: function(evt) { _mouseup: function(evt) {
// workaround for mobile IE to force touch event when unhandled pointer event elevates into a mouse event // workaround for mobile IE to force touch event when unhandled pointer event elevates into a mouse event

13
test/ifame.html Normal file
View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>KonvaJS Sandbox</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=1.0, minimum-scale=1.0, maximum-scale=1.0">
</head>
<body>
<iframe src="./sandbox.html"></iframe>
</body>
</html>