Skip to content

Commit a2049e9

Browse files
novaxproStefanie Hein
andauthored
Dragging nested fields 78614 (#54)
* Drag-Drop: add a negative margin (as a positive) to the marginBoxWidth to correct the width when using a drag/drop helper element. See #78614 --------- Co-authored-by: Stefanie Hein <stefanie.hein@the-elements.de>
1 parent 66f6aeb commit a2049e9

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

public/cui.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25750,7 +25750,7 @@ CUI.Draggable = (function(superClass) {
2575025750
};
2575125751

2575225752
Draggable.prototype.init_helper = function(ev, $target, diff) {
25753-
var clone_source, dim, helper, hn, offset, set_dim, start;
25753+
var cloneMarginBoxWidth, clone_source, dim, helper, hn, offset, set_dim, start;
2575425754
helper = this.get_helper(ev, CUI.globalDrag, diff);
2575525755
if (!helper) {
2575625756
return;
@@ -25779,8 +25779,12 @@ CUI.Draggable = (function(superClass) {
2577925779
CUI.dom.setStyle(hn, start);
2578025780
if (helper === "clone") {
2578125781
set_dim = CUI.dom.getDimensions(clone_source);
25782+
cloneMarginBoxWidth = set_dim.marginBoxWidth;
25783+
if (set_dim.marginLeft < 0) {
25784+
cloneMarginBoxWidth = set_dim.marginBoxWidth + (-1 * set_dim.marginLeft);
25785+
}
2578225786
CUI.dom.setDimensions(hn, {
25783-
marginBoxWidth: set_dim.marginBoxWidth,
25787+
marginBoxWidth: cloneMarginBoxWidth,
2578425788
marginBoxHeight: set_dim.marginBoxHeight
2578525789
});
2578625790
}

public/cui.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/base/DragDropSelect/Draggable.coffee

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,8 +629,13 @@ class CUI.Draggable extends CUI.DragDropSelect
629629

630630
# console.error "measureing clone", set_dim.marginBoxWidth, CUI.globalDrag.$source, dim
631631

632+
# if element has a negative margin we need to add that (as a positive) to the marginBoxWidth, so the width is correct
633+
cloneMarginBoxWidth = set_dim.marginBoxWidth
634+
if set_dim.marginLeft < 0
635+
cloneMarginBoxWidth = set_dim.marginBoxWidth + (-1 * set_dim.marginLeft)
636+
632637
CUI.dom.setDimensions hn,
633-
marginBoxWidth: set_dim.marginBoxWidth
638+
marginBoxWidth: cloneMarginBoxWidth
634639
marginBoxHeight: set_dim.marginBoxHeight
635640

636641

0 commit comments

Comments
 (0)