Skip to content

Instantly share code, notes, and snippets.

@ShaileshPrajapati-BTC
Created April 25, 2018 11:15
Show Gist options
  • Save ShaileshPrajapati-BTC/8f6e25bcef4e2b397d88b1a56b43df51 to your computer and use it in GitHub Desktop.
Save ShaileshPrajapati-BTC/8f6e25bcef4e2b397d88b1a56b43df51 to your computer and use it in GitHub Desktop.
import React,{Component} from 'react';
import {
Animated,
Easing
} from 'react-native';
export default class Pulse extends Component {
constructor(props) {
super(props);
this.pulseValue = new Animated.Value(0)
}
componentDidMount() {
this.pulseAnimation();
}
pulseAnimation(){
this.pulseValue.setValue(0)
Animated.timing(this.pulseValue, {
toValue: 1,
duration: 3000,
easing: Easing.in
})
.start(this.pulseAnimation.bind(this));
}
render() {
const pulseSize = this.props.pulseSize || 250
return (
<Animated.View
style={{
position: 'absolute',
backgroundColor:'#7f7f7f',
width: this.pulseValue.interpolate({
inputRange: [0, 1],
outputRange: [100, pulseSize]
}),
height: this.pulseValue.interpolate({
inputRange: [0, 1],
outputRange: [100, pulseSize]
}),
borderRadius: pulseSize/2,
opacity: this.pulseValue.interpolate({
inputRange: [0, 1],
outputRange: [1, 0]
})
}}
/>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment