|
|
|
@ -118,12 +118,23 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
let _index=0
|
|
|
|
|
|
|
|
|
|
group.on('dragstart',function (){
|
|
|
|
|
const {x,y}=this.absolutePosition()
|
|
|
|
|
this.startPos={
|
|
|
|
|
x:x,
|
|
|
|
|
y:y
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
group.on('dragmove',function (){
|
|
|
|
|
if(_index===0){
|
|
|
|
|
_index=this.getAttr('index')
|
|
|
|
|
}
|
|
|
|
|
this.zIndex(999)
|
|
|
|
|
const {y:thisY}=this.absolutePosition()
|
|
|
|
|
|
|
|
|
|
const dir=thisY-this.startPos.y>0?-40:40
|
|
|
|
|
|
|
|
|
|
const children=that.slGroup.children
|
|
|
|
|
|
|
|
|
|
for (const child of children) {
|
|
|
|
@ -132,34 +143,24 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const {y:thatY}=child.absolutePosition()
|
|
|
|
|
|
|
|
|
|
const moveUpFlag=child.getAttr('moveUp')||false
|
|
|
|
|
if (thisY>=thatY&&thisY<=thatY+40&&!moveUpFlag){
|
|
|
|
|
child.setAttr('moveUp',true);
|
|
|
|
|
child.setAttr('moveDown',false);
|
|
|
|
|
--_index
|
|
|
|
|
const moveDir=child.getAttr('moveDir')||0
|
|
|
|
|
if (thisY>=thatY&&thisY<=thatY+40&&moveDir!==dir){
|
|
|
|
|
child.setAttr('moveDir',dir);
|
|
|
|
|
_index+=dir>0?1:-1
|
|
|
|
|
child.move({
|
|
|
|
|
y:-40
|
|
|
|
|
y:dir
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const {y:_thatY}=child.absolutePosition()
|
|
|
|
|
const moveDownFlag=child.getAttr('moveDown')||false
|
|
|
|
|
if (thisY<=_thatY&&!moveDownFlag){
|
|
|
|
|
const moveUpFlag=child.getAttr('moveUp')||false
|
|
|
|
|
if (moveUpFlag){
|
|
|
|
|
child.setAttr('moveUp',false);
|
|
|
|
|
child.setAttr('moveDown',true);
|
|
|
|
|
++_index
|
|
|
|
|
child.move({
|
|
|
|
|
y:40
|
|
|
|
|
})
|
|
|
|
|
this.startPos={
|
|
|
|
|
x:x,
|
|
|
|
|
y:thisY
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
group.on('dragend',function (){
|
|
|
|
|
console.log(_index)
|
|
|
|
|
const index=this.getAttr('index')
|
|
|
|
|
const element = slList.splice(index-1, 1)[0];
|
|
|
|
|
slList.splice(_index-1, 0, element);
|
|
|
|
|