Commit 9a82021a authored by hucy's avatar hucy

fix:不重要的提交

parent 481607b1
......@@ -87,10 +87,10 @@ function createShape() {
draggable: true,
});
state.shape = new Konva.Rect({
width: 30 + Math.random() * 30,
height: 30 + Math.random() * 30,
width: 60 + Math.random() * 30,
height: 60 + Math.random() * 30,
fill: 'grey',
rotation: 360 * Math.random(),
// rotation: 360 * Math.random(),
name: 'fillShape',
});
state.group.add(state.shape);
......@@ -117,10 +117,10 @@ function haveIntersection(r1: any, r2: any) {
c: false,
d: false,
};
let pos: any = {
x: r2.x + r2.width,
y: r2.y + r2.height,
};
// let pos: any = {
// x: r2.x + r2.width,
// y: r2.y + r2.height,
// };
if (r2.x > r1.x + r1.width) {
obj.a = true;
}
......@@ -133,11 +133,11 @@ function haveIntersection(r1: any, r2: any) {
if (r2.y + r2.height < r1.y) {
obj.d = true;
}
console.log('obj', obj, obj.a || obj.b || obj.c || obj.d);
// console.log('obj', obj, obj.a || obj.b || obj.c || obj.d);
return {
value: !(obj.a || obj.b || obj.c || obj.d),
pos,
// pos,
};
// return !(
......@@ -156,13 +156,21 @@ function layerDragmove(e: any) {
if (group._id == target._id) {
return;
}
// r1当前循环的可视矩形区域 r2当前移动目标的可视矩形区域
let r1 = group.getClientRect();
let r2 = targetRect;
let result = haveIntersection(r1, r2);
if (result.value) {
console.log('1', target._lastPos);
// target.x(result.pos.x);
// target.y(result.pos.y);
// 有碰撞
console.log('1', target);
if (r2.x < r1.x + r1.width / 2) {
target.x(r1.x - r2.width);
} else {
target.x(r1.x + r1.width);
}
// target.x(100);
// target.y(100);
group.findOne('.fillShape').fill('red');
} else {
group.findOne('.fillShape').fill('grey');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment