mirror of
https://github.com/motajs/template.git
synced 2026-11-20 11:24:30 +08:00
fix: sequenceCurve 问题
This commit is contained in:
1 parent
51a2a66847
commit
e469941f01
3 files changed
+8
-8
No files matched your search
@@ -290,8 +290,8 @@ export class Animater implements IAnimater {
|
||||
plan: number = this.executingGroup
|
||||
): Promise<void> {
|
||||
const raw = this.query(content, index, plan);
|
||||
if (!raw) return Promise.resolve();
|
||||
else return raw.promise;
|
||||
if (raw) return raw.promise;
|
||||
else return Promise.resolve();
|
||||
}
|
||||
|
||||
planEnd(preTime: number = 0, postTime: number = 0): number {
|
||||
|
||||
@@ -337,7 +337,7 @@ export interface IAnimater extends IExcitable<number> {
|
||||
|
||||
/**
|
||||
* 等待指定动画计划执行完毕,参考 {@link query} 的描述。
|
||||
* 如果对象没有正在执行动画或在指定计划中不存在,那么返回的 `Promise` 会立刻兑现。
|
||||
* 如果对象的动画已经执行完毕或在指定计划中不存在,那么返回的 `Promise` 会立刻兑现。
|
||||
* @param content 动画对象
|
||||
* @param index 动画计划索引
|
||||
* @param plan 计划组索引,不填时表示当前正在执行动画的计划组。
|
||||
|
||||
@@ -171,12 +171,12 @@ export function sequenceCurve(
|
||||
scale: number[],
|
||||
move: number[]
|
||||
): ExcitationCurve {
|
||||
const keep = cumsum(duration);
|
||||
const keep = [0, ...cumsum(duration)];
|
||||
return p => {
|
||||
const index = keep.findIndex(sum => p >= sum);
|
||||
if (index === -1) return 0;
|
||||
const progress = (p - keep[index]) / duration[index];
|
||||
return seq[index](progress) * scale[index] + move[index];
|
||||
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];
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user