[英]sortableJS mobile implementation of Drag n' Drop via touch
New to sortableJS . sortableJS的新手。 Working on the mobile side of a Trello clone with Drag n' Drop functionality.
在具有拖放功能的Trello克隆的移动端工作。
Drag n' Drop is working smoothly on desktop but I can't seem to find what tweaks I need to include for mobile device. Drag n' Drop 在桌面上运行顺利,但我似乎找不到我需要为移动设备包括哪些调整。
sortableJS has some mobile options that you can add like ( delay
, delayOnTouchOnly
, touchStartThreshold
, etc) just can't find what I'm looking for in regards to being able to: sortableJS有一些您可以添加的移动选项,例如(
delay
、 delayOnTouchOnly
、 touchStartThreshold
等)只是找不到我正在寻找的关于能够:
function makeSortable() {
Sortable.create($boardContainer[0], {
filter: ".add",
animation: 150,
ghostClass: "ghost",
easing: "cubic-bezier(0.785, 0.135, 0.15, 0.86)",
onMove: function (event) {
let shouldMove = !$(event.related).hasClass("add");
return shouldMove;
},
onEnd: function (event) {
let { id, position } = $(event.item).data();
let newPosition = event.newIndex + 1;
if (position === newPosition) {
return;
}
$.ajax({
url: `/api/lists/${id}`,
data: {
position: newPosition,
},
method: "PUT",
}).then(function () {
init();
});
},
});
$(".list > ul").each(function (index, element) {
Sortable.create(element, {
animation: 150,
ghostClass: "ghost",
easing: "cubic-bezier(0.785, 0.135, 0.15, 0.86)",
group: "shared",
onEnd: function (event) {
let { id, position, list_id } = $(event.item).find("button").data();
let newPosition = event.newIndex + 1;
let newListId = $(event.item).parents(".list").data("id");
if (position === newPosition && list_id === newListId) {
return;
}
$.ajax({
url: `/api/cards/${id}`,
method: "PUT",
data: {
list_id: newListId,
position: newPosition,
},
}).then(function () {
init();
});
},
});
});
}
Any help would be greatly appreciated!任何帮助将不胜感激!
Just came down to having the right CDN.只是归结为拥有正确的 CDN。 The one I had imported didn't yet have the functionality ironed out: When in doubt check your scripts!
我导入的那个还没有解决这个功能:如果有疑问,请检查你的脚本! :)
:)
Latest CDN:最新CDN:
<script src="https://cdn.jsdelivr.net/npm/sortablejs@latest/Sortable.min.js"></script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.