首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何处理反应自然状态下的动画时序

如何处理反应自然状态下的动画时序
EN

Stack Overflow用户
提问于 2020-02-24 14:11:23
回答 2查看 1.7K关注 0票数 1

我试图在按下TouchableOpacity组件时增加视图的高度,但它不起作用。我做错什么了?我应该使用lifeCycle组件吗?

代码语言:javascript
复制
import * as React from "react";
import {
  View
} from "react-native";
import * as Animatable from "react-native-animatable";
import Animated from "react-native-reanimated";

const Screen_Height = Dimensions.get("window").height;

class RegistrationView extends React.Component {
  state = {
    registrationHeight: new Animated.Value(150),
  };

  increaseHeight = () => {
      Animated.timing(this.state.registrationHeight, {
      toValue: Screen_Height,
      duration: 500
    }).start();
  };

 render() {
    return (
<Animated.View
            style={{
              height: this.state.registrationHeight
            }}
          >
<TouchableOpacity onPress={() => this.increaseHeight()}>
              <View>
                <Text>
                  Welcome, press here.
                </Text>
              </View>
</TouchableOpacity>
 </Animated.View>
)
}

我知道这个错误:

** TypeError: config.easing不是函数。(在'config.easing((0,base.divide)(newFrameTime,config.duration)‘)中,'config.easing’是未定义的) **

EN

回答 2

Stack Overflow用户

发布于 2020-02-24 19:59:16

解决了,问题是导入模块,我应该做:**导入{动画}从“反应-本机”;不:**导入动画从“反应-本机-恢复”;

票数 5
EN

Stack Overflow用户

发布于 2020-02-24 14:56:43

如果您讨论的是您的TouchableOpacity视图,请尝试替换代码的这一部分:

代码语言:javascript
复制
<View>
  <Text>
    Welcome, press here.
  </Text>
</View>

在这方面:

代码语言:javascript
复制
<Animated.View style={{height: this.state.registrationHeight}}>
  <Text>
     Welcome, press here.
  </Text>
</Animated.View>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60377703

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档