Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/ui/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@
turnNumber = -1;
el: HTMLElement;
eventHandlers: QueueEventHandlers = {};
protected prevX = 0;

getHash() {
return 'none';
Expand All @@ -239,6 +240,7 @@

insert(containerElement: HTMLElement, queuePosition: number, x: number) {
this.queuePosition = queuePosition;
this.prevX = x;
if (this.el) {
this.el.remove();
}
Expand Down Expand Up @@ -297,12 +299,25 @@
}

animateUpdate(queuePosition: number, x: number) {
const keyframes = [{ transform: `translateX(${x}px) translateY(0px) scale(1)` }];
// Detect significant backward movement (e.g., when a creature is delayed and
// moves from the active section to the delayed section in the queue).
// The jump animation makes this position change more intuitive for the player.
const JUMP_THRESHOLD = 80; // more than one vignette width = likely a delay move
const isJump = this.prevX - x > JUMP_THRESHOLD;
const keyframes = isJump
? [
// Start at current position (prevX), arc upward then down to new position
{ transform: `translateX(${this.prevX}px) translateY(0px) scale(1)`, easing: 'ease-out' },
{ transform: `translateX(${(this.prevX + x) / 2}px) translateY(-60px) scale(1)`, easing: 'ease-in-out', offset: 0.4 },

Check failure on line 311 in src/ui/queue.ts

View workflow job for this annotation

GitHub Actions / test

Replace `·transform:·`translateX(${(this.prevX·+·x)·/·2}px)·translateY(-60px)·scale(1)`,·easing:·'ease-in-out',·offset:·0.4·` with `⏎↹↹↹↹↹↹transform:·`translateX(${(this.prevX·+·x)·/·2}px)·translateY(-60px)·scale(1)`,⏎↹↹↹↹↹↹easing:·'ease-in-out',⏎↹↹↹↹↹↹offset:·0.4,⏎↹↹↹↹↹`
{ transform: `translateX(${x}px) translateY(0px) scale(1)` },
]

Check failure on line 313 in src/ui/queue.ts

View workflow job for this annotation

GitHub Actions / test

Replace `↹` with `··`
: [{ transform: `translateX(${x}px) translateY(0px) scale(1)` }];
const animation = this.el.animate(keyframes, {
duration: CONST.animDurationMS,
duration: isJump ? CONST.animDurationMS + 150 : CONST.animDurationMS,
fill: 'forwards',
});
animation.commitStyles();
this.prevX = x;
return animation;
}

Expand Down
Loading