Skip to content

fix: prevent anchor drift when animations complete with an onFinished callback#47

Merged
Xerrion merged 3 commits intomasterfrom
copilot/fix-animation-frame-queue
Feb 24, 2026
Merged

fix: prevent anchor drift when animations complete with an onFinished callback#47
Xerrion merged 3 commits intomasterfrom
copilot/fix-animation-frame-queue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 24, 2026

When a queued animation completed, its state was cleared before the onFinished callback fired. The next Animate() call inside the callback found no active state, skipped Stop(), and called frame:GetPoint() while the frame was still at its final translated position — baking the translation offset into the new anchor. Each queue entry compounded the drift, causing frames to stack.

Changes

  • LibAnimate.lua — completion handler: Defer lib.activeAnimations[frame] = nil until after onFinished fires for frames that have a callback.
    • Frames without a callback are still cleared immediately (no behaviour change).
    • After the callback returns, the state is cleared only if the callback did not start a new animation (identity check: activeAnimations[frame] == state).

Keeping the completed state alive during the callback means Animate() → Stop() finds it, restores the frame to state.anchorX/Y, and frame:GetPoint() captures the correct base anchor.

-- Before: state wiped before callbacks fire
lib.activeAnimations[frame] = nil
-- ...fire callbacks (Stop() skipped, GetPoint() captures offset position)

-- After: state kept alive; Stop() inside callback restores base anchor first
-- ...fire callbacks (Stop() finds state, restores anchorX/Y correctly)
if lib.activeAnimations[cb.frame] == cb.state then
    lib.activeAnimations[cb.frame] = nil  -- clear only if callback didn't replace it
end

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • luarocks.org
    • Triggering command: /usr/bin/lua5.1 /usr/bin/lua5.1 /usr/bin/luarocks install luacheck (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Animation frames can get stuck on top of each other when queuing them too fast. Please find out where the problems are.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

… prevent anchor drift in queues

Co-authored-by: Xerrion <1850632+Xerrion@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix animation frames getting stuck on top of each other fix: prevent anchor drift when animations complete with an onFinished callback Feb 24, 2026
Copilot AI requested a review from Xerrion February 24, 2026 07:05
@Xerrion Xerrion marked this pull request as ready for review February 24, 2026 12:13
@Xerrion Xerrion merged commit e4a9d04 into master Feb 24, 2026
1 check passed
@Xerrion Xerrion deleted the copilot/fix-animation-frame-queue branch February 24, 2026 12:14
Xerrion pushed a commit that referenced this pull request Feb 24, 2026
🤖 I have created a release *beep* *boop*
---


## [3.5.5](3.5.4...3.5.5)
(2026-02-24)


### Bug Fixes

* apply initial keyframe immediately in Animate() to prevent frame
overlap ([#48](#48))
([b5ea1d2](b5ea1d2))
* harden callback safety, SlideAnchor guards, and easing validation
([#52](#52))
([bf71c6a](bf71c6a))
* prevent anchor drift when animations complete with an onFinished
callback ([#47](#47))
([e4a9d04](e4a9d04))


### Documentation

* add bug report and feature request issue templates
([#53](#53))
([ec638f6](ec638f6))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

2 participants