跳到主要内容
Office Open

PPTX

切换效果

添加淡入、推入、擦除等幻灯片切换效果

使用幻灯片选项中的 transition 属性在切换幻灯片时添加动画效果。

#基本切换

JSON
{
  "slides": [
    {
      "children": [],
      "transition": {
        "type": "fade",
        "speed": "medium"
      }
    }
  ]
}

#幻灯片放映设置

使用 show 选项控制演示文稿播放行为:

JSON
{
  "show": {
    "loop": true,
    "useTimings": true
  },
  "slides": [
    {
      "children": [
        {
          "shape": {
            "x": "0.0cm",
            "y": "0.0cm",
            "width": "5.3cm",
            "height": "2.6cm",
            "textBody": {
              "text": "幻灯片 1"
            }
          }
        }
      ]
    }
  ]
}

#放映选项

属性类型说明
loopboolean循环放映
type"present" | "browse" | "kiosk"放映类型(演讲/浏览/展台)
showScrollbarboolean显示滚动条(浏览模式)
restartnumber重启策略
showNarrationboolean放映时播放旁白
showAnimationboolean放映时显示动画
useTimingsboolean使用录制的排练时间
slideRange{ start: number; end: number }限定放映的幻灯片范围
penColorstring演示笔颜色(srgbClr hex)

#切换类型

#淡入

json
{
  "transition": { "type": "fade" }
}

#推入

json
{
  "transition": {
    "type": "push",
    "direction": "right"
  }
}

#擦除

json
{
  "transition": {
    "type": "wipe",
    "direction": "down"
  }
}

#覆盖

json
{
  "transition": {
    "type": "cover",
    "direction": "right"
  }
}

#拆分

json
{
  "transition": {
    "type": "split",
    "orient": "horz",
    "direction": "out"
  }
}

#轮辐

json
{
  "transition": {
    "type": "wheel",
    "spokes": 4
  }
}

#溶解

json
{
  "transition": {
    "type": "dissolve",
    "speed": "slow"
  }
}

#随机

json
{
  "transition": { "type": "random" }
}

#切换选项

属性类型说明
typeTransitionType切换类型
speed"slow" | "medium" | "fast"切换速度
directionstring方向(取决于类型)
orient"horz" | "vert"方向(拆分/百叶窗/棋盘等)
spokesnumber轮辐数量(轮辐切换)
advanceOnClickboolean单击鼠标时切换
advanceAfterTimenumber自动切换间隔(毫秒)
thruBlkboolean黑场过渡(淡入/剪切)
startSound{ rId; name?; loop? }切换开始时播放的声音
stopPreviousSoundboolean停止之前播放的声音

#可用类型

"fade" | "push" | "wipe" | "split" | "blinds" | "checker" | "comb" | "randomBar" | "cover" | "pull" | "strips" | "wheel" | "zoom" | "circle" | "dissolve" | "diamond" | "newsflash" | "plus" | "wedge" | "random" | "cut"

#完整示例

JSON
{
  "slides": [
    {
      "children": [
        {
          "shape": {
            "x": "2.6cm",
            "y": "4.0cm",
            "width": "13.2cm",
            "height": "2.6cm",
            "textBody": {
              "text": "Welcome"
            },
            "properties": {
              "fill": "4472C4"
            }
          }
        }
      ],
      "transition": {
        "type": "fade",
        "speed": "medium"
      }
    },
    {
      "children": [
        {
          "shape": {
            "x": "2.6cm",
            "y": "4.0cm",
            "width": "13.2cm",
            "height": "2.6cm",
            "textBody": {
              "text": "Content Slide"
            },
            "properties": {
              "fill": "ED7D31"
            }
          }
        }
      ],
      "transition": {
        "type": "push",
        "direction": "right",
        "speed": "slow"
      }
    },
    {
      "children": [
        {
          "shape": {
            "x": "2.6cm",
            "y": "4.0cm",
            "width": "13.2cm",
            "height": "2.6cm",
            "textBody": {
              "text": "Thank You"
            },
            "properties": {
              "fill": "70AD47"
            }
          }
        }
      ],
      "transition": {
        "type": "wipe",
        "direction": "down"
      }
    }
  ]
}