From 836fe2d928d0e7b8330a052d8b70abc2048112bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=91=A3=E5=93=B2=E5=A5=87?= <13840175730@139.com> Date: Tue, 6 Aug 2024 09:24:56 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=AE=8C=E5=96=84=E4=B8=8A=E6=96=99=E6=8B=96?= =?UTF-8?q?=E6=8B=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/sliao/index.vue | 41 ++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/src/views/sliao/index.vue b/src/views/sliao/index.vue index be0f787..9152ffb 100644 --- a/src/views/sliao/index.vue +++ b/src/views/sliao/index.vue @@ -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);