diff --git a/Examples/AdvancedEffects/src/Banner.js b/Examples/AdvancedEffects/src/Banner.js index 8f412882cd54f98a6ec7f238ed80dfd43428eff0..b442f6cc9ded43dab64ebccf352d5754d3351169 100644 --- a/Examples/AdvancedEffects/src/Banner.js +++ b/Examples/AdvancedEffects/src/Banner.js @@ -30,7 +30,7 @@ class Banner extends React.Component { return console.log("Banner onLoad")} onProgress={e => console.log("Banner onProgress", e.nativeEvent)}> - + ; } } diff --git a/Examples/Simple/src/AnimatedHelloGL.js b/Examples/Simple/src/AnimatedHelloGL.js index c87b0d783e0ba21323893f3cfbfbf41eba817a71..8bb2a523af2590ded11a2a8be6d7b66ed6de7e5f 100644 --- a/Examples/Simple/src/AnimatedHelloGL.js +++ b/Examples/Simple/src/AnimatedHelloGL.js @@ -1,6 +1,7 @@ const React = require("react-native"); const GL = require("gl-react"); const {Surface} = require("gl-react-native"); +const {Animated} = React; const shaders = GL.Shaders.create({ helloGL: { @@ -21,20 +22,15 @@ class HelloGL extends React.Component { constructor (props) { super(props); this.state = { - value: 0 + value: new Animated.Value(0) }; } componentDidMount () { - const loop = time => { - this.raf = requestAnimationFrame(loop); - this.setState({ - value: (1 + Math.cos(time / 1000)) / 2 // cycle between 0 and 1 - }); - }; - this.raf = requestAnimationFrame(loop); - } - componentWillUnmount () { - cancelAnimationFrame(this.raf); + const loop = () => Animated.sequence([ + Animated.timing(this.state.value, { toValue: 1, duration: 1000 }), + Animated.timing(this.state.value, { toValue: 0, duration: 1000 }) + ]).start(loop); + loop(); } render () { const { width, height } = this.props;