|
|
@ -46,22 +46,34 @@ export default { |
|
|
|
}; |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
removeAll(){ |
|
|
|
removeAll() { |
|
|
|
this.lineLeft = []; |
|
|
|
this.lineTop = []; |
|
|
|
}, |
|
|
|
listenerChange(list, index,cb) { |
|
|
|
listenerChange(list, index, cb) { |
|
|
|
const activeStyle = list[index].style; |
|
|
|
// 上边缘 |
|
|
|
if (Math.abs(activeStyle.top) <= value) { |
|
|
|
activeStyle.top = 0; |
|
|
|
cb && cb(list[index], index); |
|
|
|
} |
|
|
|
// 左边缘 |
|
|
|
if (Math.abs(activeStyle.left) <= value) { |
|
|
|
activeStyle.left = 0; |
|
|
|
cb && cb(list[index], index); |
|
|
|
} |
|
|
|
if (list.length==1) { |
|
|
|
return |
|
|
|
} |
|
|
|
list.forEach((item, jndex) => { |
|
|
|
if (jndex !== index) { |
|
|
|
let curStyle = item.style; |
|
|
|
|
|
|
|
let curBottom = curStyle.top+curStyle.height |
|
|
|
let curRight = curStyle.left+curStyle.width |
|
|
|
let actRight = activeStyle.left+activeStyle.width |
|
|
|
let actBottom = activeStyle.top+activeStyle.height |
|
|
|
let curBottom = curStyle.top + curStyle.height; |
|
|
|
let curRight = curStyle.left + curStyle.width; |
|
|
|
let actRight = activeStyle.left + activeStyle.width; |
|
|
|
let actBottom = activeStyle.top + activeStyle.height; |
|
|
|
|
|
|
|
|
|
|
|
this.removeLine(curStyle.top, curStyle.left); |
|
|
|
this.removeLine(curBottom, curRight); |
|
|
|
// TODO 中 中 |
|
|
@ -69,49 +81,49 @@ export default { |
|
|
|
if (Math.abs(activeStyle.top - curStyle.top) <= value) { |
|
|
|
activeStyle.top = curStyle.top; |
|
|
|
this.makeTop2Bottom(curStyle.top); |
|
|
|
cb&&cb(list[index],index) |
|
|
|
cb && cb(list[index], index); |
|
|
|
} |
|
|
|
// 下--上 |
|
|
|
if (Math.abs(actBottom - curBottom) <= value) { |
|
|
|
activeStyle.top = curBottom - activeStyle.height; |
|
|
|
this.makeTop2Bottom(curBottom); |
|
|
|
cb&&cb(list[index],index) |
|
|
|
cb && cb(list[index], index); |
|
|
|
} |
|
|
|
// 上--下 |
|
|
|
if (Math.abs(activeStyle.top - curBottom) <= value) { |
|
|
|
activeStyle.top = curBottom; |
|
|
|
this.makeTop2Bottom(curBottom); |
|
|
|
cb&&cb(list[index],index) |
|
|
|
cb && cb(list[index], index); |
|
|
|
} |
|
|
|
// 左--左 |
|
|
|
if (Math.abs(activeStyle.left - curStyle.left) <= value) { |
|
|
|
activeStyle.left = curStyle.left; |
|
|
|
this.makeLeft2Right(curStyle.left); |
|
|
|
cb&&cb(list[index],index) |
|
|
|
cb && cb(list[index], index); |
|
|
|
} |
|
|
|
// 左--右 |
|
|
|
if (Math.abs(activeStyle.left - curRight) <= value) { |
|
|
|
activeStyle.left = curRight |
|
|
|
activeStyle.left = curRight; |
|
|
|
this.makeLeft2Right(curRight); |
|
|
|
cb&&cb(list[index],index) |
|
|
|
cb && cb(list[index], index); |
|
|
|
} |
|
|
|
// 右--右 |
|
|
|
if (Math.abs(actRight - curRight) <= value) { |
|
|
|
activeStyle.left = curRight - activeStyle.width; |
|
|
|
this.makeLeft2Right(curRight); |
|
|
|
cb&&cb(list[index],index) |
|
|
|
cb && cb(list[index], index); |
|
|
|
} |
|
|
|
// 下--上 |
|
|
|
if (Math.abs(actBottom - curStyle.top) <= value) { |
|
|
|
activeStyle.top = curStyle.top - activeStyle.height; |
|
|
|
this.makeTop2Bottom(curStyle.top); |
|
|
|
cb&&cb(list[index],index) |
|
|
|
cb && cb(list[index], index); |
|
|
|
} |
|
|
|
// 右--左 |
|
|
|
if (Math.abs(actRight - curStyle.left) <= value) { |
|
|
|
activeStyle.left = curStyle.left - activeStyle.width; |
|
|
|
this.makeLeft2Right(curStyle.left); |
|
|
|
cb&&cb(list[index],index) |
|
|
|
cb && cb(list[index], index); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|