From dfb26367006949bdf062411aaa20a38f2ec30825 Mon Sep 17 00:00:00 2001 From: Patryk Niedźwiedziński Date: Tue, 9 Feb 2021 17:31:37 +0100 Subject: Some shit happens no idea how --- .envrc | 1 + App.js | 136 +++++++++++++++++++++++++++++++++++++++++++++++++++++++------- shell.nix | 7 ++++ 3 files changed, 130 insertions(+), 14 deletions(-) create mode 100644 .envrc create mode 100644 shell.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..1d953f4 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use nix diff --git a/App.js b/App.js index 181f3ce..06d204f 100644 --- a/App.js +++ b/App.js @@ -1,21 +1,129 @@ -import { StatusBar } from 'expo-status-bar'; -import React from 'react'; -import { StyleSheet, Text, View } from 'react-native'; - -export default function App() { - return ( - - Open up App.js to start working on your app! - - - ); +import React, { Component } from "react"; +import { Animated, Text, View, StyleSheet, Button } from "react-native"; + +const force0 = 10; // px/ms +const alpha = 89 * (Math.PI / 180); +const g = .1; +const t = 2000; + +class App extends Component { + // fadeAnim will be used as the value for opacity. Initial Value: 0 + state = { + yAnim: new Animated.Value(0), + xAnim: new Animated.Value(0), + v: new Animated.Value(force0 * Math.sin(alpha)) + }; + + fadeIn = () => { + // move in x-axis + const vx = force0 * Math.cos(alpha); + Animated.timing(this.state.xAnim, { + toValue: vx * t, + duration: t, + useNativeDriver:true, + }).start(); + + // move in y-axis + Animated.timing(this.state.v, { + toValue: force0 * Math.sin(alpha) - g/2*t, + duration: t, + useNativeDriver: true, + }).start(); + Animated.timing(this.state.yAnim, { + toValue: Animated.multiply(this.state.v, t), + duration: t, + useNativeDriver: true, + }).start(); + }; + + //funkcja ustawiajÄ…ca zmianÄ™ wartoÅ›ci stanu fadeAnim z bieżącej na 0 w ciÄ…gu 5s i startujÄ…ca tÄ… zmianÄ™ + fadeOut = () => { + // Will change fadeAnim value to 0 in 5 seconds + Animated.timing(this.state.xAnim, { + toValue: -150, + duration: t, + useNativeDriver:true, + }).start(); + Animated.timing(this.state.yAnim, { + toValue: 0, + duration: t, + useNativeDriver:true, + }).start(); + Animated.timing(this.state.v, { toValue: force0 * Math.sin(alpha), duration: t }) + }; + + //funkcja ustawiajÄ…ca zmianÄ™ wartoÅ›ci stanu fadeAnim z bieżącej na 0 w ciÄ…gu 5s i startujÄ…ca tÄ… zmianÄ™ + fadeStop = () => { + Animated.timing(this.state.xAnim).stop(); + Animated.timing(this.state.yAnim).stop(); + }; + + + render() { + return ( + + + {/*komponent animacyjny*/} + + + + + + {/*komponent statyczny*/} + +