집 > Q&A > 본문
想实现:把p1拖放到p2上时,p2变成半透明,鼠标放开把p2替换为p1。我使用了html5的drag,能实现拖动,但是始终没有比较好的方法实现想实现的功能,各路英雄帮帮忙呀~
ringa_lee2017-04-11 13:24:55
我用了个拖拽库实现.. dragula
我是这样实现的:
1
2
3
4
5
6
7
8
9
10
11
<code>dragula([document.querySelector('list')], {
<code>dragula([document.querySelector(
'list'
)], {
direction: 'vertical'
direction:
'vertical'
})
.on('drag', (el) => {
.on(
'drag'
, (el) => {
this.dragIndex = $(el).index()
.on('drop', (el) => {
'drop'
this.dropIndex = $(el).index()
// sort 内实现数据交换
this.sort()
})</code>