From d712298fd5016bd9800fa8e855128ab82ef4a683 Mon Sep 17 00:00:00 2001 From: xyf-mac Date: Wed, 10 Nov 2021 22:04:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D2=E4=B8=AAposition=E7=9A=84bu?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/src/inject/index.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/source/src/inject/index.ts b/source/src/inject/index.ts index 58bc90b..449f4fc 100644 --- a/source/src/inject/index.ts +++ b/source/src/inject/index.ts @@ -247,21 +247,21 @@ class CCInspector { return allKeys; } - _getPairProperty(key: string) { + _getPairProperty(key: string): null | { key: string, values: string[] } { let pairProperty: Record = { rotation: ["rotationX", "rotationY"], anchor: ["anchorX", "anchorY"], size: ["width", "height"], skew: ["skewX", "skewY"], - position: ["x", "y", "z"], + position: ["x", "y", "z"], // position比较特殊,过来的key就是position也需要能处理 scale: ["scaleX", "scaleY", "scaleZ"], designResolution: ["width", "height"], // 这个比较特殊,在key下边,其他的都不是在key下 }; - for (let value in pairProperty) { - if (pairProperty.hasOwnProperty(value)) { - let pair = pairProperty[value]; - if (pair.includes(key)) { - return {key: value, values: pair}; + for (let pairPropertyKey in pairProperty) { + if (pairProperty.hasOwnProperty(pairPropertyKey)) { + let pair = pairProperty[pairPropertyKey]; + if (pair.includes(key) || key === pairPropertyKey) { + return {key: pairPropertyKey, values: pair}; } } } @@ -523,7 +523,10 @@ class CCInspector { let index = keys.findIndex(el => el === item); if (index !== -1) { keys.splice(index, 1); - bSplice = true; + if (pair && item === pair.key) { + // 切掉了自己,才能步进+1 + bSplice = true; + } } }); // 序列化成对的属性