From db9863606143ca800982f978b8176e5668ff53bf Mon Sep 17 00:00:00 2001 From: Michele Bonazza Date: Mon, 12 Aug 2024 19:11:01 +0200 Subject: [PATCH 1/2] Support dynamic fillValue values --- src/SegmentedArc.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/SegmentedArc.js b/src/SegmentedArc.js index 6943794..2ecff66 100644 --- a/src/SegmentedArc.js +++ b/src/SegmentedArc.js @@ -131,13 +131,10 @@ export const SegmentedArc = ({ delay: animationDelay, useNativeDriver: false, easing: Easing.out(Easing.ease) - }).start(); - - const listenerId = arcAnimatedValue.addListener(e => { - if (e.value === lastFilledSegment.filled) animationRunning.current = false; + }).start(() => { + animationRunning.current = false; }); - return () => arcAnimatedValue.removeListener(listenerId); - }, []); + }, [lastFilledSegment.filled]); if (arcs.length === 0) { return null; From 0c692ddcd958697577df923f25d67cbaf9d824b7 Mon Sep 17 00:00:00 2001 From: Michele Bonazza Date: Tue, 13 Aug 2024 09:03:48 +0200 Subject: [PATCH 2/2] Fix segment filledColor on animation --- src/components/Segment.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/components/Segment.js b/src/components/Segment.js index 0691a4d..c64f668 100644 --- a/src/components/Segment.js +++ b/src/components/Segment.js @@ -12,20 +12,17 @@ export const Segment = ({ arc }) => { const { filledArcWidth, radius, isAnimated, emptyArcWidth, arcAnimatedValue } = segmentedArcContext; const arcRef = useRef(); - const animationComplete = useRef(false); useEffect(() => { if (!isAnimated) return; const listener = arcAnimatedValue.addListener(v => { if (!arcRef.current) return; - if (animationComplete.current) return; if (v.value <= arc.start) return; if (v.value >= arc.end) { arcRef.current.setNativeProps({ d: drawArc(arc.centerX, arc.centerY, radius, arc.start, arc.end) }); - animationComplete.current = true; } else { arcRef.current.setNativeProps({ d: drawArc(arc.centerX, arc.centerY, radius, arc.start, v.value)