Skip to content

Commit 6508845

Browse files
authored
Support for progress props using Animated number (#20)
* Support for progress props using Animated number * Checking progress props Animated.Value + Update README
1 parent 97808dd commit 6508845

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ PRs are welcome!
3232

3333
The following important features are not implemented:
3434

35-
- `progress` prop
35+
- `progress` prop (partially implemented using Animated.Value)
3636
- imperative API

src/index.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,23 @@ class Animation extends PureComponent {
88

99
componentDidMount() {
1010
this.loadAnimation(this.props);
11+
12+
if (typeof this.props.progress === 'object' &&
13+
this.props.progress._listeners) {
14+
15+
this.props.progress.addListener((progress) => {
16+
const { value } = progress;
17+
let frame = value / (1 / this.anim.getDuration(true));
18+
this.anim.goToAndStop(frame, true);
19+
});
20+
}
21+
}
22+
23+
componentWillUnmount() {
24+
if (typeof this.props.progress === 'object' &&
25+
this.props.progress._listeners) {
26+
this.props.progress.removeAllListeners();
27+
}
1128
}
1229

1330
UNSAFE_componentWillReceiveProps(nextProps) {

0 commit comments

Comments
 (0)