X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/436728b375888873e6e96079a73f12d8adbd7b96..5952990eee08ffd82ee5e8ecd3f840dacf222ef6:/src/editor/modules/documentCanvas/canvas/genericElement.js diff --git a/src/editor/modules/documentCanvas/canvas/genericElement.js b/src/editor/modules/documentCanvas/canvas/genericElement.js index f115bd4..44615f5 100644 --- a/src/editor/modules/documentCanvas/canvas/genericElement.js +++ b/src/editor/modules/documentCanvas/canvas/genericElement.js @@ -103,22 +103,19 @@ $.extend(generic, { referenceAction = 'after'; } - if(event.type === 'nodeMoved') { - /* globals Node */ - if(event.meta.node.nodeType === Node.TEXT_NODE) { - actionArg = utils.getElementForTextNode(event.meta.node); - } else { - actionArg = utils.getElementForNode(event.meta.node); + if(event.meta.move) { + /* Let's check if this node had its own canvas element and it's accessible. */ + actionArg = utils.getElementForElementRootNode(event.meta.node); + if(actionArg && actionArg.sameNode(referenceElement)) { + referenceElement = this.children()[nodeIndex]; } - } else { + } + if(!actionArg) { actionArg = event.meta.node; } referenceElement[referenceAction](actionArg); }, - onNodeMoved: function(event) { - return this.onNodeAdded.call(this, event); - }, onNodeDetached: function(event) { if(event.meta.node.sameNode(this)) { this.detach();