Animation fix - support dynamic fillValue #141
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the segmented-arc animation pipeline so fillValue can be changed dynamically (including decreases) while keeping the cap/segments visually in sync, and adds a regression test to confirm the animation restarts on rerender.
Changes:
- Updates
Segmentto keep an animated path mounted for all segments and to update the path when the animated value moves below a segment’s start. - Updates
SegmentedArcto mark animations complete via thestart()callback and to re-run the animation effect when the filled angle changes. - Adds a test asserting
Animated.timingis re-invoked whenfillValuechanges.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/components/Segment.js |
Keeps animated segment paths mounted and updates path drawing logic for dynamic values. |
src/SegmentedArc.js |
Reworks the animation effect to re-run on filled-angle changes and clears the “running” flag on completion. |
src/__tests__/SegmentedArc.spec.js |
Adds a test verifying animation re-triggers when fillValue updates. |
Comments suppressed due to low confidence (1)
src/components/Segment.js:36
- Removing the previous “complete” guard means that once
v.valueexceedsarc.end, this listener will continue callingsetNativePropson every animation frame for the remainder of the overall animation (and for every segment that’s already complete). This can become a noticeable performance cost with multiple segments. Consider reintroducing a small ref-based guard (e.g., track whether this segment is currently complete and skip updates whilev.value >= arc.end, resetting whenv.valuedrops back belowarc.endfor reverse animations).
if (v.value >= arc.end) {
arcRef.current.setNativeProps({
d: drawArc(arc.centerX, arc.centerY, radius, arc.start, arc.end)
});
} else {
arcRef.current.setNativeProps({
d: drawArc(arc.centerX, arc.centerY, radius, arc.start, v.value)
});
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@jkhusanov I've opened a new pull request, #143, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
@jkhusanov I've opened a new pull request, #144, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
@jkhusanov I've opened a new pull request, #145, to work on those changes. Once the pull request is ready, I'll request review from you. |
* Initial plan * Fix animation race condition by cancelling in-flight animations Co-authored-by: jkhusanov <25942541+jkhusanov@users.noreply.github.com> * Add test for animation cancellation during updates Co-authored-by: jkhusanov <25942541+jkhusanov@users.noreply.github.com> * Properly handle animation reference cleanup after cancellation Co-authored-by: jkhusanov <25942541+jkhusanov@users.noreply.github.com> * Improve animation cleanup logic to prevent race conditions Co-authored-by: jkhusanov <25942541+jkhusanov@users.noreply.github.com> * Refine animation cleanup to prevent race conditions Co-authored-by: jkhusanov <25942541+jkhusanov@users.noreply.github.com> * Address final code review feedback Co-authored-by: jkhusanov <25942541+jkhusanov@users.noreply.github.com> * Clear animation reference in cleanup and improve test helper reusability Co-authored-by: jkhusanov <25942541+jkhusanov@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jkhusanov <25942541+jkhusanov@users.noreply.github.com>
* Bump tmp in /example in the npm_and_yarn group across 1 directory Bumps the npm_and_yarn group with 1 update in the /example directory: [tmp](https://github.com/raszi/node-tmp). Updates `tmp` from 0.2.3 to 0.2.4 - [Changelog](https://github.com/raszi/node-tmp/blob/master/CHANGELOG.md) - [Commits](raszi/node-tmp@v0.2.3...v0.2.4) --- updated-dependencies: - dependency-name: tmp dependency-version: 0.2.4 dependency-type: indirect dependency-group: npm_and_yarn ... Signed-off-by: dependabot[bot] <support@github.com> * Bump rexml in /example in the bundler group across 1 directory Bumps the bundler group with 1 update in the /example directory: [rexml](https://github.com/ruby/rexml). Updates `rexml` from 3.4.1 to 3.4.2 - [Release notes](https://github.com/ruby/rexml/releases) - [Changelog](https://github.com/ruby/rexml/blob/master/NEWS.md) - [Commits](ruby/rexml@v3.4.1...v3.4.2) --- updated-dependencies: - dependency-name: rexml dependency-version: 3.4.2 dependency-type: indirect dependency-group: bundler ... Signed-off-by: dependabot[bot] <support@github.com> * Bump the npm_and_yarn group across 1 directory with 2 updates Bumps the npm_and_yarn group with 2 updates in the /example directory: [lodash](https://github.com/lodash/lodash) and [node-forge](https://github.com/digitalbazaar/forge). Updates `lodash` from 4.17.21 to 4.17.23 - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](lodash/lodash@4.17.21...4.17.23) Updates `node-forge` from 1.3.1 to 1.3.3 - [Changelog](https://github.com/digitalbazaar/forge/blob/main/CHANGELOG.md) - [Commits](digitalbazaar/forge@v1.3.1...v1.3.3) --- updated-dependencies: - dependency-name: lodash dependency-version: 4.17.23 dependency-type: indirect dependency-group: npm_and_yarn - dependency-name: node-forge dependency-version: 1.3.3 dependency-type: indirect dependency-group: npm_and_yarn ... Signed-off-by: dependabot[bot] <support@github.com> * update dependecy to fix Vulnerability * update js-yaml * update on-headers' * Update on-headers in main dir * Update send * Update brace condition * Pod update * Make the example project run only local changes * Update example App to latest React Native version (#139) * Upgrade yarn to latest version (#140) * Upgrade yarn to latest version * Update node * CI changes * fix syntax * remove this * edit config * add orbs * simpler approach * use specific directory * Use new command * try this * try these * Bump the npm_and_yarn group across 2 directories with 2 updates (#146) Bumps the npm_and_yarn group with 2 updates in the / directory: [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser) and [minimatch](https://github.com/isaacs/minimatch). Bumps the npm_and_yarn group with 1 update in the /example directory: [minimatch](https://github.com/isaacs/minimatch). Updates `fast-xml-parser` from 4.5.0 to 4.5.3 - [Release notes](https://github.com/NaturalIntelligence/fast-xml-parser/releases) - [Changelog](https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/CHANGELOG.md) - [Commits](https://github.com/NaturalIntelligence/fast-xml-parser/commits) Updates `minimatch` from 3.1.2 to 3.1.3 - [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md) - [Commits](isaacs/minimatch@v3.1.2...v3.1.3) Updates `minimatch` from 3.1.2 to 3.1.3 - [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md) - [Commits](isaacs/minimatch@v3.1.2...v3.1.3) --- updated-dependencies: - dependency-name: fast-xml-parser dependency-version: 4.5.3 dependency-type: indirect dependency-group: npm_and_yarn - dependency-name: minimatch dependency-version: 3.1.3 dependency-type: indirect dependency-group: npm_and_yarn - dependency-name: minimatch dependency-version: 3.1.3 dependency-type: indirect dependency-group: npm_and_yarn ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Animation fix - support dynamic fillValue (#141) * Support dynamic fill value * Fix segments animation when going back * Fix animation race condition for dynamic fillValue updates (#144) * Initial plan * Fix animation race condition by cancelling in-flight animations Co-authored-by: jkhusanov <25942541+jkhusanov@users.noreply.github.com> * Add test for animation cancellation during updates Co-authored-by: jkhusanov <25942541+jkhusanov@users.noreply.github.com> * Properly handle animation reference cleanup after cancellation Co-authored-by: jkhusanov <25942541+jkhusanov@users.noreply.github.com> * Improve animation cleanup logic to prevent race conditions Co-authored-by: jkhusanov <25942541+jkhusanov@users.noreply.github.com> * Refine animation cleanup to prevent race conditions Co-authored-by: jkhusanov <25942541+jkhusanov@users.noreply.github.com> * Address final code review feedback Co-authored-by: jkhusanov <25942541+jkhusanov@users.noreply.github.com> * Clear animation reference in cleanup and improve test helper reusability Co-authored-by: jkhusanov <25942541+jkhusanov@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jkhusanov <25942541+jkhusanov@users.noreply.github.com> --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> * Update codeownsers (#147) * Bump the npm_and_yarn group across 2 directories with 1 update (#148) Bumps the npm_and_yarn group with 1 update in the / directory: [minimatch](https://github.com/isaacs/minimatch). Bumps the npm_and_yarn group with 1 update in the /example directory: [minimatch](https://github.com/isaacs/minimatch). Updates `minimatch` from 3.1.3 to 3.1.5 - [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md) - [Commits](isaacs/minimatch@v3.1.3...v3.1.5) Updates `minimatch` from 3.1.3 to 3.1.5 - [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md) - [Commits](isaacs/minimatch@v3.1.3...v3.1.5) --- updated-dependencies: - dependency-name: minimatch dependency-version: 3.1.5 dependency-type: indirect dependency-group: npm_and_yarn - dependency-name: minimatch dependency-version: 3.1.5 dependency-type: indirect dependency-group: npm_and_yarn ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump the npm_and_yarn group across 2 directories with 1 update (#149) Bumps the npm_and_yarn group with 1 update in the / directory: [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser). Bumps the npm_and_yarn group with 1 update in the /example directory: [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser). Updates `fast-xml-parser` from 4.5.3 to 4.5.4 - [Release notes](https://github.com/NaturalIntelligence/fast-xml-parser/releases) - [Changelog](https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/CHANGELOG.md) - [Commits](NaturalIntelligence/fast-xml-parser@v4.5.3...v4.5.4) Updates `fast-xml-parser` from 4.5.3 to 4.5.4 - [Release notes](https://github.com/NaturalIntelligence/fast-xml-parser/releases) - [Changelog](https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/CHANGELOG.md) - [Commits](NaturalIntelligence/fast-xml-parser@v4.5.3...v4.5.4) --- updated-dependencies: - dependency-name: fast-xml-parser dependency-version: 4.5.4 dependency-type: indirect dependency-group: npm_and_yarn - dependency-name: fast-xml-parser dependency-version: 4.5.4 dependency-type: indirect dependency-group: npm_and_yarn ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Update dependencies to resolve Dependabot alerts (#150) * Update minmatch dependency (#151) * Bump version (#153) --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
It addresses the issue #103, the solution is inspired by #104, and further improved to fix animation back when fillValue is set to a lower value than the original, as reported as a comment in that PR.
Randomly changing fillValue on press:
Screen.Recording.2026-02-17.at.5.36.08.PM.mov