【发布时间】:2017-08-06 12:59:36
【问题描述】:
你好,我有this fiddle
$('button').click(function(){
$('#sa').addClass('animate-sa2')
})
.st0{fill:none;stroke:#000000;stroke-width:33;stroke-miterlimit:10;};
#sa{
stroke-dasharray:320;
stroke-dashoffset:100;
}
.animate-sa{
animation:1.5s animate-sa forwards;
}
.animate-sa-2{
animation:1.5s animate-sa forwards;
}
@keyframes animate-sa{
from{
stroke-dasharray:320;
stroke-dashoffset:100;
}
to{
stroke-dasharray:500;
stroke-dashoffset:0;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button type="button">click</button>
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="501.9px" height="273.8px" viewBox="0 0 501.9 273.8" style="enable-background:new 0 0 501.9 273.8;" xml:space="preserve">
<path id="sa" class="animate-sa st0 " d="M281,156.2c56,51.5,80.4-57.4,80.4-57.4c-12.5,41.2-9.2,71,19.2,71.6c28.4,0.6,43.7-71.2,43.7-71.2
s-21.2,77.8,32.9,70.8c53.2-6.9,7.6-93.5,7.6-93.5"/>
</svg>
svg 将 在页面加载时立即进行动画处理,但我这里有一个按钮,应该通过添加 再次对其进行动画处理>("animate-sa2) 和头等舱一样。但是不行!你能帮帮我吗?
【问题讨论】:
标签: jquery css svg jquery-animate keyframe