首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >LayoutAnimation与功能组件一起工作吗

LayoutAnimation与功能组件一起工作吗
EN

Stack Overflow用户
提问于 2022-03-22 10:49:55
回答 1查看 124关注 0票数 0

我正在开发一个使用类组件的本机应用程序。类组件使我能够只用4行代码动画:

代码语言:javascript
运行
复制
componentWillUpdate() {
   UIManager.setLayoutAnimationEnabledExperimental && UIManager.setLayoutAnimationEnabledExperimental(true);
   LayoutAnimation.easeInEaseOut();
}

现在,不再推荐类组件使用react,而不再推荐使用功能性组件。我想知道如何在功能组件中实现与上面的代码相同的动画?

EN

回答 1

Stack Overflow用户

发布于 2022-03-22 10:58:42

尝尝这个,

代码语言:javascript
运行
复制
import {LayoutAnimation, Platform, UIManager} from 'react-native';

if (Platform.OS === 'android') {
  UIManager.setLayoutAnimationEnabledExperimental &&
    UIManager.setLayoutAnimationEnabledExperimental(true);
}

const setAnimation = () => {
        LayoutAnimation.configureNext({
            duration: 250,
            update: {
                type: LayoutAnimation.Types.easeInEaseOut,
                springDamping: 0.7,
            },
        });
        LayoutAnimation.configureNext({
            duration: 500,
            create: {
                type: LayoutAnimation.Types.easeInEaseOut,
                property: LayoutAnimation.Properties.scaleXY,
                springDamping: 0.7,
            },
        });
    };
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71570784

复制
相关文章

相似问题

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