2016-04-12 21 views
0

ダッシュオフセットアニメーション技術を使用して簡単なスピナーを作成しています。あなたは私がhereを持っているのを見ることができます。あなたが見ることができるように、多角形は決して閉じません。マイターコーナーを上に置くのではなく、パスが図形を完成させるようにする簡単な方法はありますか?ストロークダッシュオフセットのアニメートでは形状を閉じることができません

SVGのパスを上書きして、最終コーナーを完成させることができます。残念ながら、それは理想的ではないアニメーションで覆い隠すことができます。

HTML

<div class="logo-container"> 
    <svg class="is2-logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 243.514 195.632"> 
    <path class="gray-path" fill="none" stroke="#9A9A9A" stroke-width="16" stroke-miterlimit="10" d="M121.71 64.26l106.08 61.04-106.08 61.033L15.724 125.3z"/> 
    <path class="blue-path" fill="none" stroke="#00B3E9" stroke-width="16" stroke-miterlimit="10" d="M121.71 9.225l106.08 61.04-106.08 61.032L15.724 70.265z"/> 
    </svg> 
</div> 

CSS

.logo-container { 
    width: 400px; 
    .is2-logo path { 
    stroke-dasharray: 1000; 
    stroke-dashoffset: 1000; 
    } 
    .blue-path { 
    animation: dash 2s linear forwards infinite; 
    } 
    .gray-path { 
    animation: dash 2s linear forwards infinite .5s; 
    } 
} 

@keyframes dash { 
    0% { 
    stroke-dashoffset: 1000; 
    } 
    50% { 
    stroke-dashoffset: 0; 
    } 
    100% { 
    stroke-dashoffset: -1000; 
    } 
} 
+0

他の2つのパスを作成することパスを閉じたままにしたい場合を除き、目に見えません。 –

+0

私の代替計画のようなものでしたが、それは複雑さを増し、いくつかの努力を重ねます。また、画像や色付きの背景に配置したい場合にも問題が発生します。より洗練されたソリューションがあることを願っています。 –

答えて

0

ではなく、上部にあるマイターコーナーを残すの形状を完了します。

実際には、上部にバットのラインキャップが残っています。

灰色のような丸い線が青い線になるのはなぜですか?

.logo-container { 
 
    width: 400px; 
 
} 
 
.logo-container .is2-logo path { 
 
    stroke-dasharray: 1000; 
 
    stroke-dashoffset: 1000; 
 
} 
 
.logo-container .blue-path { 
 
    animation: dash 5s linear forwards infinite; 
 
} 
 
.logo-container .gray-path { 
 
    animation: dash 5s linear forwards infinite .5s; 
 
} 
 

 
@keyframes dash { 
 
    0% { 
 
    stroke-dashoffset: 1000; 
 
    } 
 
    50% { 
 
    stroke-dashoffset: 0; 
 
    } 
 
    100% { 
 
    stroke-dashoffset: -1000; 
 
    } 
 
}
<div class="logo-container"> 
 
    <svg class="is2-logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 243.514 195.632"> 
 
    <path class="gray-path" fill="none" stroke="#9A9A9A" stroke-linecap="round" stroke-width="16" stroke-linejoin="round" stroke-miterlimit="10" d="M121.71 64.26l106.08 61.04-106.08 61.033L15.724 125.3z"/> 
 
    <path class="blue-path" fill="none" stroke="#00B3E9" stroke-width="16" stroke-linejoin="round" stroke-linecap="round" stroke-miterlimit="10" d="M121.71 9.225l106.08 61.04-106.08 61.032L15.724 70.265z"/> 
 
    </svg> 
 
</div>

+0

残念ながら、クライアントのロゴは四捨五入されていないので、私は彼らがこの解決法を拒否すると仮定しています。しかし、それは簡単に最もエレガントです。私は今、マーカーの開始/終了を使用して調べています。 –

+0

ロゴの角は丸められていませんか?ブルーダイヤモンドの上隅だけ? –

+0

角を丸くしてはならず、スタックされたダイヤモンドのように見えるべきです。私のペンがこの混乱につながるコーナーを丸めてしまった場合は謝罪します。 –

0

なぜあなたはちょうど同じオフセットをダッシュ​​を残して、他の足でパスを拡張しない:

<svg class="is2-logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 243.514 195.632"> 
 
    <path class="gray-path" fill="none" stroke="#9A9A9A" stroke-linejoin="round" stroke-width="16" stroke-miterlimit="10" d="M121.71 64.26l106.08 61.04-106.08 61.033L15.724 125.3 l106.08 -61.04 106.08 61.04" marker-end="url(#gray-start)"/> 
 
    <path class="blue-path" fill="none" stroke="#00B3E9" stroke-linejoin="round" stroke-width="16" stroke-miterlimit="10" d="M121.71 9.225 l106.08 61.04 -106.08 61.032 L15.724 70.265 l106.08 -61.04 106.08 61.04"/> 
 
    </svg>

関連する問題