Skip to content

Commit

Permalink
Resume animations after unpausing
Browse files Browse the repository at this point in the history
  • Loading branch information
amyjko committed Dec 1, 2024
1 parent 9e72215 commit 4327c7d
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 21 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
We'll note all notable changes in this file, including bug fixes, enhancements, and all closed issues.
Dates are in `YYYY-MM-DD` format and versions are in [semantic versioning](http://semver.org/) format.

## 0.13.1 2024-11-30

### Fixed

- Resume animations after unpausing
- Fixed $effect cycle in palette
- Fixed label ids on palette

## 0.13.0 2024-11-02

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wordplay",
"version": "0.13",
"version": "0.13.1",
"scripts": {
"postinstall": "run-script-os",
"postinstall:default": "svelte-kit sync && cp .env.template .env",
Expand Down Expand Up @@ -101,4 +101,4 @@
"defaults",
"not op_mini all"
]
}
}
51 changes: 32 additions & 19 deletions src/components/output/StageView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -189,29 +189,42 @@
}
});
function resetAnimator() {
if (animator !== undefined) animator.stop();
// Make a new one.
animator = new Animator(
evaluator,
// When output exits, remove it from the map and triggering a render so that its removed from stage.
(name) => {
// Remember that we exited this name.
recentlyExited.add(name);
if (exiting.has(name)) exiting.delete(name);
},
// When the animating poses or sequences on stage change, update the store
(nodes) => {
// Update the set of animated nodes.
if (interactive && animatingNodes)
animatingNodes.set(new Set(nodes));
},
);
}
// When the evaluator changes, stop the animator and create a new animator for the new evaluator.
$effect(() => {
evaluator;
// Previous scene? Stop it.
untrack(() => {
if (animator !== undefined) animator.stop();
// Make a new one.
animator = new Animator(
evaluator,
// When output exits, remove it from the map and triggering a render so that its removed from stage.
(name) => {
// Remember that we exited this name.
recentlyExited.add(name);
if (exiting.has(name)) exiting.delete(name);
},
// When the animating poses or sequences on stage change, update the store
(nodes) => {
// Update the set of animated nodes.
if (interactive && animatingNodes)
animatingNodes.set(new Set(nodes));
},
);
});
untrack(() => resetAnimator());
});
// Stop or When the evaluator is playing but the animator is stopped, create a new animator.
$effect(() => {
if (animator) {
if ($evaluation.playing) {
if (animator.isStopped()) untrack(() => resetAnimator());
} else {
animator.stop();
}
}
});
let context = $derived(
Expand Down
4 changes: 4 additions & 0 deletions src/output/Animator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ export default class Animator {
this.physics = new Physics(evaluator);
}

isStopped() {
return this.stopped;
}

/**
* When any of the following inputs change, update the stage accordingly so that the
* rendered screen reflects it.
Expand Down

0 comments on commit 4327c7d

Please sign in to comment.