4

所以这是我的代码,在正文标记中,如文档中所指定:

   <amp-animation layout="nodisplay" trigger="visibility">
    <script type="application/json">
        [
            {
                "selector": ".shape-3",
                "duration": 1000,
                "delay": 0,
                "keyframes": "buildInKeyframes",
                "fill": "both",
                "direction": "normal"
            },
            {
                "selector": ".shape-3",
                "duration": 1000,
                "delay": 1200,
                "keyframes": "buildOutKeyframes",
                "fill": "both",
                "direction": "normal"
            }

        ]
    </script>
    </amp-animation>

(在 head 标签中,我使用标签样式 amp-custom 定义了关键帧)我有一个带有 class="shape-3" 的 div,我想用第一个动画对其进行动画处理,完成后,用第二个动画对其进行动画处理。问题是

4

1 回答 1

0

您可以尝试通过以下方式使用动画:

<amp-animation layout="nodisplay">
  <script type="application/json">
    {
      "selector": ".shape-3",
      "duration": "1s",
      "iterations": "1",
      "fill": "both",
      "direction": "alternate",
      "animations": [
        {
          "selector": ".target-class",
          "easing": "cubic-bezier(0,0,.21,1)",
          "keyframes": {
            "transform": "rotate(20deg)"
          }
        },
        {
          "delay": "1s",
          "easing": "cubic-bezier(0,0,.21,1)",
          "keyframes": {
            "transform": "rotate(30deg)"
          }
        }
      ]
    }
  </script>
</amp-animation>

第二个动画的延迟是第一个动画所花费的时间。

于 2022-01-07T07:56:11.433 回答