如何使用javascript创建SVG动画标记
我有一个带动画的SVG圆圈如何使用javascript创建SVG动画标记,javascript,html,svg,Javascript,Html,Svg,我有一个带动画的SVG圆圈 <circle cx="30" cy="50" r="15" fill="blue" stroke="black" stroke-width="1"> <animateMotion path="M 0 0 H 300 Z" dur="8s" repeatCount="indefinite" /> </circle> 您可以使用javascript获得大量关于svg的示例 您可以从那里获得帮助。您可以获得大量关于使用javas
<circle cx="30" cy="50" r="15" fill="blue" stroke="black" stroke-width="1">
<animateMotion path="M 0 0 H 300 Z" dur="8s" repeatCount="indefinite" />
</circle>
您可以使用javascript获得大量关于svg的示例
您可以从那里获得帮助。您可以获得大量关于使用javascript的svg的示例
您可以从那里获得帮助。看起来像是
animateMotion
元素在Webkit中被恶意创建(请参阅),在IE中不受支持。我认为您最好使用纯javascript动画库,比如。看起来像animateMotion
元素在Webkit中被恶意创建(请参阅)时被恶意创建(请参阅),并且在IE中不受支持。我认为您最好使用纯javascript动画,使用类似的库。也许这就是您的问题:
在XML中:
<animateMotion path= ... />
希望有帮助,向m93a致意。也许这就是你的问题: 在XML中:
<animateMotion path= ... />
希望有帮助,关于m93a。如果只需单击按钮就很重要,可以使用
动画中的begin
属性来解决:
干杯如果单击
很重要,可以使用动画中的开始
属性来解决:
var animateMotion = document.createElementNS('http://www.w3.org/2000/svg','animateMotion');
animateMotion.setAttribute("dur","3s");
animateMotion.setAttribute("repeatCount","1");
var mpath = document.createElementNS('http://www.w3.org/2000/svg','mpath');
mpath.setAttributeNS("http://www.w3.org/1999/xlink", "href", "#YourPath");
animateMotion.appendChild(mpath);
干杯如果您希望在
元素附加页面上尽快设置动画,
var animateMotion = document.createElementNS('http://www.w3.org/2000/svg','animateMotion');
animateMotion.setAttribute("dur","3s");
animateMotion.setAttribute("repeatCount","1");
var mpath = document.createElementNS('http://www.w3.org/2000/svg','mpath');
mpath.setAttributeNS("http://www.w3.org/1999/xlink", "href", "#YourPath");
animateMotion.appendChild(mpath);
将
'begin'设置为'unfinite',并开始动画调用其.beginElement()
如果希望在
元素附加页面后立即制作动画,
将
'begin'设置为'unfinite',并开始动画调用其.beginElement()
看来你已经有了正确的答案。我认为这在Webkit中目前还不起作用,但应该在其他地方起作用。我对Firefox也有类似的问题。文档:看起来你已经有了正确的答案。我认为这在Webkit中目前不起作用,但应该在其他地方起作用。我对Firefox也有类似的问题。文档:请解释您所做的更改,以及您的代码如何修复OP的问题。请解释您所做的更改,以及您的代码如何修复OP的问题。
var animateMotion = document.createElementNS(SVG_NS, 'animateMotion');
animateMotion.setAttribute('begin', 'indefinite');
//append animateMotion to the page
animateMotion.beginElement();