Commit a78e1c71 authored by Gaëtan Renaudeau's avatar Gaëtan Renaudeau

simplify code

parent 0877cc44
import React, {Component} from "react"; import React, {Component} from "react";
import {View, Animated } from "react-native"; import {View, Animated} from "react-native";
import {AnimatedSurface} from "gl-react-native"; import {AnimatedSurface} from "gl-react-native";
import GL from "gl-react"; import GL from "gl-react";
import Dimensions from "Dimensions";
const { width: viewportW, height: viewportH } = Dimensions.get("window");
export default class Tests extends Component { export default class AnimatedExample extends Component {
state = { state = {
heightValue: new Animated.Value(200) heightValue: new Animated.Value(200),
}; };
componentWillMount () { componentWillMount () {
let i = 0; let i = 0;
this.interval = setInterval(() => { this.interval = setInterval(() =>
Animated.spring(this.state.heightValue, { Animated.spring(this.state.heightValue, {
toValue: ++i % 2 ? 500 : 200, toValue: ++i % 2 ? 500 : 200,
}).start(); }).start(), 1000);
}, 1000);
} }
componentWillUnmount () { componentWillUnmount () {
clearInterval(this.interval); clearInterval(this.interval);
} }
render () { render () {
const { heightValue } = this.state; const { heightValue } = this.state;
return <View style={{ return <View style={{ paddingTop: 60, alignItems: "center" }}>
backgroundColor: "#000",
flex: 1,
paddingTop: 60,
alignItems: "center"
}}>
<AnimatedSurface <AnimatedSurface
width={200} width={200}
height={heightValue}> height={heightValue}>
<GL.Node shader={{ <GL.Node shader={{// inline example
frag: ` frag: `
precision highp float; precision highp float;
varying vec2 uv; varying vec2 uv;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment