From a78e1c71ab08ff8206b8a6d3b8a89f853f40521d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Sun, 12 Jun 2016 17:42:47 +0200 Subject: [PATCH] simplify code --- example/src/Animated/index.js | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/example/src/Animated/index.js b/example/src/Animated/index.js index 2c29673..3511a3b 100644 --- a/example/src/Animated/index.js +++ b/example/src/Animated/index.js @@ -1,37 +1,29 @@ import React, {Component} from "react"; -import {View, Animated } from "react-native"; +import {View, Animated} from "react-native"; import {AnimatedSurface} from "gl-react-native"; 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 = { - heightValue: new Animated.Value(200) + heightValue: new Animated.Value(200), }; componentWillMount () { let i = 0; - this.interval = setInterval(() => { + this.interval = setInterval(() => Animated.spring(this.state.heightValue, { toValue: ++i % 2 ? 500 : 200, - }).start(); - }, 1000); + }).start(), 1000); } componentWillUnmount () { clearInterval(this.interval); } render () { const { heightValue } = this.state; - return + return -