Browse Source

'图标图片原点设置'

zhangyu 5 years ago
parent
commit
90cfd7b7c2
1 changed files with 4 additions and 3 deletions
  1. 4 3
      saga-web-big/src/items/SIconTextItem.ts

+ 4 - 3
saga-web-big/src/items/SIconTextItem.ts

@@ -118,6 +118,7 @@ export class SIconTextItem extends SObjectItem {
     }
     set sWidth(v: number) {
         this.img.width = v;
+        this.img.origin = new SPoint(this.img.width * 0.5, this.img.height * 0.5);
         this.changeAhchorPoint();
         this.update();
     }
@@ -128,6 +129,7 @@ export class SIconTextItem extends SObjectItem {
     }
     set sHeight(v: number) {
         this.img.height = v;
+        this.img.origin = new SPoint(this.img.width * 0.5, this.img.height * 0.5);
         this.changeAhchorPoint();
         this.update();
     }
@@ -180,6 +182,7 @@ export class SIconTextItem extends SObjectItem {
         this.img.url = `http://adm.sagacloud.cn:8080/doc/assets/img/logo.png`;
         this.img.width = 32;
         this.img.height = 32;
+        this.img.origin = new SPoint(this.img.width * 0.5, this.img.height * 0.5);
         this.img.connect("onMove", this, this.changeAhchorPoint.bind(this));
         let anchorPoint;
         if (data && data.length) {
@@ -210,7 +213,7 @@ export class SIconTextItem extends SObjectItem {
         this.textItem.text = "";
         this.textItem.font.size = 12;
         // 偏移二分之一文本高度
-        this.textItem.moveTo((this.img.width * 0.5) + 4, -(this.textItem.height * 0.5));
+        this.textItem.moveTo((this.img.width * 0.5) + 2, -(this.textItem.height * 0.5));
         this.moveable = true;
         this.selectable = true;
     }
@@ -254,8 +257,6 @@ export class SIconTextItem extends SObjectItem {
      * @param   newSize 改之后大小
      * */
     onResize(oldSize: SSize, newSize: SSize) {
-        this.img.origin = new SPoint(this.img.width * 0.5, this.img.height * 0.5);
-        this.update();
         console.log(arguments);
     } // Function onResize()