Skip to content

Commit 719d97a

Browse files
committed
update LottieRefreshControl
1 parent 1ae43c7 commit 719d97a

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

Example/LottieRefreshControl.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,18 @@ export default class LottieRefreshControl extends Component {
2020
_onRefresh = () => {
2121
let {onRefresh} = this.props;
2222
onRefresh && onRefresh();
23+
this.lottieView.play(this.state.scale.__getValue())
24+
2325
}
2426
finishRefresh=(params)=>{
25-
this._refreshc && this._refreshc.finishRefresh(params)
27+
this._refreshc && this._refreshc.finishRefresh(params);
28+
this.lottieView.reset();
2629
}
2730
_onHeaderMoving=(event)=>{
28-
this.state.scale.setValue(event.nativeEvent.percent);
31+
let {percent} = event.nativeEvent;
32+
if(percent<=1) {
33+
this.state.scale.setValue(event.nativeEvent.percent);
34+
}
2935
}
3036
render() {
3137
return (
@@ -44,7 +50,7 @@ export default class LottieRefreshControl extends Component {
4450
outputRange: [0.1,1,1],
4551
})
4652
}]}}>
47-
<LottieView style={{width:100,height:100}} hardwareAccelerationAndroid autoPlay source={require('./loop.json')} speed={1.5} />
53+
<LottieView speed={2} ref={obj =>this.lottieView = obj} style={{width:100,height:100}} hardwareAccelerationAndroid progress={this.state.scale} source={require('./cycle_animation.json')} />
4854
</Animated.View>
4955
</AnyHeader>
5056
}

Example/cycle_animation.json

+1
Large diffs are not rendered by default.

Example/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"test": "jest"
88
},
99
"dependencies": {
10-
"lottie-react-native": "^2.5.6",
10+
"lottie-react-native": "^2.5.8",
1111
"react": "16.3.1",
1212
"react-native": "0.55.4",
1313
"react-native-indicators": "^0.13.0",

Example/yarn.lock

+3-3
Original file line numberDiff line numberDiff line change
@@ -3327,9 +3327,9 @@ lottie-ios@^2.5.0:
33273327
version "2.5.0"
33283328
resolved "https://registry.npmjs.org/lottie-ios/-/lottie-ios-2.5.0.tgz#55c808e785d4a6933b0c10b395530b17098b05de"
33293329

3330-
lottie-react-native@^2.5.6:
3331-
version "2.5.6"
3332-
resolved "https://registry.npmjs.org/lottie-react-native/-/lottie-react-native-2.5.6.tgz#c5ad64a880108d50c728505ede10470a109c6e70"
3330+
lottie-react-native@^2.5.8:
3331+
version "2.5.8"
3332+
resolved "https://registry.npmjs.org/lottie-react-native/-/lottie-react-native-2.5.8.tgz#8599a077f4071f01d5e5215bcf50a3a8e67e7bc9"
33333333
dependencies:
33343334
invariant "^2.2.2"
33353335
lottie-ios "^2.5.0"

0 commit comments

Comments
 (0)