Skip to content

Refactor AnimationToken for Cleaner Structure and Flexible Timing #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JaskRendix
Copy link
Contributor

@JaskRendix JaskRendix commented Jul 25, 2025

PR improves the AnimationToken class and related logic.

Here’s what’s changed:

  • replaced NamedTuple with @dataclass for AnimationFrame, this allows future extensibility and enforces immutability with frozen=True
  • refactored AnimationToken constructor and logic: cleaned up how frames are stored, removing unnecessary re-wrapping and simplified frame indexing using modulo arithmetic for looping
  • added loop flag, users can now choose whether the animation repeats or plays once
  • introduced done flag, signals when a non-looping animation is finished, preventing further advancement
  • created update() method, allows animations to self-update based on elapsed time, making frame progression consistent regardless of frame rate or lag
  • enhanced all docstrings, clear descriptions now explain purpose, parameters, return values, and behavior
  • preserved __slots__, keeps memory usage optimized while the class expands in capability
  • fixed typos, corrected "frames that compromise the animation" to "frames that comprise the animation"
  • added simple demo: revised to showcase frame-rate-independent updates using AnimationToken.update() and loop=True, creating smoother visual transitions
  • added group demo: refactored token creation and update flow to demonstrate parallel animations, using randomized positions and separated update/render cycles
  • resolved broken imports by updating pyproject.toml to include the pyscroll package explicitly, fixing editable installs and restoring demo functionality during development (split out in Cleanup legacy build files and add Makefile for tooling #71)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant