From c1fe438925629c7814218aa8dfa291226146532f Mon Sep 17 00:00:00 2001 From: Peter Stuifzand Date: Tue, 24 Aug 2021 22:02:56 +0200 Subject: [PATCH] fix(drag): while dragging copy marginLeft to show item with right indent --- list-editor/index.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/list-editor/index.js b/list-editor/index.js index 1f6d4d5..10dee27 100644 --- a/list-editor/index.js +++ b/list-editor/index.js @@ -396,15 +396,19 @@ function editor(root, inputData, options) { } function enableDragging(rootElement) { + let start = -1; + let startID = null; + let drake = dragula([rootElement], { moves: function (el, container, handle, sibling) { return handle.classList.contains('marker') + }, + accepts: function (el, target, source, sibling) { + el.style.marginLeft = sibling === null ? 0 : sibling.style.marginLeft + return true } }) - let start = -1; - let startID = null; - drake.on('drag', function (el, source) { startID = $(el).attr('data-id') })