iter(g192): 动效时长字面值归零补循环档
This commit is contained in:
@@ -194,8 +194,19 @@ const DURATION_STEPS = [
|
||||
{ max: 0.17, token: 'var(--ua-duration-fast)' },
|
||||
{ max: 0.23, token: 'var(--ua-duration-base)' },
|
||||
{ max: 0.2501, token: 'var(--ua-duration-slow)' },
|
||||
{ max: 0.36, token: 'var(--ua-duration-slower)' },
|
||||
];
|
||||
|
||||
/*** 作用:循环动效(infinite)的时长 → 循环四档;0.7/0.8 收敛到中档、1.2/1.4 收敛到慢档,表外保留 ***/
|
||||
const LOOP_DURATIONS = new Map([
|
||||
['0.6s', 'var(--ua-duration-loop-fast)'],
|
||||
['0.7s', 'var(--ua-duration-loop-mid)'],
|
||||
['0.8s', 'var(--ua-duration-loop-mid)'],
|
||||
['1.2s', 'var(--ua-duration-loop-slow)'],
|
||||
['1.4s', 'var(--ua-duration-loop-slow)'],
|
||||
['1.6s', 'var(--ua-duration-loop-long)'],
|
||||
]);
|
||||
|
||||
/*** 作用:控件高度三档的字面值 → 令牌(28/34/40px 三个值保留给控件高度档位,其余尺寸不入此口径) ***/
|
||||
const CONTROL_H_TOKENS = new Map([
|
||||
['28px', 'var(--ua-control-h-sm)'],
|
||||
@@ -305,12 +316,13 @@ function hasTiming(value) {
|
||||
/*** 作用:迁移单个动效声明值(逐段替换时长,缺缓动时补 --ua-ease);返回 null 表示无需改动 ***/
|
||||
function migrateMotion(prop, core) {
|
||||
const shorthand = prop === 'transition' || prop === 'animation'; // 只有简写能补缓动,-duration 属性补了是非法的
|
||||
const loop = /infinite/.test(core) && (prop === 'animation' || prop === 'animation-duration'); // 无限循环走循环四档
|
||||
const parts = splitTopLevel(core);
|
||||
let hits = 0;
|
||||
const next = parts.map((segment) => {
|
||||
let replaced = 0;
|
||||
let out = segment.replace(/(\d*\.?\d+)(ms|s)\b/gi, (token) => {
|
||||
const mapped = durationToken(token);
|
||||
const mapped = loop ? LOOP_DURATIONS.get(token.toLowerCase()) ?? null : durationToken(token);
|
||||
if (!mapped) return token; // 表外时长保留,交给后续视觉条目单独评估
|
||||
replaced++;
|
||||
hits++;
|
||||
|
||||
Reference in New Issue
Block a user