feat(core): 旋转角度支持配置不带单位的数值

fix #260
This commit is contained in:
roymondchen 2022-08-16 15:29:02 +08:00 committed by jia000
parent 41a8400095
commit b1bd7a870e
2 changed files with 6 additions and 1 deletions

View File

@ -29,7 +29,7 @@ import {
triggerCommonMethod,
} from './events';
import Page from './Page';
import { fillBackgroundImage, style2Obj } from './utils';
import { fillBackgroundImage, isNumber, style2Obj } from './utils';
interface AppOptionsConfig {
ua?: string;
@ -125,6 +125,9 @@ class App extends EventEmitter {
if (transformKey === 'scale') {
defaultValue = 1;
}
if (transformKey === 'rotate' && isNumber(transformValue)) {
transformValue = `${transformValue}deg`;
}
return `${transformKey}(${transformValue || defaultValue})`;
})
.join(' ');

View File

@ -53,3 +53,5 @@ export const fillBackgroundImage = (value: string) => {
}
return value;
};
export const isNumber = (value: string) => /^(-?\d+)(\.\d+)?$/.test(value);