fix(core): 解决固定元素失效问题

固定元素在父链存在非none的transform时无效,去除空值的transform样式。
This commit is contained in:
i33 2022-08-30 18:30:25 +08:00 committed by jia000
parent 793d02a706
commit 8db7821032

View File

@ -119,18 +119,16 @@ class App extends EventEmitter {
if (key === 'backgroundImage') { if (key === 'backgroundImage') {
value && (results[key] = fillBackgroundImage(value)); value && (results[key] = fillBackgroundImage(value));
} else if (key === 'transform' && typeof value !== 'string') { } else if (key === 'transform' && typeof value !== 'string') {
results[key] = Object.entries(value as Record<string, string>) const values = Object.entries(value as Record<string, string>)
.map(([transformKey, transformValue]) => { .map(([transformKey, transformValue]) => {
let defaultValue = 0; if (!transformValue.trim()) return '';
if (transformKey === 'scale') {
defaultValue = 1;
}
if (transformKey === 'rotate' && isNumber(transformValue)) { if (transformKey === 'rotate' && isNumber(transformValue)) {
transformValue = `${transformValue}deg`; transformValue = `${transformValue}deg`;
} }
return `${transformKey}(${transformValue || defaultValue})`; return `${transformKey}(${transformValue})`;
}) })
.join(' '); .join(' ');
results[key] = !values.trim() ? 'none' : values;
} else if (!whiteList.includes(key) && value && /^[-]?[0-9]*[.]?[0-9]*$/.test(value)) { } else if (!whiteList.includes(key) && value && /^[-]?[0-9]*[.]?[0-9]*$/.test(value)) {
results[key] = `${value / 100}rem`; results[key] = `${value / 100}rem`;
} else { } else {