修复2个position的bug

This commit is contained in:
xyf-mac 2021-11-10 22:04:51 +08:00
parent 24f778de84
commit d712298fd5

View File

@ -247,21 +247,21 @@ class CCInspector {
return allKeys; return allKeys;
} }
_getPairProperty(key: string) { _getPairProperty(key: string): null | { key: string, values: string[] } {
let pairProperty: Record<string, any> = { let pairProperty: Record<string, any> = {
rotation: ["rotationX", "rotationY"], rotation: ["rotationX", "rotationY"],
anchor: ["anchorX", "anchorY"], anchor: ["anchorX", "anchorY"],
size: ["width", "height"], size: ["width", "height"],
skew: ["skewX", "skewY"], skew: ["skewX", "skewY"],
position: ["x", "y", "z"], position: ["x", "y", "z"], // position比较特殊过来的key就是position也需要能处理
scale: ["scaleX", "scaleY", "scaleZ"], scale: ["scaleX", "scaleY", "scaleZ"],
designResolution: ["width", "height"], // 这个比较特殊在key下边其他的都不是在key下 designResolution: ["width", "height"], // 这个比较特殊在key下边其他的都不是在key下
}; };
for (let value in pairProperty) { for (let pairPropertyKey in pairProperty) {
if (pairProperty.hasOwnProperty(value)) { if (pairProperty.hasOwnProperty(pairPropertyKey)) {
let pair = pairProperty[value]; let pair = pairProperty[pairPropertyKey];
if (pair.includes(key)) { if (pair.includes(key) || key === pairPropertyKey) {
return {key: value, values: pair}; return {key: pairPropertyKey, values: pair};
} }
} }
} }
@ -523,7 +523,10 @@ class CCInspector {
let index = keys.findIndex(el => el === item); let index = keys.findIndex(el => el === item);
if (index !== -1) { if (index !== -1) {
keys.splice(index, 1); keys.splice(index, 1);
bSplice = true; if (pair && item === pair.key) {
// 切掉了自己,才能步进+1
bSplice = true;
}
} }
}); });
// 序列化成对的属性 // 序列化成对的属性