客户有一个使用 SortableJS 的项目,但不是在列表之间移动,而是用于从列表中选择给定项目,并将其“拖放”到给定的超链接中。我们需要能够检测到 drop 事件,但要防止对 DOM 进行任何修改,因为我们只需要数据,我们还需要防止克隆。
这是我们迄今为止所拥有的
源配置:
new Sortable(cardsContainer, {
animation: 200,
ghostClass: 'dragging',
sort: false,
forceFallback: true,
group: {
name: 'shared',
pull: true, // To clone: set pull to 'clone',
revertClone: true
},
onStart: function (evt) {
createDropSortable();
menuWrapper = document.querySelector('.sidebar-menu');
observer.observe(menuWrapper, { attributes: true, childList: true, subtree: true });
}
});
目标配置(锚/链接):
document.querySelectorAll('.drop-box').forEach(dropBox => {
new Sortable(dropBox, {
group: {
name: 'shared'
},
ghostClass: "dropping",
animation: 200,
sort: false,
filter: '.drop-box',
onAdd: function (evt) {
}
});
})
任何想法我们可以做什么?
谢谢您的帮助。