@designcombo/animations

中文文档
5.5.8发布于 2025/12/05TypeScriptESM + CJS近 30 天下载 6051

A powerful animation library for managing complex animation sequences and transitions in React applications, with specialized components for different animation scenarios.

原始使用文档
文档目录11 节
  1. Installation
  2. Usage
  3. BoxAnim Component
  4. ContentAnim Component
  5. MaskAnim Component
  6. Animation Hook
  7. Animation Properties
  8. Animation Interface
  9. Features
  10. Development
  11. License

@designcombo/animations

A powerful animation library for managing complex animation sequences and transitions in React applications, with specialized components for different animation scenarios.

Installation

npm install @designcombo/animations
# or
yarn add @designcombo/animations
# or
pnpm add @designcombo/animations

Usage

BoxAnim Component

The main animation wrapper for standard in/out animations with rotation handling:

import { BoxAnim } from "@designcombo/animations";

<BoxAnim
  animationIn={[
    {
      property: "opacity",
      from: 0,
      to: 1,
      durationInFrames: 30,
      ease: (t) => t,
      delay: 0
    },
    {
      property: "translateX",
      from: -100,
      to: 0,
      durationInFrames: 30,
      ease: (t) => t
    }
  ]}
  animationOut={[
    {
      property: "opacity",
      from: 1,
      to: 0,
      durationInFrames: 15,
      ease: (t) => t
    }
  ]}
  durationInFrames={60}
  frame={currentFrame}
  style={{ transform: "rotate(45deg)" }}
>
  <div>Your BoxAnim content here</div>
</BoxAnim>;

ContentAnim Component

For timed animations that are affected by rotation transformations:

import { ContentAnim } from "@designcombo/animations";

<ContentAnim
  animationTimed={[
    {
      property: "scale",
      from: 0.8,
      to: 1.2,
      durationInFrames: 45,
      ease: (t) => t,
      persist: true
    }
  ]}
  durationInFrames={60}
  frame={currentFrame}
  style={{ width: 200, height: 200 }}
>
  <div>Content with timed animations</div>
</ContentAnim>;

MaskAnim Component

For creating mask reveal animations with different patterns:

import { MaskAnim } from "@designcombo/animations";

<MaskAnim
  frame={currentFrame}
  item={itemData}
  keyframeAnimations={[
    {
      property: "maskRevealIn", // or "maskRevealCenterIn", "maskRevealCornerIn"
      durationInFrames: 30
    }
  ]}
>
  <div>Content that will be revealed with mask animation</div>
</MaskAnim>;

Animation Hook

Direct access to animation calculations:

import {
  useAnimation,
  combineAnimations,
  combine
} from "@designcombo/animations";

// Basic usage
const style = useAnimation(
  combineAnimations(animations),
  durationInFrames,
  frame,
  false // isOut
);

// Advanced usage with timed animations
const timedStyle = useAnimation(
  combineAnimations(animations),
  durationInFrames,
  frame,
  false, // isOut
  true // isTimed
);

// Combining multiple animation sources
const combinedAnimations = combine(
  animationIn,
  animationOut,
  additionalAnimations
);

Animation Properties

The library supports various animation properties:

  • Transform Properties: scale, translateX, translateY, rotate
  • Visual Properties: opacity
  • Special Properties: shake (with automatic intervals)
  • Mask Properties: maskRevealIn, maskRevealCenterIn, maskRevealCornerIn

Animation Interface

interface Animation {
  property: keyof React.CSSProperties | string;
  from: number;
  to: number;
  durationInFrames: number;
  ease: (t: number) => number;
  delay?: number;
  persist?: boolean; // For timed animations
}

Features

  • Animated Component: Main wrapper for in/out animations with rotation compensation
  • ContentAnimations Component: Specialized for timed animations affected by rotation
  • MaskWrapper Component: Creates mask reveal effects with multiple patterns
  • Animation Hook: Direct access to animation calculations
  • Rotation Handling: Automatic compensation for rotated elements
  • Persistent Animations: Support for animations that persist after completion
  • Shake Effects: Built-in shake animation with automatic intervals
  • Transform Extraction: Utilities for parsing and combining transform properties
  • Performance Optimized: Efficient animation rendering with memoization
  • TypeScript Support: Full type safety with comprehensive interfaces
  • Remotion Integration: Built for Remotion video framework

Development

# Install dependencies
pnpm install

# Start development server
pnpm dev

# Build package
pnpm build

# Format code
pnpm format

License

MIT

版本与发布记录

@designcombo/animations 共发布 21 个版本,首次发布于 2025/09/07;过去 12 个月发布了 12 个版本。

版本发布日期距今
5.5.8latest2025/12/0511 个月前
5.5.72025/12/0511 个月前
5.5.62025/11/2911 个月前
5.5.52025/11/2811 个月前
5.5.42025/11/2811 个月前
5.5.32025/11/2811 个月前

关于 @designcombo/animations 的常见问题

@designcombo/animations 是什么?

A powerful animation library for managing complex animation sequences and transitions in React applications, with specialized components for different animation scenarios.

如何安装 @designcombo/animations?

在项目目录运行 npm install @designcombo/animations,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@designcombo/events(^1.0.2)、react(^18.2.0)、remotion(^4.0.0)、@designcombo/types(5.5.8)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@designcombo/animations 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@designcombo/animations 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@designcombo/animations 可以商用吗?

@designcombo/animations 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@designcombo/animations 的下载量有多少?

根据 npm 官方下载统计,@designcombo/animations 在 2026/10/12 – 2026/11/10 这 30 天内被下载 6,051 次,日均约 202 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@designcombo/animations 还在维护吗?

最新版本 5.5.8 发布于 2025/12/05(11 个月前);至今共发布 21 个版本,其中过去 12 个月发布了 12 个;首次发布于 2025/09/07。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。