.sortable-chosen ghost

拖拽时添加的高亮元素
sortable-chosen.jpg

onEnd

image.png

  1. Sortable.create(item, {
  2. animation: 150,
  3. ghostClass: styled.blue,
  4. group: {
  5. name: 'items',
  6. pull: 'clone',
  7. put: false, // 禁止拖拽到当前列表
  8. },
  9. setData: function (dataTransfer, dragEl) {
  10. console.log('set', dataTransfer, dragEl);
  11. // `dataTransfer` object of HTML5 DragEvent
  12. dataTransfer.setData('Text', dragEl.textContent);
  13. },
  14. // Element dragging ended
  15. onEnd: function (e) {
  16. const {
  17. item, from, to, oldIndex, newIndex,
  18. oldDraggableIndex, newDraggableIndex,
  19. clone, pullMode,
  20. } = e;
  21. console.log('end', e);
  22. // item dragged HTMLElement
  23. // to target list
  24. // from previous list
  25. // oldIndex element's old index within old parent
  26. // newIndex element's new index within new parent
  27. // oldDraggableIndex; element's old index within old parent, only counting draggable elements
  28. // newDraggableIndex; element's new index within new parent, only counting draggable elements
  29. // clone; the clone element
  30. // pullMode; when item is in another sortable: `"clone"` if cloning, `true` if moving
  31. },
  32. });