mirror of
https://github.com/motajs/template.git
synced 2026-11-30 18:54:30 +08:00
fix: sequenceCurve 在 0 处不固定为 0
This commit is contained in:
1 parent
f2b5ba9d97
commit
35d03881d2
1 file changed
+11
-4
@@ -185,12 +185,19 @@ export function sequenceCurve(
|
||||
);
|
||||
return () => 0;
|
||||
}
|
||||
const keep = [seq[0](0), ...cumsum(duration)];
|
||||
const keep = [0, ...cumsum(duration)];
|
||||
return p => {
|
||||
const index = keep.findIndex(sum => p <= sum);
|
||||
if (index <= 0) return 0;
|
||||
const progress = (p - keep[index - 1]) / duration[index - 1];
|
||||
return seq[index - 1](progress) * scale[index - 1] + move[index - 1];
|
||||
if (index < 0) {
|
||||
return 0;
|
||||
} else if (index === 0) {
|
||||
return seq[0](0);
|
||||
} else {
|
||||
const progress = (p - keep[index - 1]) / duration[index - 1];
|
||||
return (
|
||||
seq[index - 1](progress) * scale[index - 1] + move[index - 1]
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user