客户有一个使用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 });
}
});Dest配置(锚/链接):
document.querySelectorAll('.drop-box').forEach(dropBox => {
new Sortable(dropBox, {
group: {
name: 'shared'
},
ghostClass: "dropping",
animation: 200,
sort: false,
filter: '.drop-box',
onAdd: function (evt) {
}
});
})我们能做些什么?
谢谢你的帮助。
发布于 2022-11-30 15:51:52
看看onMove,onEnd或者onUpdate。欲了解更多信息:https://github.com/SortableJS/Sortable
https://stackoverflow.com/questions/67035603
复制相似问题