PPTX

动画效果

为形状添加进入、退出、强调和运动路径动画

为形状添加动画效果,控制它们在演示文稿中的出现和行为方式。

基本用法

动画通过 animation 属性直接设置在形状上:

import { Shape } from "@office-open/pptx";

new Shape({
    x: 1,
    y: 1,
    width: 6,
    height: 3,
    text: "动画形状",
    animation: {
        type: "fade",
        duration: 800,
    },
});

动画类型

进入动画(class: "entr",默认)

类型描述支持的方向
appear立即出现
fade淡入
fly从边缘飞入leftrightupdown
wipe从边缘擦入leftrightupdown
dissolve溶解出现
split分裂出现horizontalvertical
blinds百叶窗效果horizontalvertical
checker棋盘效果horizontalvertical
randomBars随机条纹horizontalvertical
wheel轮辐效果
zoom缩放出现
cover从边缘覆盖leftrightupdown
push从边缘推入leftrightupdown
strips从角落条状出现leftrightupdown

退出动画(class: "exit"

与进入动画相同的类型,添加 class: "exit"

animation: { type: "fade", class: "exit", duration: 800 }
animation: { type: "fly", class: "exit", direction: "right" }

强调动画(class: "emph"

emphasisType描述
growShrink放大后缩小
spin完整旋转
colorChange变色(需指定 color
transparency半透明闪烁
boldFlash加粗闪烁
wave波浪效果
pulse脉冲效果
growWithTurn旋转放大
animation: { class: "emph", emphasisType: "growShrink", duration: 800 }
animation: { class: "emph", emphasisType: "spin", duration: 1000 }
animation: { class: "emph", emphasisType: "colorChange", color: "FF0000" }

运动路径动画

pathType描述
line直线
arc弧线
circle圆形路径
curveS 形曲线
figureEight8 字形
bounce弹跳路径
loop环形路径
customPath自定义 SVG 路径(需指定 path
animation: { pathType: "circle", duration: 1500 }
animation: { pathType: "customPath", path: "M 0 0 L 100 0 L 100 100 L 0 100 Z", duration: 1200 }

动画选项

属性类型默认值描述
typeAnimationType"appear"动画预设类型
class"entr" | "exit" | "emph""entr"动画类别
durationnumber500持续时间(毫秒)
delaynumber0开始前延迟(毫秒)
triggerAnimationTrigger"onClick"触发方式
directionAnimationDirection动画方向
emphasisTypeEmphasisType强调动画类型(class="emph")
pathTypePathAnimationType运动路径类型
pathstring自定义 SVG 路径字符串
speednumber速度倍率
repeatCountnumber重复次数
autoReversebooleanfalse完成后自动反转
colorstringcolorChange 的目标颜色

触发模式

// 点击触发(默认)
animation: { type: "fade", trigger: "onClick" }

// 与上一个动画同时触发
animation: { type: "fade", trigger: "withPrevious" }

// 在上一个动画完成后触发
animation: { type: "fade", trigger: "afterPrevious" }
Copyright © 2026