【发布时间】:2013-10-30 21:01:47
【问题描述】:
我正在通过 Javascript DOM 使用 HTML5 SVG 构建图形。
我使用动画沿其 x 坐标(y 常数)移动一个 svg 元素(即主 svg 元素的子元素)。
var animate = document.createElementNS("http://www.w3.org/2000/svg", "animate");
animate.id = i;
animate.setAttribute('attributeName','x');
animate.setAttribute('begin','indefinite');
animate.setAttribute('dur','1s');
animate.setAttribute('fill','freeze');
animate.addEventListener('endEvent',animationEnd,false);
svgChild.appendChild(animate);
稍后我通过svg元素访问动画元素,并开始动画
svgChild.firstChild.setAttribute('from',xFrom);
svgChild.firstChild.setAttribute('to',xTo);
svgChild.firstChild.beginElement()
到目前为止一切正常。
但在动画结束时,为其注册的处理程序不会被调用。
我也尝试了以下方法,但这也没有用。
animate.setAttribute('end',animationEnd);
我在通过 Javascript DOM 构建 SVG 的论坛上进行了广泛搜索。但是在通过 javascript DOM 注册动画事件属性时找不到任何帮助。
我在这个论坛查到的一些问题
【问题讨论】:
标签: javascript svg svg-animate