【发布时间】:2015-09-16 17:03:32
【问题描述】:
我制作了一个简单的 SVG,它的元素每 5 秒重复一次,但是在我查看过的每个浏览器和操作系统中,它似乎每次重复时都会短暂地跳回几个像素(一旦 5 条虚线退出框架)。这有点微妙,但如果你仔细观察,它就在那里。
代码如下,这里是一个 CodePen:http://codepen.io/MityaDSCH/pen/vOpbdb
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
<!ENTITY st "fill:none;stroke:#000000;">]>
<svg version="1.1" id="feynman-logo" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="700px" height="600px" viewBox="0 0 700 600" style="border: 1px solid black;top:0;right:0;bottom:0;left:0;position:absolute;margin:auto;enable-background:new 0 0 700 600;" xml:space="preserve">
<!-- MW line -->
<polyline style="&st;" points="0,600 200,200 300,400 400,200 500,400 700,0"/>
<!-- Top Dashed Line -->
<clipPath id="top-dashed-clip">
<rect x="100" y="0" width="100" height="200" fill="url(#Gradient)"/>
</clipPath>
<line style="&st;" stroke-dasharray="22, 22" x1="100" y1="0" x2="300" y2="400" clip-path="url(#top-dashed-clip)">
<animate attributeName="x1" from="100" to="0" dur="7s" begin="0s" fill="remove" repeatCount="indefinite"/>
<animate attributeName="y1" from="0" to="-200" dur="7s" begin="0s" fill="remove" repeatCount="indefinite"/>
<animate attributeName="x2" from="300" to="200" dur="7s" begin="0s" fill="remove" repeatCount="indefinite"/>
<animate attributeName="y2" from="400" to="200" dur="7s" begin="0s" fill="remove" repeatCount="indefinite"/>
</line>
<!-- Bottom Dashed Line -->
<clipPath id="bottom-dashed-clip">
<rect x="500" y="400" width="100" height="200"/>
</clipPath>
<line style="&st;" stroke-dasharray="22, 22" x1="600" y1="600" x2="400" y2="200" clip-path="url(#bottom-dashed-clip)">
<animate attributeName="x1" from="600" to="700" dur="7s" begin="0s" fill="remove" repeatCount="indefinite"/>
<animate attributeName="y1" from="600" to="800" dur="7s" begin="0s" fill="remove" repeatCount="indefinite"/>
<animate attributeName="x2" from="400" to="500" dur="7s" begin="0s" fill="remove" repeatCount="indefinite"/>
<animate attributeName="y2" from="200" to="400" dur="7s" begin="0s" fill="remove" repeatCount="indefinite"/>
</line>
</svg>
【问题讨论】:
标签: xml animation svg vector-graphics