0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

sortable.js trash

0
Posted at

-demo https://codepen.io/gnjo/pen/PgJqLM
-sortable.jsは明確に削除操作が無い為、body全体にドロップされた際に削除する。

Sortable.create(document.body
...
 onAdd:e=>e.item.remove(), //remove
var data=`https://i.imgur.com/5ntXKyR.jpg,https://i.imgur.com/rCJwzGQ.jpg,https://i.imgur.com/CcKioLq.jpg,https://i.imgur.com/9AViGyD.jpg`.split(',')
,base =document.getElementById('base')
,ed=document.getElementById('ed')
,fac=(d)=>{var el =document.createElement('img');el.src=d;return el}
data.map(fac).map(d=> base.appendChild(d) )

Sortable.create(base, {
 animation: 200,
 group: {
  name: "shared",
  pull: "clone",
  put: false,
  revertClone: true,
 },
 sort: true
});

Sortable.create(ed, {
 group: "shared",
 sort: true,
});

Sortable.create(document.body, {
 group: {
  name: 'trash',
  pull: false,
  put: ['shared']
 },
 sort: false,
 onAdd:e=>e.item.remove(), //remove
});
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?