|
@@ -80,6 +80,7 @@ export class SIconTextItem extends SObjectItem {
|
|
}
|
|
}
|
|
set sWidth(v: number) {
|
|
set sWidth(v: number) {
|
|
this.img.width = v;
|
|
this.img.width = v;
|
|
|
|
+ this.changeAhchorPoint();
|
|
this.update();
|
|
this.update();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -89,6 +90,7 @@ export class SIconTextItem extends SObjectItem {
|
|
}
|
|
}
|
|
set sHeight(v: number) {
|
|
set sHeight(v: number) {
|
|
this.img.height = v;
|
|
this.img.height = v;
|
|
|
|
+ this.changeAhchorPoint();
|
|
this.update();
|
|
this.update();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -140,7 +142,13 @@ export class SIconTextItem extends SObjectItem {
|
|
this.img.url = `http://adm.sagacloud.cn:8080/doc/assets/img/logo.png`;
|
|
this.img.url = `http://adm.sagacloud.cn:8080/doc/assets/img/logo.png`;
|
|
this.img.width = 24;
|
|
this.img.width = 24;
|
|
this.img.height = 24;
|
|
this.img.height = 24;
|
|
- let anchorPoint = [{ x: 0, y: this.img.height / 2 }, { x: 0, y: -this.img.height / 2 }, { x: -this.img.width / 2, y: 0 }, { x: this.img.width / 2, y: 0 }];
|
|
|
|
|
|
+ this.img.connect("onMove", this, this.moveAhchorPoint.bind(this));
|
|
|
|
+ let anchorPoint = [
|
|
|
|
+ { x: this.img.x, y: this.img.height / 2 },
|
|
|
|
+ { x: this.img.x, y: -this.img.height / 2 },
|
|
|
|
+ { x: -this.img.width / 2, y: this.img.y },
|
|
|
|
+ { x: this.img.width / 2, y: this.img.y }
|
|
|
|
+ ];
|
|
this.anchorList = anchorPoint.map(t => {
|
|
this.anchorList = anchorPoint.map(t => {
|
|
let item = new SAnchorItem(this);
|
|
let item = new SAnchorItem(this);
|
|
item.moveTo(t.x, t.y);
|
|
item.moveTo(t.x, t.y);
|
|
@@ -158,11 +166,42 @@ export class SIconTextItem extends SObjectItem {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * 图片移动计算并移动锚点的位置
|
|
|
|
+ *
|
|
|
|
+ * */
|
|
|
|
+ private moveAhchorPoint(): void {
|
|
|
|
+ // 判断是否有锚点
|
|
|
|
+ if (this.anchorList.length) {
|
|
|
|
+ this.anchorList.forEach(item => {
|
|
|
|
+ item.moveTo(item.x + this.img.x, item.y + this.img.y);
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ } // Function moveAhchorPoint()
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 图片大小改变计算并移动锚点的位置
|
|
|
|
+ *
|
|
|
|
+ * */
|
|
|
|
+ private changeAhchorPoint(): void {
|
|
|
|
+ // 判断是否有锚点
|
|
|
|
+ if (this.anchorList.length) {
|
|
|
|
+ let anchorPoint = [
|
|
|
|
+ { x: this.img.x, y: this.img.height / 2 },
|
|
|
|
+ { x: this.img.x, y: -this.img.height / 2 },
|
|
|
|
+ { x: -this.img.width / 2, y: this.img.y },
|
|
|
|
+ { x: this.img.width / 2, y: this.img.y }
|
|
|
|
+ ];
|
|
|
|
+ this.anchorList.forEach((item, index) => {
|
|
|
|
+ item.moveTo(anchorPoint[index].x, anchorPoint[index].y);
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ } // Function changeAhchorPoint()
|
|
|
|
+
|
|
|
|
+ /**
|
|
* 鼠标按下事件
|
|
* 鼠标按下事件
|
|
*
|
|
*
|
|
* */
|
|
* */
|
|
onMouseDown(event: SMouseEvent): boolean {
|
|
onMouseDown(event: SMouseEvent): boolean {
|
|
- console.log(this)
|
|
|
|
if (this.status == SItemStatus.Normal) {
|
|
if (this.status == SItemStatus.Normal) {
|
|
return super.onMouseDown(event);
|
|
return super.onMouseDown(event);
|
|
} else if (this.status == SItemStatus.Edit) {
|
|
} else if (this.status == SItemStatus.Edit) {
|