From c34bcb0a3054bdab29fbaff17e587c19d7b5de28 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 16 九月 2020 23:39:28 +0800 Subject: [PATCH] 2020-09-16 --- src/templates/modalconfig/dragelement/card.jsx | 18 ++++++++---------- 1 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/templates/modalconfig/dragelement/card.jsx b/src/templates/modalconfig/dragelement/card.jsx index 21d7dec..e7436ea 100644 --- a/src/templates/modalconfig/dragelement/card.jsx +++ b/src/templates/modalconfig/dragelement/card.jsx @@ -18,18 +18,16 @@ const [, drop] = useDrop({ accept: 'form', canDrop: () => true, - drop: (item) => { - if (!item.hasOwnProperty('originalIndex')) { + drop: ({ id: draggedId, originalIndex }) => { + if (originalIndex === undefined) { hasDrop(card) + } else if (draggedId) { + if (draggedId !== id) { + const { index: overIndex } = findCard(id) + moveCard(draggedId, overIndex) + } } - }, - hover({ id: draggedId }) { - if (!draggedId) return - if (draggedId !== id) { - const { index: overIndex } = findCard(id) - moveCard(draggedId, overIndex) - } - }, + } }) const opacity = isDragging ? 0 : 1 -- Gitblit v1.8.0