【发布时间】:2016-11-29 11:11:31
【问题描述】:
是否可以沿线路径为圆设置动画?
我已经尝试了以下代码。我可以合并两条线路径和圆圈并应用相同的过渡
$(document).ready(function () {
var svgPath = document.getElementById('heart');
var path = new ProgressBar.Path(svgPath, {
duration: 3000
});
path.animate(-1, {
easing: 'easeOutBounce',
duration: 2000
}, function () {
console.log('Animation has finished');
});
});
#container {
width:220px;
position: relative;
}
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://rawgit.com/kimmobrunfeldt/progressbar.js/1.0.0/dist/progressbar.js"></script>
<div id="container" style="width:200px;height:200px;">
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100.08 100" width="500"
height="500">
<path d="M50,2A48,48,0,1,1,2,50,48,48,0,0,1,50,2" fill-opacity="0" stroke="#eee" />
<circle cx="95.87" cy="64.33" r="2.66" />
<path id="heart" fill-opacity="0" d="M95.6,65.16A48,48,0,1,1,50,2" fill="none" stroke="#000" />
</svg>
</div>
【问题讨论】:
-
不太清楚你所说的“动画圆圈”是什么意思。你能澄清一下吗?
-
检查我的例子 - 圆没有动画路径只有描边路径被动画了
-
所以你想自己绕圈旋转(像跳动者一样)?
-
不像 throbber - 我想要用路径动画的圆圈,你只能看到动画路径而不是圆圈
-
恐怕还不清楚您到底在寻找什么。我会选择一个作为答案,希望它能给你你想要的:)
标签: javascript jquery css animation svg