Skip to content

Commit c319d2f

Browse files
committed
update LottieRefreshControl
1 parent d273953 commit c319d2f

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

Example/LottieRefreshControl.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,40 @@ import {
1212
import PropTypes from 'prop-types';
1313
import LottieView from 'lottie-react-native'
1414
import {SmartRefreshControl, AnyHeader} from 'react-native-smartrefreshlayout';
15-
import Icon from 'react-native-vector-icons/Ionicons';
16-
import {SkypeIndicator} from 'react-native-indicators';
1715

18-
const AnimatedIcon = Animated.createAnimatedComponent(Icon);
1916
export default class LottieRefreshControl extends Component {
17+
state = {
18+
scale: new Animated.Value(0.1)
19+
}
2020
_onRefresh = () => {
2121
let {onRefresh} = this.props;
2222
onRefresh && onRefresh();
2323
}
2424
finishRefresh=(params)=>{
2525
this._refreshc && this._refreshc.finishRefresh(params)
2626
}
27+
_onHeaderMoving=(event)=>{
28+
this.state.scale.setValue(event.nativeEvent.percent);
29+
}
2730
render() {
2831
return (
2932
<SmartRefreshControl
33+
onHeaderMoving={this._onHeaderMoving}
3034
style={{flex:1}}
3135
ref={ref => this._refreshc = ref}
3236
children={this.props.children}
3337
onRefresh={this._onRefresh}
3438
headerHeight={100}
3539
HeaderComponent={
36-
<AnyHeader style={{height:100,justifyContent:'center',alignItems:'center'}}>
40+
<AnyHeader>
41+
<Animated.View style={{height:100,justifyContent:'center',alignItems:'center',transform: [{
42+
scale:this.state.scale.interpolate({
43+
inputRange: [0,1,2],
44+
outputRange: [0.1,1,1],
45+
})
46+
}]}}>
3747
<LottieView style={{width:100,height:100}} hardwareAccelerationAndroid autoPlay source={require('./loop.json')} speed={1.5} />
48+
</Animated.View>
3849
</AnyHeader>
3950
}
4051
/>

0 commit comments

Comments
 (0)