简体   繁体   English

如何为参照SVG背景制作动画

[英]How to animate an referential SVG background

Does exists some way to animate referential background svg with vivus.js? 是否存在某种使用vivus.js为参照背景svg进行动画处理的方法? I'm trying to use it. 我正在尝试使用它。 I found this code in the oficial documentation but I don't know if this is possible. 我在官方文档中找到了此代码,但我不知道这是否可行。 Look at the code below: 看下面的代码:

HTML
<section id="svg-bg" class="materiais-topo">
  <!-- some elements here -->
</section>

CSS (SASS)
    .materiais-topo {
      background-color: $green-fluo;
      background-image: url('../images/line-fluo.svg');
      background-position: center center;
      background-repeat: no-repeat;
    }

JS
new Vivus-bg('svg-bg', {
   file: MAIN_URL+'dist/images/line-fluo.svg'
});

Someone has any solution? 有人有什么解决办法吗? If you know to animate referential background svg without vivus.js let me know. 如果您知道要在没有vivus.js的情况下为参照背景svg设置动画,请告诉我。

EDIT: This method only inject SVG file in my div element. 编辑:此方法仅在我的div元素中注入SVG文件。

So, as far as I know, it's impossible to manipulate a Background SVG with Javascript. 因此,据我所知,用Javascript操作Background SVG是不可能的。

But, you can: 但是你可以:

Here an example of SVG SMIL animation: 这是SVG SMIL动画的示例:

<svg xmlns="http://www.w3.org/2000/svg" width="300px" height="100px">
    <rect x="0" y="0" width="300" height="100" stroke="black" stroke-width="1" />
    <circle cx="0" cy="50" r="15" fill="blue" stroke="black" stroke-width="1">
        <animateMotion path="M 0 0 H 300 Z" dur="3s" repeatCount="indefinite" />
    </circle>
</svg>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM