From 8fbfb973f6443556079e6bdc57fc3d19f4e0c3df Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Sun, 2 Jul 2017 17:02:53 +0200 Subject: [PATCH] Take into account full size of elements while dragging --- src/utils/Sorter.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/utils/Sorter.js b/src/utils/Sorter.js index 117de420a..a3c7c07c2 100644 --- a/src/utils/Sorter.js +++ b/src/utils/Sorter.js @@ -548,10 +548,15 @@ module.exports = Backbone.View.extend({ if (this.canvasRelative && this.em) { var pos = this.em.get('Canvas').getElementPos(el); - top = pos.top; - left = pos.left; - height = pos.height; - width = pos.width; + var styles = window.getComputedStyle(el); + var marginTop = parseFloat(styles['marginTop']); + var marginBottom = parseFloat(styles['marginBottom']); + var marginRight = parseFloat(styles['marginRight']); + var marginLeft = parseFloat(styles['marginLeft']); + top = pos.top - marginTop; + left = pos.left - marginLeft; + height = pos.height + marginTop + marginBottom; + width = pos.width + marginLeft + marginRight; } else { var o = this.offset(el); top = this.relative ? el.offsetTop : o.top - (this.wmargin ? -1 : 1) * this.elT;