你能告诉我为什么这个例子http://www.silkcutz.co.uk/test/是从这里取来的,https://github.com/SVGator/trigger-animation使用的是( ID为“e6flsqoxhzzs1”的logo.svg),工作非常好.
但是http://www.silkcutz.co.uk/test/2.html (使用ID为“eOKHP9YQpje1”的Untitled.svg )并不是,这是一个非常简单的框移动位置的动画(只是为了测试目的)。
这两个html文件都非常简单,应该只需要更改文件名和ID,但是示例2.html.您可能会认为svg有问题,但是当在这里的实时演示中使用上传SVG工具测试svg文件(Untitled.svg)时,https://www.svgator.com/help/getting-started/svgator-player-js-api工作得很好,并按预期的方式触发!
任何帮助都是非常感谢的!
发布于 2022-05-06 06:16:54
要使用这里所描述的技术,您需要使用“动画开始:单击”导出SVGator项目。
但是程序动画最近已经实现了。查看这些资源:https://www.svgator.com/help/getting-started/animate-programmatically https://www.svgator.com/help/getting-started/svgator-player-js-api
下面是一个关于如何将Player API与嵌入在标记中的SVG一起使用的完整示例:
<!DOCTYPE html>
<html>
<head>
<title>Testing SVG</title>
<script>
//Wait for the document to load
document.addEventListener("DOMContentLoaded", function() {
//grab the <object> element
let object1 = document.getElementById('animated-svg');
//Wait for the content of the <object> to load
object1.addEventListener("load", function() {
//grab the <svg> element
let svg = object1.contentDocument.getElementById('e5478wvxh25l1');
//Wait for the SVGtor player to be ready for use
svg.svgatorPlayer.ready(function(player) {
//inset your code here; i.e.
player.play();
});
});
});
</script>
</head>
<body>
<object id="animated-svg" type="image/svg+xml" data="animated.svg" style="height: 857px;"></object>
</body>
</html>同样值得知道的是,无论您如何设置“动画开始”,您都可以访问Player API,并且可以作为专业用户控制动画。
https://stackoverflow.com/questions/72108305
复制相似问题