Skip to content

Commit

Permalink
Support onCompleted callback
Browse files Browse the repository at this point in the history
  • Loading branch information
muh-hamada authored Apr 4, 2021
1 parent c8b36b3 commit b286c04
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions components/AnimatedSVGPath/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class AnimatedSVGPath extends Component {
transform: PropTypes.string,
reverse: PropTypes.bool,
rewind: PropTypes.bool,
onCompleted: PropTypes.any,
};

static defaultProps = {
Expand Down Expand Up @@ -59,6 +60,7 @@ class AnimatedSVGPath extends Component {
easing = Easing["linear"],
reverse,
rewind,
onCompleted,
} = this.props;
this.strokeDashoffset.setValue(!reverse ? this.length : 0);
const animationsSequence = [].concat(
Expand All @@ -84,6 +86,8 @@ class AnimatedSVGPath extends Component {
);

Animated.sequence(animationsSequence).start(() => {
if (typeof onCompleted === 'function') onCompleted();

if (loop) {
this.animate();
}
Expand Down

0 comments on commit b286c04

Please sign in to comment.