首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >svg触发器动画问题(svgator)

svg触发器动画问题(svgator)
EN

Stack Overflow用户
提问于 2022-05-04 05:28:24
回答 1查看 353关注 0票数 1

你能告诉我为什么这个例子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工作得很好,并按预期的方式触发!

任何帮助都是非常感谢的!

EN

回答 1

Stack Overflow用户

发布于 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一起使用的完整示例:

代码语言:javascript
复制
<!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,并且可以作为专业用户控制动画。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72108305

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档