You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

amCharts4 SVG路径绘制动画在Safari浏览器中出现异常

SVG路径绘制动画在Safari中起始位置异常

使用amCharts4生成SVG路径的绘制动画,该动画在Chrome、Firefox等浏览器中表现正常,但在Mac和iOS的Safari浏览器中,路径的起始位置随机,不符合从起点到终点绘制的预期。

所用CSS动画代码

#amchart {
    width : 100%;
  max-width: 100%;
    height : 500px;
}
#amchart .amcharts-animateLine1,
#amchart .amcharts-animateLine2,
#amchart .amcharts-animateLine3 {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    -webkit-animation-name: am-draw;
       -moz-animation-name: am-draw;
         -o-animation-name: am-draw;
            animation-name: am-draw;
    -webkit-animation-timing-function: ease-in-out;
       -moz-animation-timing-function: ease-in-out;
         -o-animation-timing-function: ease-in-out;
            animation-timing-function: ease-in-out;
    -webkit-animation-duration: 15s;
       -moz-animation-duration: 15s;
         -o-animation-duration: 15s;
            animation-duration: 15s;
    -webkit-animation-direction: forwards;
       -moz-animation-direction: forwards;
         -o-animation-direction: forwards;
            animation-direction: forwards;
}

@-webkit-keyframes am-draw {
  0% {
    stroke-dashoffset: 1;
  }
  100% {
    stroke-dashoffset: 0;
  }
}

@-moz-keyframes am-draw {
  0% {
    stroke-dashoffset: 1;
  }
  100% {
    stroke-dashoffset: 0;
  }
}

@-o-keyframes am-draw {
  0% {
    stroke-dashoffset: 1;
  }
  100% {
    stroke-dashoffset: 0;
  }
}

@keyframes am-draw {
  0% {
    stroke-dashoffset: 1;
  }
  100% {
    stroke-dashoffset: 0;
  }
}

已尝试的解决方法

  • 为目标路径设置pathlength="1",但未解决问题。

我刚接触CSS动画和SVG,若有信息缺失请告知,我会补充。

内容的提问来源于stack exchange,提问作者user22150038

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.17 12:05:17