Checkpoint current UI and ink integration state
This commit is contained in:
@@ -27,6 +27,7 @@ class AnimationQueueModule extends BaseModule {
|
||||
this.bindMethods([
|
||||
'schedule',
|
||||
'fastForward',
|
||||
'fastForwardSequential',
|
||||
'clearAll',
|
||||
'setSpeed',
|
||||
'beginFastForward',
|
||||
@@ -216,6 +217,54 @@ class AnimationQueueModule extends BaseModule {
|
||||
// Use parent's dispatchEvent method
|
||||
this.dispatchEvent('ui:animation:fastforward', { state: false });
|
||||
}
|
||||
|
||||
fastForwardSequential(maxDuration = 320) {
|
||||
if (this.timeoutQueue.length === 0) {
|
||||
console.log('AnimationQueue: No animations to fast forward sequentially');
|
||||
return;
|
||||
}
|
||||
|
||||
const now = Date.now();
|
||||
const pending = this.timeoutQueue
|
||||
.filter(timeout => !timeout.executed)
|
||||
.map(timeout => {
|
||||
if (timeout.timeoutId !== null) {
|
||||
clearTimeout(timeout.timeoutId);
|
||||
timeout.timeoutId = null;
|
||||
}
|
||||
const remaining = Math.max(0, (timeout.startTime + timeout.delay) - now);
|
||||
return { timeout, remaining };
|
||||
})
|
||||
.sort((left, right) => left.remaining - right.remaining);
|
||||
|
||||
if (pending.length === 0) {
|
||||
this.timeoutQueue = [];
|
||||
this.endFastForward();
|
||||
this.emitAnimationComplete();
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`AnimationQueue: Fast forwarding ${pending.length} pending items sequentially`);
|
||||
this.beginFastForward();
|
||||
|
||||
const maxRemaining = Math.max(1, ...pending.map(item => item.remaining));
|
||||
const compressedDuration = Math.max(80, Number(maxDuration) || 320);
|
||||
|
||||
pending.forEach(({ timeout, remaining }) => {
|
||||
timeout.timeoutId = setTimeout(() => {
|
||||
timeout.execute();
|
||||
const index = this.timeoutQueue.indexOf(timeout);
|
||||
if (index !== -1) {
|
||||
this.timeoutQueue.splice(index, 1);
|
||||
}
|
||||
if (this.timeoutQueue.length === 0) {
|
||||
this.delay = 0;
|
||||
this.endFastForward();
|
||||
this.emitAnimationComplete();
|
||||
}
|
||||
}, Math.round((remaining / maxRemaining) * compressedDuration));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Begin fast forwarding mode
|
||||
|
||||
Reference in New Issue
Block a user