我正在尝试在 IE9 中伪造 SMIL 支持假笑
我动态创建 SVG 元素,添加带有 animate 元素的 rect 元素并调用 beginElement()。
IE9 给我一个错误:
对象不支持属性或方法“beginElement”
静态 SVG 工作原理:http://jsfiddle.net/FG3PG/1/
如何使用 FakeSmile 来修复它?
以下显示了我正在尝试做的事情:http://jsfiddle.net/DgMDV/13/
这是相同的代码:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE HTML><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<script type="text/javascript" src="http://bazaar.launchpad.net/~smilteam/smil/MAIN/download/head:/smil.user.js-20080305202719-59ane0zgfr5f3vz8-1/smil.user.js"></script>
</head>
<body>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" height="200">
<rect class="drag resize" x="10" y="10" width="100" height="50" fill="#c66" />
</svg>
<script type="text/javascript">
var svg = document.getElementsByTagName('svg')[0];
var svgNS = svg.getAttribute('xmlns');
var rect = document.getElementsByTagName('rect')[0];
var animation = document.createElementNS(
"http://www.w3.org/2000/svg", "animate");
animation.setAttributeNS(null, 'attributeName', 'x');
animation.setAttributeNS(null, 'dur', 0.5);
animation.setAttributeNS(null, 'begin', 'indefinite');
animation.setAttributeNS(null, 'fill', 'freeze');
animation.setAttributeNS(null, 'to', 100);
rect.appendChild(animation);
animation.beginElement();
</script>
</body>
</html>
Fenring(leunen-d)回答fakesmil不支持动态动画
并且可以添加以下功能:https://answers.launchpad.net/smil/+question/203333
function registerAnimation(anim) {
var targets = getTargets(anim);
var elAnimators = new Array();
for(var i=0; i<targets.length ;i++) {
var target = targets[i];
var animator = new Animator(anim, target, i);
animators.push(animator);
elAnimators[i] = animator;
}
anim.animators = elAnimators;
var id = anim.getAttribute("id");
if (id)
id2anim[id] = anim;
for(var i=0; i<elAnimators.length ;i++)
elAnimators[i].register();
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)