Browse Source

上边缘左边缘吸附

master
1549469775 4 years ago
parent
commit
05e9ff7360
  1. 6
      src/api/request/index.js
  2. 44
      src/ui/editor/MakeLine.vue

6
src/api/request/index.js

@ -16,7 +16,7 @@ const checkERR = (err, type) => {
};
// 静默执行
export function request_(type = "GET", url, data = {},contentType=0,sendToken = true) {
export function request_(type = "GET", url, data = {}) {
var __data = {};
if (type.toUpperCase() == "GET") {
__data.params = data;
@ -34,10 +34,6 @@ export function request_(type = "GET", url, data = {},contentType=0,sendToken =
url: realUrl,
method: type,
...__data,
headers:{
$type: contentType,
$token: sendToken,
},
responseType: "json",
})
.then((res) => {

44
src/ui/editor/MakeLine.vue

@ -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);
}
}
});

Loading…
Cancel
Save