Convert Figma logo to code with AI

ant-design logoant-motion

:bicyclist: Animate specification and components of Ant Design

4,587
358
4,587
33

Top Related Projects

23,338

Open source, production-ready animation and gesture library for React

🍿 A cross-browser library of CSS animations. As easy to use as an easy thing.

49,575

JavaScript animation engine

19,483

GSAP (GreenSock Animation Platform), a JavaScript animation library for the modern web

26,486

Animate on scroll library

26,868

Actor-based state management & orchestration for complex app logic.

Quick Overview

Ant Motion is a React-based animation library that provides a set of high-quality motion components and utilities for building smooth and visually appealing user interfaces. It is part of the Ant Design ecosystem, a popular UI design system for React applications.

Pros

  • Extensive Animation Library: Ant Motion offers a wide range of pre-built animation components and utilities, covering various use cases such as entrance effects, exit effects, and scrolling animations.
  • Customizable Animations: The library allows developers to easily customize the animations to fit their specific design requirements, including adjusting timing, easing, and other parameters.
  • Smooth Transitions: Ant Motion's animations are designed to provide smooth and natural-looking transitions, enhancing the overall user experience.
  • Integration with Ant Design: As part of the Ant Design ecosystem, Ant Motion seamlessly integrates with the Ant Design UI library, making it a natural choice for projects already using Ant Design.

Cons

  • Learning Curve: While the library provides comprehensive documentation, developers new to Ant Motion may face a learning curve, especially if they are not familiar with the Ant Design ecosystem.
  • Performance Considerations: Depending on the complexity and number of animations used, the library may have a slight impact on the overall performance of the application, especially on lower-end devices.
  • Limited Support for Non-React Frameworks: Ant Motion is primarily focused on React-based applications, and its support for other JavaScript frameworks or libraries may be limited.
  • Potential Vendor Lock-in: By using Ant Motion, developers may become more dependent on the Ant Design ecosystem, which could make it challenging to migrate to alternative animation libraries in the future.

Code Examples

Entrance Animation

import { motion } from 'antd-motion';

const MyComponent = () => {
  return (
    <motion.div
      animation={{
        enter: { y: 0, opacity: 1, type: 'fadeInUp', duration: 0.5 },
        exit: { y: -50, opacity: 0, type: 'fadeOut', duration: 0.3 },
      }}
    >
      This is a component with an entrance animation.
    </motion.div>
  );
};

Scroll Animation

import { useScroll, motion } from 'antd-motion';

const MyScrollComponent = () => {
  const { scrollY } = useScroll();

  return (
    <motion.div
      animation={{
        in: { y: 0, opacity: 1, type: 'fadeInUp', duration: 0.6 },
        out: { y: 50, opacity: 0, type: 'fadeOut', duration: 0.3 },
        scrollY: {
          start: 100,
          end: 300,
        },
      }}
    >
      This component will animate when scrolled into view.
    </motion.div>
  );
};

Transition Animation

import { motion } from 'antd-motion';

const MyTransitionComponent = () => {
  return (
    <motion.div
      animation={{
        transition: {
          duration: 0.5,
          ease: 'easeInOut',
        },
      }}
    >
      This component will have a smooth transition animation.
    </motion.div>
  );
};

Getting Started

To get started with Ant Motion, follow these steps:

  1. Install the antd-motion package:
npm install antd-motion
  1. Import the necessary components and utilities from the library:
import { motion, useScroll } from 'antd-motion';
  1. Use the motion component to wrap your elements and define the animation properties:
<motion.div
  animation={{
    enter: { y: 0, opacity: 1, type: 'fadeInUp', duration: 0.5 },
    exit: { y: -50, opacity: 0, type: 'fadeOut', duration: 0.3 },
  }}
>
  This is a component with an entrance animation.
</motion.div>
  1. Customize

Competitor Comparisons

23,338

Open source, production-ready animation and gesture library for React

Pros of Motion

  • More comprehensive animation library with a wider range of features
  • Better documentation and community support
  • Seamless integration with React and other frameworks

Cons of Motion

  • Steeper learning curve for beginners
  • Larger bundle size, which may impact performance in some cases

Code Comparison

Ant Motion:

import QueueAnim from 'rc-queue-anim';

<QueueAnim delay={300} className="queue-simple">
  <div key="a">Queue Demo</div>
  <div key="b">Welcome</div>
  <div key="c">To</div>
  <div key="d">Ant Motion</div>
</QueueAnim>

Motion:

import { motion } from "framer-motion"

<motion.div
  initial={{ opacity: 0 }}
  animate={{ opacity: 1 }}
  transition={{ duration: 0.5 }}
>
  Hello Motion
</motion.div>

Summary

Motion offers a more robust and versatile animation solution with better documentation and community support. However, it may be more complex for beginners and have a larger bundle size. Ant Motion provides simpler animations with a focus on Ant Design components, making it easier to use for projects already utilizing the Ant Design ecosystem. The code comparison shows that Motion offers more granular control over animations, while Ant Motion provides pre-built animation components.

🍿 A cross-browser library of CSS animations. As easy to use as an easy thing.

Pros of Animate.css

  • Lightweight and easy to use with minimal setup
  • Extensive library of pre-built animations
  • Wide browser compatibility

Cons of Animate.css

  • Limited customization options
  • Lacks advanced animation sequencing capabilities
  • No built-in React integration

Code Comparison

Animate.css usage:

<link rel="stylesheet" href="animate.min.css">
<div class="animate__animated animate__bounce">An animated element</div>

Ant Motion usage:

import { TweenOneGroup } from 'ant-motion';

<TweenOneGroup
  enter={{ x: 30, opacity: 0, type: 'from' }}
  leave={{ x: -30, opacity: 0 }}
>
  {children}
</TweenOneGroup>

Key Differences

  • Ant Motion is specifically designed for React applications, while Animate.css is framework-agnostic
  • Ant Motion offers more complex animation capabilities and better integration with Ant Design components
  • Animate.css focuses on simple, ready-to-use CSS animations, while Ant Motion provides a more programmatic approach

Use Cases

  • Choose Animate.css for quick, simple animations in various web projects
  • Opt for Ant Motion when working with React and Ant Design, or when more advanced animation control is needed
49,575

JavaScript animation engine

Pros of Anime

  • Lightweight and flexible JavaScript animation library
  • Supports a wide range of animation types (CSS properties, SVG, DOM attributes)
  • Extensive documentation and examples

Cons of Anime

  • Less integrated with React ecosystem
  • Requires more manual setup for complex animations
  • Steeper learning curve for beginners

Code Comparison

Ant Motion (React-based):

import { TweenOneGroup } from 'ant-motion';

<TweenOneGroup
  enter={{ opacity: 0, scale: 0.8, type: 'from' }}
  leave={{ opacity: 0, scale: 0.8 }}
>
  {items}
</TweenOneGroup>

Anime (JavaScript):

anime({
  targets: '.element',
  opacity: [0, 1],
  scale: [0.8, 1],
  duration: 1000,
  easing: 'easeOutElastic(1, .8)'
});

Summary

Ant Motion is specifically designed for React applications, offering seamless integration with Ant Design components and a more declarative approach to animations. It provides pre-built animation components and effects, making it easier for React developers to implement complex animations quickly.

Anime, on the other hand, is a more versatile JavaScript animation library that can be used in various contexts, not limited to React. It offers fine-grained control over animations and supports a wider range of animation targets, including SVG and DOM attributes. However, it requires more setup and JavaScript knowledge to integrate with React applications effectively.

19,483

GSAP (GreenSock Animation Platform), a JavaScript animation library for the modern web

Pros of GSAP

  • More powerful and flexible animation capabilities
  • Extensive plugin ecosystem for advanced effects
  • Better performance, especially for complex animations

Cons of GSAP

  • Steeper learning curve for beginners
  • Requires a paid license for some advanced features

Code Comparison

Ant Motion:

import { TweenOneGroup } from 'ant-motion';

<TweenOneGroup
  enter={{ opacity: 0, scale: 0.8, type: 'from' }}
  leave={{ opacity: 0, scale: 0.8 }}
  appear={false}
>
  {children}
</TweenOneGroup>

GSAP:

import { gsap } from "gsap";

gsap.to(".box", {
  duration: 1,
  x: 100,
  y: 100,
  rotation: 360,
  ease: "power2.inOut"
});

Summary

GSAP offers more advanced animation capabilities and better performance, but comes with a steeper learning curve and potential licensing costs. Ant Motion provides a simpler, React-focused approach that may be sufficient for basic animation needs. GSAP's syntax is more JavaScript-oriented, while Ant Motion integrates seamlessly with React components. Choose based on your project's complexity and animation requirements.

26,486

Animate on scroll library

Pros of AOS

  • Lightweight and easy to implement
  • Works with any HTML elements, not limited to specific components
  • Supports a wide range of animation types out of the box

Cons of AOS

  • Less integrated with React ecosystem
  • Fewer customization options for complex animations
  • Limited support for sequencing or chaining animations

Code Comparison

AOS:

<div data-aos="fade-up" data-aos-duration="1000">
  Animate me!
</div>

Ant Motion:

import { TweenOne } from 'ant-motion';

<TweenOne
  animation={{ y: -30, opacity: 1 }}
  style={{ opacity: 0 }}
>
  Animate me!
</TweenOne>

Summary

AOS is a simpler, more lightweight solution for adding scroll-based animations to web pages. It's easy to implement and works with any HTML element. However, it lacks some of the advanced features and React integration that Ant Motion offers.

Ant Motion, being part of the Ant Design ecosystem, provides more complex animation capabilities and better integration with React components. It offers more customization options and supports advanced animation sequencing, but may have a steeper learning curve for those not familiar with the Ant Design system.

Choose AOS for quick, simple animations across various projects, and Ant Motion for more sophisticated animations in React-based Ant Design projects.

26,868

Actor-based state management & orchestration for complex app logic.

Pros of XState

  • More versatile state management solution, applicable to various domains beyond animations
  • Robust tooling ecosystem, including visualizer and testing utilities
  • Based on statecharts, offering a more formal and structured approach to state management

Cons of XState

  • Steeper learning curve due to its more complex concepts and API
  • May be overkill for simple animation tasks that Ant Motion handles easily
  • Requires more setup and configuration for basic use cases

Code Comparison

XState:

import { createMachine, interpret } from 'xstate';

const toggleMachine = createMachine({
  id: 'toggle',
  initial: 'inactive',
  states: {
    inactive: { on: { TOGGLE: 'active' } },
    active: { on: { TOGGLE: 'inactive' } }
  }
});

Ant Motion:

import { TweenOneGroup } from 'ant-motion';

const AnimationComponent = () => (
  <TweenOneGroup
    enter={{ x: 30, opacity: 0, type: 'from' }}
    leave={{ x: 30, opacity: 0 }}
  >
    {/* Child components */}
  </TweenOneGroup>
);

XState offers a more comprehensive state management solution with broader applications, while Ant Motion provides a simpler, more focused approach for React-based animations. XState's flexibility comes at the cost of increased complexity, whereas Ant Motion offers ease of use for quick animation implementations in React projects.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Ant Motion

Animation specification and components of Ant Design.

Dependencies DevDependencies

What is Ant Motion?

Ant Motion is a motion design specification from Ant Design, and also provide a complete solution with lots of out-of-box animations for your React applications.

What can Ant Motion do?

  • Create neat animations by using React components with a simple configuration.
  • Create beautiful landing page with motions by a few steps.

Demos

Specification

Ant Motion is an abstraction interface mainly intended to enhance the comfortness in the UX, increase the UI vitality, and also describe the level of relationship among touch feedback, user intentions and other functional effects. View details

Animation Components

  • rc-tween-one

    This is a React wrapper to animate your components. You can perform all of the style animations, including transform3d, fuzzy and other effects, you can also complete the Bezier curve animation. For the specific parameters see the API

  • rc-animate

    On a single element according to the status of animation display hidden, need to combine css or other third-party animation class used together; for the specific parameters see API

  • rc-queue-anim

    Add a serial rendering approach to a group of elements. Refer to the API for the specific parameters.

  • rc-scroll-anim

    Through a simple configuration, you can add animations which follow the scollbar on the elements of the page. Refer to the API for the specific parameters.

  • rc-banner-anim

    With a simple configuration, you can set up a modern and professional banner slider. Refer to the API for the specific parameters.

Landing page solution

Landing Formally launched, more. 🎉🎉🎉

This is based on the Ant Motion React components to follow with the design specifications of Ant Design to complete the demo page, you can quickly and flexibly configure the page template you want.

It provides a single-element example and a full-page example after configuration.

ant-motion-dva-cli-example

umi-example

More details

Develop

npm install
npm start

Go to http://localhost:8111

NPM DownloadsLast 30 Days