react动画库

Animations are important in instances like page transitions, scroll events, entering and exiting components, and events that the user should be alerted to.

动画在诸如页面过渡,滚动事件,进入和退出组件以及应提醒用户的事件之类的实例中很重要。

In this article, we’ll take a look at 5 React animation libraries that can be integrated with React for interactive and attractive web pages.

在本文中,我们将研究5个React动画库,这些库可以与React集成在一起,以生成交互式且吸引人的网页。

0.建立自己的动画库 (0. Building Your Own Animation Library)

Building your own animations or even just composing animations out of existing libraries is something you should definitely try for yourself. It doesn’t have to be a complete ‘component library project’. Whenever you build a component you think you or your team may want to use in the future, simply publish it to Bit.dev.

一定要自己尝试制作自己的动画,甚至只是从现有库中合成动画。 它不必是完整的“组件库项目”。 每当您构建组件时,您认为您或您的团队将来可能希望使用,只需将其发布到Bit.dev即可

Once a component gets published to Bit.dev, it gets automatically documented (if you’re using prop-types or TypeScript). In addition, you can add your own example code snippets that would get rendered for you, on the component page.

组件一旦发布到Bit.dev ,它就会被自动记录(如果您使用的是prop-types或TypeScript)。 此外,您可以在组件页面上添加自己的示例代码片段,这些片段将为您呈现。

It’s quite simply a good way to gradually build your own shareable collection of reusable React components.

这是逐步构建自己的可重用React组件的共享集合的一种好方法。

Example: exploring React components published on Bit.dev
示例:浏览发布在Bit.dev上的React组件

1.React过渡小组 (1. React Transition Group)

React Transition Group is a comprehensive animation library with 7.1k Github stars. It has four components that display transitions from one component state to another using a declarative API used for mounting and unmounting of components:

React Transition Group是一个拥有7.1k Github星星的综合动画库。 它具有四个组件,这些组件使用用于安装和卸载组件的声明性API显示从一个组件状态到另一组件状态的转换:

1. Transition

1.过渡

2. CSSTransition

2. CSSTransition

3. SwitchTransition

3. SwitchTransition

4. TransitionGroup

4. TransitionGroup

Let’s see how transition components can be used to create the following type of transitions:

让我们看看如何使用过渡组件创建以下类型的过渡:

• ‘entering’

•“进入”

• ‘entered’

•“进入”

• ‘exiting’

•“退出”

• ‘exited’

•“退出”

To use the react-transition-group, install it using npm or yarn:

要使用react-transition-group,请使用npm或yarn安装它:

# npm

#npm

# yarn

#纱

Let’s import the ‘Transition’ component from the ‘react-transition-group’ in to the App.js file.

让我们从“ react-transition-group”中将“ Transition”组件导入App.js文件。

Set the transition component using a timeout and allow the component to begin the “enter” stage by setting the transition to true. As the current component changes state from ‘entered’ to “entering” and back to “entered”, we will set the “.box-entered” and “.box-entering” CSS classes to create the appropriate changes.

使用超时设置过渡组件,并通过将过渡设置为true来允许该组件开始“进入”阶段。 当当前组件的状态从“已输入”更改为“已输入”,然后再回到“已输入”时,我们将设置“ .box-entered”和“ .box-entering” CSS类以创建适当的更改。

Set the keyframes that set the properties like position and color during the smooth transition.

设置关键帧,这些关键帧将设置平滑过渡期间的位置和颜色等属性。

2.React真棒揭示 (2. React Awesome Reveal)

This is a React component written in TypeScript, and it uses the Intersection Observer API to add reveal animations. The intersection API detects the element as it appears in the viewport. Internally, the animations are accelerated using Animation.css that uses the benefit of hardware acceleration.

这是一个用TypeScript编写的React组件,它使用Intersection Observer API添加显示动画。 相交API检测到视口中出现的元素。 在内部,使用Animation.css加速了动画,该动画利用了硬件加速的优势。

Here is an example of the Slide component using React Awesome Reveal.

这是使用React Awesome Reveal的Slide组件的示例。

Add the dependency of React Awesome Reveal as follows:

添加React Awesome Reveal的依赖项,如下所示:

using npm

使用npm

using yarn

用纱

Let’s import the Slide component from “react-awesome-reveal”. This animated component slides your content during the mounting of components.

让我们从“ react-awesome-reveal”中导入Slide组件。 这个动画组件会在组件安装期间滑动您的内容。

Use the Slide components with the content and allow it to slide in at once.

将“幻灯片”组件与内容一起使用,并使其一次滑入。

There are various other effects like cascade, damping, direction, and duration. It also allows you to chain multiple effects together.

还有其他各种效果,例如级联,阻尼,方向和持续时间。 它还允许您将多个效果链接在一起。

This is a quick example of chaining effects:

这是链接效果的快速示例:

3. Motion API (3. Motion API)

Motion API provides a simple animation, gesture API as a FrameX library, and maintains SVG and HTML semantics. Your highly animated prototypes are portable to a production-ready environment. It allows,

Motion API提供了一个简单的动画,手势API作为FrameX库,并维护SVG和HTML语义。 您动画效果极强的原型可移植到可用于生产环境中。 它允许

1) Animation: Animation is automatically done by using an animate prop.

1)动画:动画是通过使用动画道具自动完成的。

2) Gestures: Gestures like hover, tag, pan, and drag are supported as the React event system is extended.

2)手势:随着React事件系统的扩展,支持诸如悬停,标记,平移和拖动之类的手势。

3) Variants: Sub-tress is animated using a single animate prop. It also orchestrates these animations with options like “when” and “staggerChildren”.

3)变体:使用单个动画道具对子树进行动画处理。 它还使用“ when”和“ staggerChildren”等选项来编排这些动画。

4) Server-side Rendering: Server-side rendering is possible with flashes of restyled content.

4)服务器端渲染:可以通过重新样式化的内容的闪烁来实现服务器端渲染。

5) Motion values: This is used to create reactive chains of motion values that get updated during animations.

5)运动值:用于创建在动画过程中更新的运动值的React链。

6) Scroll-based Animations: Motion makes scroll-based or parallax animations easy.

6)基于滚动的动画:Motion使基于滚动或视差的动画变得容易。

Motion works with React 16.8 and later versions. Install framer-motion using npm.

Motion适用于React 16.8和更高版本。 使用npm安装framer-motion。

The official site is filled with examples. Let’s try out “AnimateSharedLayout” which allows the animation of different components sharing layout ID. Though it is in beta, you will be able to install it with the following command:

官方站点上有很多示例。 让我们尝试一下“ AnimateSharedLayout”,它允许不同组件的动画共享布局ID。 尽管它处于测试版,但是您可以使用以下命令进行安装:

Lets first create the data that needs to be displayed.

首先创建需要显示的数据。

Let’s animate the above data using motion and AnimatedSharedLayout from “framer-motion”.

让我们使用来自“ framer-motion”的运动和AnimatedSharedLayout为上述数据设置动画。

Along with the motion components, CSS plays an important role in animation. Check out the CSS file for this example.

CSS与运动组件一起在动画中起着重要作用。 请查看此示例CSS文件。

Example of Animated Shared Layout
动画共享版式示例

4.ReactTweenful: (4. React Tweenful:)

React Tweenful creates real-world animations for your pages. It uses SVG to perform animations for various shapes, colors, and sizes. React Tweenful includes features like:

React Tweenful为您的页面创建真实世界的动画。 它使用SVG来执行各种形状,颜色和大小的动画。 React Tweenful包括以下功能:

1. Looping: Works for a specific number or an infinite loop.

1.循环:适用于特定数字或无限循环。

2. Easing techniques: This is a classic animation that starts with a point to move naturally along a curve. It gives an option to predefined easing. Custom easing can also be performed with Bezier.

2.缓动技术:这是一种经典动画,其起始点是沿曲线自然移动。 它提供了预定义宽松的选项。 自定义缓动也可以使用Bezier执行。

3. Delayed animations: It is possible to set a delay to start and end the animation. You can also add a delay to current animations and events. In addition, it allows a negative delay that can mimic CSS animations.

3.延迟的动画:可以设置开始和结束动画的延迟。 您还可以向当前动画和事件添加延迟。 此外,它允许产生可以模拟CSS动画的负延迟。

4. Events support: Provides event support to manage animations.

4.事件支持:提供事件支持以管理动画。

5. Animations based on percent: Allows percentages for CSS animations.

5.基于百分比的动画:允许CSS动画的百分比。

6. A component called “Tweenful” is provided to animate the DOM. Using this component the DOM nodes are manipulated easily.

6.提供了一个名为“ Tweenful”的组件来为DOM制作动画。 使用此组件,可以轻松操纵DOM节点。

8. Animating SVG: To animation SVG nodes a specific SVG component is provided.

8.动画SVG:为动画SVG节点提供了特定的SVG组件。

9. Observer component: Supports Mounting and unmounting animations while the component is loading and unloading, with the Observer component.

9. Observer组件:支持使用Observer组件在组件加载和卸载时安装和卸载动画。

10. Handling child transitions during animations like removal of list or change of page requires observers. The ObserverGroup component handles child transitions during animations.

10.处理动画过程中的子过渡(例如删除列表或更改页面)需要观察者。 ObserverGroup组件处理动画期间的子过渡。

Now let’s look at an example of React Tweenful. Start by installing it using npm:

现在让我们看一下React Tweenful的示例。 首先使用npm安装它:

Then let’s download the zip folder for the repo and then navigate to src folder to get the required library file (In this example, we’re using Observer.js)

然后让我们下载的zip文件夹的回购 ,然后导航到src文件夹,以获得所需要的库文件(在这个例子中,我们使用Observer.js)

Let’s import it as follows:

让我们如下导入它:

Add the following props object to configure the animation.

添加以下props对象以配置动画。

Now let’s write our class.

现在让我们编写我们的课程。

This is where we add the object to be animated. The Observer and Tweentiful.div components will be placed inside the return statement of our App class:

这是我们要添加动画对象的地方。 Observer和Tweentiful.div组件将放置在我们的App类的return语句内:

That’s it. This is the result:

而已。 结果如下:

5. React运动 (5. React Motion)

This is a popular library for React. The animations created look natural and use physics concepts to provide a realistic feel.

这是React的流行库。 所创建的动画看起来自然,并使用物理概念提供逼真的感觉。

The demo provides various examples with varying levels of complexity. The community has provided a large set of live examples and demos of games, animations, transitions, and drawings along with many Youtube channels and tutorials.

该演示提供了具有不同复杂程度的各种示例。 该社区提供了大量的游戏,动画,过渡和绘图的实时示例和演示,以及许多Youtube频道和教程。

This library is an alternative to the react transition group. The API avoids using hard-coded values and durations to create animations. Hard-coding the values does not lead to smooth transitions when interrupted. To create realistic animations, React Motion uses the values of stiffness, damping, and precision during the animations. The effects are created using the below API.

该库是React过渡组的替代方法。 API避免使用硬编码的值和持续时间来创建动画。 硬编码值在中断时不会导致平滑过渡。 为了创建逼真的动画,React Motion在动画过程中使用刚度,阻尼和精度值。 使用以下API创建效果。

1) Spring: Spring is a function and defines the animation of destination value by setting stiffness and damping to the given value. Check the demo on how the values of stiffness and damping affect spring motion.

1) Spring :Spring是一个函数,它通过将刚度和阻尼设置为给定值来定义目标值的动画。 查看演示中有关刚度和阻尼值如何影响弹簧运动的演示。

2) Motion: To wrap any component wrap it around the motion and set up the props like spring functions and inline styling to animate it.

2)动作:要包裹任何组件,请将其包裹在动作周围,并设置诸如弹簧功能和内嵌样式的道具以对其进行动画处理。

3) Staggered Motion: This component sets the interpolated value of an item depending on the value of previous items. This motion is used for menu animation where the links stagger, but the position is dependent on the previous menu links.

3)交错运动:此组件根据先前项目的值设置项目的插值。 此动作用于菜单动画,其中链接交错,但位置取决于先前的菜单链接。

4) Transition Motion: Used during mounting and unmounting of items. For example, if you have three items and you would like to animate the third item while the component renders, you can use the TransitonMotion component by defining the key, data and style required for the animation.

4)过渡运动:在物品的装卸过程中使用。 例如,如果您有三个项目,并且想在组件渲染时为第三个项目设置动画,则可以通过定义动画所需的关键点,数据和样式来使用TransitonMotion组件。

Let’s look at an example using React Motion. We start by installing it via npm:

让我们来看一个使用React Motion的示例。 我们首先通过npm安装它:

We’ll be creating a ball that rolls away when we click on it. Import React Motion to your App.js file.

我们将创建一个单击时会滚开的球。 将React Motion导入您的App.js文件。

Now let’s write the css for our animation.

现在,让我们为动画编写CSS。

Add the following functions to handle what happens when we click on the ball:

添加以下函数来处理我们单击球时发生的情况:

This is the Motion component. It defines the object to be animated, in this case, it is the image of the ball.

这是运动组件。 它定义了要动画的对象,在这种情况下,它是球的图像。

This is how the result will look:

结果如下所示:

结论 (Conclusion)

We looked at five libraries for creating animations and transitions for your websites. Each of these offers a unique way of creating animations. Now all libraries work well with all scenarios and requirements. So it is important that you experiment with at least a few of them before selecting one.

我们研究了五个用于为您的网站创建动画和过渡的库。 每一种都提供了一种独特的动画制作方式。 现在,所有库都能很好地满足所有方案和要求。 因此,在选择一个之前,至少要对其中一些进行试验,这一点很重要。

学到更多 (Learn More)

翻译自: https://blog.bitsrc.io/react-animation-libraries-for-2020-437a21c73fed

react动画库


http://www.taodudu.cc/news/show-893914.html

相关文章:

  • 线框模型_进行计划之前:线框和模型
  • 工作经验教训_在设计工作五年后获得的经验教训
  • 中文排版规则_非设计师的5条排版规则
  • ux设计_声音建议:设计UX声音的快速指南
  • sans serif_Sans和Serif相遇可爱
  • sql 避免除0错误_设计简历时避免这3个常见的UX错误
  • 如何编写数据库可视化界面_编写用于数据可视化的替代文本
  • reloaddata 跳动_纸跳动像素
  • 利益相关者软件工程_改善开发人员团队与非技术利益相关者之间交流的方法
  • 响应式网格项目动画布局_响应式网格及其实际使用方式:常见的UI布局
  • 时间轴ui设计_我应该在UI设计上花更多时间吗?
  • 移动端分步注册_移动应用程序的可用性测试:分步指南
  • 插图 引用 同一行两个插图_提出食物主题中的插图
  • 脸部细微表情识别_您可以仅使用面部表情来控制字体吗?
  • 用户体验设计师能为seo做_用户体验设计师可以从产品设计历史中学到什么
  • orton效果_如何使图片发光:Orton效果
  • hp-ux锁定用户密码_UX设计101:用户研究-入门需要了解的一切
  • extjs6 引入ux_关于UX以及如何摆脱UX的6种常见误解
  • illustrator下载_Illustrator笔工具练习
  • 怎么更好练习数位板_如何设计更好的仪表板
  • hp-ux锁定用户密码_我们如何简化925移动应用程序的用户入门— UX案例研究
  • 微信公众号无需二次登录_您无需两次解决问题-您需要一个设计系统
  • 视觉工程师面试指南_选择正确视觉效果的终极指南
  • 问题反馈模板_使用此模板可获得更好,更有价值的UX反馈
  • iofd:文件描述符_文字很重要:谈论设计时18个有意义的描述符
  • 数据可视化 信息可视化_可视化哲学的黎明
  • 重口味动漫_每种口味的图标样式
  • 从头开始vue创建项目_我正在以设计师的身份开始一个被动的收入项目。 从头开始。...
  • 英国文化影响管理风格_文化如何影响用户体验
  • element ui 空格_空格是您的UI朋友。 大量使用它。

react动画库_React 2020动画库相关推荐

  1. R语言gganimate包创建可视化gif动图、可视化动图:ggplot2可视化静态散点图、gganimate包创建动态散点分面图(facet_wrap)动画基于transition_time函数

    R语言gganimate包创建可视化gif动图.可视化动图:ggplot2可视化静态散点图.gganimate包创建动态散点分面图(facet_wrap)动画基于transition_time函数 目 ...

  2. R语言gganimate包创建可视化gif动图、可视化动图:、gganimate包创建动态线型图动画基于transition_time函数、使用geom_point函数显示动画移动的数据点

    R语言gganimate包创建可视化gif动图.可视化动图:.gganimate包创建动态线型图动画基于transition_time函数.使用geom_point函数显示动画移动的数据点 目录

  3. R语言gganimate包创建可视化gif动图、可视化动图:创建动态散点图动画基于transition_time函数、使用shadow_wake函数配置动画的渐变效果(gradual falloff)

    R语言gganimate包创建可视化gif动图.可视化动图:创建动态散点图动画基于transition_time函数.使用shadow_wake函数配置动画的渐变效果(gradual falloff) ...

  4. 动圈耳机振膜_动圈耳机和动铁耳机区别,以及选择

    一款好耳机不仅仅是看他价格,还要看它和你的播放器契匹配度够不够高,大家可以从能最基本的发声单元和基本原理入手进行初步了解一一比对,就比较容易找到适合你的好耳机了.根据发声的原理分类,一般分为动圈耳机和 ...

  5. B12HTML5期末大作业:动漫网站设计——火影忍者动漫(7页) 动漫HTML代码 学生漫画设计与制作期末作业下载 大学生动漫设计与制作成品下载 漫画作业代码下载

    HTML5期末大作业:动漫网站设计--火影忍者动漫(7页) 动漫HTML代码 学生漫画设计与制作期末作业下载 大学生动漫设计与制作成品下载 漫画作业代码下载 常见网页设计作业题材有 个人. 美食. 公 ...

  6. 网易互娱动效设计师 | VX动效学习如何入门?

    在上篇<游戏动效与美术特效的区别>文章中,学院君给大家介绍了VX是什么.今天又给大家带来一篇VX动效入门干货文章,主要从哪里学,怎么做,如何深入等三个方面,系统讲下VX动效学习如何入门. ...

  7. 黑马程序员—编程实现:猫和狗都会叫,但猫是喵喵的叫,狗是汪汪的叫?定义一个动物类,在动物类(animal)中有一个叫的抽象方法。 写两个子类,一个猫一个狗, * 继承自动物类,并实现相应的抽象方法。

    ------ Java培训.Android培训.iOS培训..Net培训.期待与您交流! -------package com.itheima; /*  *第9题:   * 编程实现:猫和狗都会叫,但 ...

  8. HTML5期末大作业:动漫网站设计——火影忍者动漫(7页) 动漫HTML代码 学生漫画设计与制作期末作业下载 大学生动漫设计与制作成品下载 漫画作业代码下载

    HTML5期末大作业:动漫网站设计--火影忍者动漫(7页) 动漫HTML代码 学生漫画设计与制作期末作业下载 大学生动漫设计与制作成品下载 漫画作业代码下载 常见网页设计作业题材有 个人. 美食. 公 ...

  9. HTML5期末大作业:动漫网站设计——动漫电影《你的名字》(7页) HTML+CSS+JavaScript 学生DW网页设计作业成品 html网页设计期末大作业_网页设计平时作业

    HTML5期末大作业:动漫网站设计--动漫电影<你的名字>(7页) HTML+CSS+JavaScript 学生DW网页设计作业成品 html网页设计期末大作业_网页设计平时作业 常见网页 ...

最新文章

  1. 唠唠SE的集合-04——ArrayList
  2. 如何操作提升手机端网站的排名优化?
  3. php 定义数字int,php中的int参数
  4. 32位linux运行64位jdk,linux64位操作系统装32位jdk解决方法
  5. asp.net datatable 导出为 txt
  6. 对 Web 应用程序进行性能调优
  7. 获得BAT技术专家Offer,他到底做了什么?
  8. 华为南太无线解决方案部梁旭阳_华为“测温”手机申请了专利,华为今年共申请了 8,607 项无线专利...
  9. RPC框架dubbo架构原理及使用说明
  10. 雷赛服务器信号er020,雷赛配合松下电机做三轴,xy轴到位信号的问题
  11. 14款超实用的Unity3D常用插件推荐
  12. HTML中美化页面,10 使用CSS美化页面
  13. 单机版fifa11显示ea服务器,游戏新消息:EA服务器出问题所有EA游戏在线功能无法正常运行...
  14. 攻防世界WEB题练习
  15. requestLayout() improperly called by 出现后的解决方法
  16. 计算机学院文化长廊,计算机学院2019年寝室文化节动员大会顺利召开
  17. 【python第3课】顺序、循环、分支
  18. 海尔智家罗马尼亚冰箱工厂将投产;长沙世茂希尔顿酒店今夏揭幕​;现代与LG新能源打造环保汽车电池 | 美通企业周刊...
  19. 京东到家话费券系统NIO实战
  20. 04741<计算机网络原理> 之第一章计算机网络概述

热门文章

  1. 微智魔盒骗局_微智魔盒官宣
  2. T(n) = 25T(n/5)+n^2的时间复杂度 计算方法
  3. 计算机运维知识点,系统运维必会知识点
  4. 复试计算机网络与软件工程,2018华南理工大学软件工程复试经验贴
  5. 前端面试每日 3+1(每日三问)
  6. ThinkPHP模型连接数据库 查询 ajax
  7. 64位进程和32位进程通信问题,接收端收不到 SendMessage发送的消息
  8. WebSocket-nodejs实现
  9. mysql数据库面试总结(一)
  10. Ubuntu16.04 安装 docker