2016-08-19 11 views
1

SVGサークルをアニメーションできますか?SVG画像のアニメーション

<svg> 
    <circle id="orange-circle" r="30" cx="50" cy="50" fill="orange" /> 
    <animate 
     xlink:href="#orange-circle" 
     attributeName="cx" 
     from="50" 
     to="450" 
     dur="1s" 
     fill="freeze" 
     repeatCount="indefinite" /> 
</svg> 

同様に、私は、画像をアニメーション化しようとしています:

<svg> 
    <image id="orange-circle" x="0" y="20" width="200" height="180" xlink:href="cat.png" /> 
    <animate 
     xlink:href="#orange-circle" 
     attributeName="cx" 
     from="50" 
     to="450" 
     dur="1s" 
     fill="freeze" 
     repeatCount="indefinite" /> 
</svg> 

は、どのように私は上記のコードの作業を行うことができますか?画像付き

+0

実際の問題は何ですか?アニメーションが開始されていませんか?彼らとは何が正しいのですか?役割を果たしている可能性のある周囲のコードはありますか? – dakab

+0

FAQアニメーションをご覧ください:https://css-tricks.com/transforms-on-svg-elements/ – KingRider

答えて

1

例コード(簡単には)美しい:

<svg> 
 
    <circle fill="blue" cx="150" cy="100" r="50"></circle> 
 
    <image xlink:href="http://i.imgur.com/ANS7Rkc.png" x="-50" y="72" width="100" height="50"> 
 
    <animate attributeName="x" from="-50" to="300" dur="5s" repeatCount="indefinite"></animate> 
 
    </image> 
 
</svg>

例(非画像) https://codepen.io/danjiro/post/how-to-make-svg-loop-animation

チュートリアル: https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial

enjoin us;)

+0

ありがとうございました。 –

関連する問題