I want to create a glowing animation for my button and my image. I want to know is there a react native animation I can use to achieve this glowing effect. I have this css style, but I don't think it would work with react native. Any thoughts on how I can do this for a button or image in react-native or react.js?
.glow {
font-size: 80px;
color: #fff;
text-align: center;
-webkit-animation: glow 1s ease-in-out infinite alternate;
-moz-animation: glow 1s ease-in-out infinite alternate;
animation: glow 1s ease-in-out infinite alternate;
}
@-webkit-keyframes glow {
from {
text-shadow: 0 0 10px #fff, 0 0 20px #fff, 0 0 30px #e60073, 0 0 40px #e60073, 0 0 50px #e60073, 0 0 60px #e60073, 0 0 70px #e60073;
}
to {
text-shadow: 0 0 20px #fff, 0 0 30px #ff4da6, 0 0 40px #ff4da6, 0 0 50px #ff4da6, 0 0 60px #ff4da6, 0 0 70px #ff4da6, 0 0 80px #ff4da6;
}
}
I want to create a glowing animation for my button and my image. I want to know is there a react native animation I can use to achieve this glowing effect. I have this css style, but I don't think it would work with react native. Any thoughts on how I can do this for a button or image in react-native or react.js?
.glow {
font-size: 80px;
color: #fff;
text-align: center;
-webkit-animation: glow 1s ease-in-out infinite alternate;
-moz-animation: glow 1s ease-in-out infinite alternate;
animation: glow 1s ease-in-out infinite alternate;
}
@-webkit-keyframes glow {
from {
text-shadow: 0 0 10px #fff, 0 0 20px #fff, 0 0 30px #e60073, 0 0 40px #e60073, 0 0 50px #e60073, 0 0 60px #e60073, 0 0 70px #e60073;
}
to {
text-shadow: 0 0 20px #fff, 0 0 30px #ff4da6, 0 0 40px #ff4da6, 0 0 50px #ff4da6, 0 0 60px #ff4da6, 0 0 70px #ff4da6, 0 0 80px #ff4da6;
}
}
Share
Improve this question
asked Jun 10, 2019 at 18:19
MasteroluMasterolu
4712 gold badges9 silver badges20 bronze badges
1
- Let me know if you find anything :-) – Sopo Commented Aug 13, 2019 at 14:58
1 Answer
Reset to default 2I think that using keyframes in react native is not available, so I implemented my own solution:
this.state = {
isBlinking: false
};
this.blinkingInterval = false;
ponentWillUnmount() {
clearInterval(this.blinkingInterval);
this.blinkingInterval = false;
}
ponentDidMount() {
if (!this.blinkingInterval) {
this.blinkingInterval = setInterval(() => {
this.setState({
isBlinking: !this.state.isBlinking
});
}, 800);
}
}
In Render:
<Text style={this.state.isBlinking && styles.textGlowing}>Hello World</Text>
In the css file:
textGlowing: {
textShadowColor: 'rgba(0, 0, 0, 0.75)',
textShadowOffset: {width: -1, height: 1},
textShadowRadius: 15
}