SVG animation inside svg:use element. Works in Firefox, not in Chrome -
i'm using svg:use
element embed animating svg spinner inside large d3.js tree many nodes.
one node looks this:
<g class="node clickable" data-path="1" data-depth="0" transform=""> <text class="title" x="0" y=".36em" style="fill-opacity: 1;" text-anchor="begin">model</text> <text class="subtitle" x="0" y="2em" style="fill-opacity: 1;" text-anchor="begin"> <use href="static/spinner.svg#spinner" transform="translate(54.75,-9) rotate(0 7,9)"> </g>
i use jquery insert spinner when needed in 1 of many g.node
elements in tree.
the svg source of spinner follows:
<?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"> <svg id="spinner" version="1.1" xmlns="http://www.w3.org/2000/svg" width="16px" height="16px"> <g> <line x1="50" y1="3.167" x2="50" y2="23.5" opacity="0.2"> <animate attributetype="css" attributename="opacity" from="1" to="0.1" dur="1.2s" repeatcount="indefinite" begin="0s" /> </line> <line x1="80.102" y1="14.124" x2="67.033" y2="29.7" opacity="0.2"> <animate attributetype="css" attributename="opacity" from="1" to="0.1" dur="1.2s" repeatcount="indefinite" begin="0.1333s" /> </line> <line x1="96.121" y1="41.867" x2="76.096" y2="45.398" opacity="0.2"> <animate attributetype="css" attributename="opacity" from="1" to="0.1" dur="1.2s" repeatcount="indefinite" begin="0.2666s" /> </line> <line x1="90.559" y1="73.415" x2="72.949" y2="63.249" opacity="0.2"> <animate attributetype="css" attributename="opacity" from="1" to="0.1" dur="1.2s" repeatcount="indefinite" begin="0.4s" /> </line> <line x1="66.018" y1="94.007" x2="59.064" y2="74.901" opacity="0.2"> <animate attributetype="css" attributename="opacity" from="1" to="0.1" dur="1.2s" repeatcount="indefinite" begin="0.5333s" /> </line> <line x1="33.983" y1="94.007" x2="40.937" y2="74.901" opacity="0.2"> <animate attributetype="css" attributename="opacity" from="1" to="0.1" dur="1.2s" repeatcount="indefinite" begin="0.6666s" /> </line> <line x1="9.442" y1="73.417" x2="27.052" y2="63.25" opacity="0.2"> <animate attributetype="css" attributename="opacity" from="1" to="0.1" dur="1.2s" repeatcount="indefinite" begin="0.8s" /> </line> <line x1="3.879" y1="41.868" x2="23.904" y2="45.399" opacity="0.2"> <animate attributetype="css" attributename="opacity" from="1" to="0.1" dur="1.2s" repeatcount="indefinite" begin="0.9333s" /> </line> <line x1="19.897" y1="14.124" x2="32.966" y2="29.7" opacity="0.2"> <animate attributetype="css" attributename="opacity" from="1" to="0.1" dur="1.2s" repeatcount="indefinite" begin="1.0666s" /> </line> </g> </svg>
this works in firefox, not in chrome or safari. in chrome , safari, first 'frame' of animation shown, spinner not animating.
does know how solve problem?
thanks!
apparently chrome not (automatically) play animations in embedded external svg files, found out when svg referenced use
element not loaded external file somewhere within document.
a temporary solution follows:
Comments
Post a Comment