2015-01-22 2 views
1

아래 코드에서 알 수 있듯이 멋진 순환 진행 표시 줄이 있습니다. 그러나 몇 가지 질문이 있으며이를 수행하는 방법에 대해서는 약간의 손실이 있습니다 (이상적으로는 나는 주위 만곡 간다 분홍색 줄을 만들고 싶어하고 평평하지 )CSS SVG 경로 - 순환 진행 표시 줄 (작은 앰먼트)

  1. 어떤 JS를 사용하려면,이 가능할까요? 그것의 가장자리처럼. 그래서 그 대신에 | 시작과 끝에서 조금 닮았습니다.)
  2. 중간에 떨리는 원이 생기면 을 다시 시작하기 전에 애니메이션이 완료되면 1 초 동안 을 일시 중지 할 수 있습니까?

/* Load Progress Animation */ 
 

 
@-webkit-keyframes load { 
 
    0% { 
 
    stroke-dashoffset: 0 
 
    } 
 
} 
 
@-moz-keyframes load { 
 
    0% { 
 
    stroke-dashoffset: 0 
 
    } 
 
} 
 
@keyframes load { 
 
    0% { 
 
    stroke-dashoffset: 0 
 
    } 
 
} 
 
/* Qik Progress Container */ 
 

 
.progress { 
 
    position: relative; 
 
    display: inline-block; 
 
    padding: 0; 
 
    text-align: center; 
 
} 
 
/* Item SVG */ 
 

 
.progress svg { 
 
    width: 4rem; 
 
    height: 4rem; 
 
} 
 
.progress svg:nth-child(2) { 
 
    position: absolute; 
 
    left: 0; 
 
    top: 0; 
 
    transform: rotate(-90deg); 
 
    -webkit-transform: rotate(-90deg); 
 
    -moz-transform: rotate(-90deg); 
 
    -ms-transform: rotate(-90deg); 
 
} 
 
.progress svg:nth-child(2) path { 
 
    fill: none; 
 
    stroke-width: 20; 
 
    stroke-dasharray: 629; 
 
    stroke: rgba(60, 99, 121, 0.9); 
 
    -webkit-animation: load 8s; 
 
    -moz-animation: load 8s; 
 
    -o-animation: load 8s; 
 
    animation: load 8s; 
 
} 
 
.pulse { 
 
    border-radius: 50%; 
 
    width: 18px; 
 
    height: 18px; 
 
    background: #ff1251; 
 
    position: absolute; 
 
    top: 1.45rem; 
 
    left: 1.45rem; 
 
    -webkit-animation: pulse 0.6s linear infinite; 
 
    -moz-animation: pulse 0.6s linear infinite; 
 
    -ms-animation: pulse 0.6s linear infinite; 
 
    animation: pulse 0.6s linear infinite; 
 
} 
 
@keyframes "pulse" { 
 
    0% { 
 
    -webkit-transform: scale(1); 
 
    -moz-transform: scale(1); 
 
    -o-transform: scale(1); 
 
    -ms-transform: scale(1); 
 
    transform: scale(1); 
 
    } 
 
    50% { 
 
    -moz-transform: scale(0.8); 
 
    -o-transform: scale(0.8); 
 
    -ms-transform: scale(0.8); 
 
    transform: scale(0.8); 
 
    } 
 
    100% { 
 
    -webkit-transform: scale(1); 
 
    -moz-transform: scale(1); 
 
    -o-transform: scale(1); 
 
    -ms-transform: scale(1); 
 
    transform: scale(1); 
 
    } 
 
} 
 
@-moz-keyframes pulse { 
 
    0% { 
 
    -moz-transform: scale(1); 
 
    transform: scale(1); 
 
    } 
 
    50% { 
 
    -moz-transform: scale(0.8); 
 
    transform: scale(0.8); 
 
    } 
 
    100% { 
 
    -moz-transform: scale(1); 
 
    transform: scale(1); 
 
    } 
 
} 
 
@-webkit-keyframes "pulse" { 
 
    0% { 
 
    -webkit-transform: scale(1); 
 
    transform: scale(1); 
 
    } 
 
    50% { 
 
    -webkit-transform: scale(0.8); 
 
    transform: scale(0.8); 
 
    } 
 
    100% { 
 
    -webkit-transform: scale(1); 
 
    transform: scale(1); 
 
    } 
 
} 
 
@-ms-keyframes "pulse" { 
 
    0% { 
 
    -ms-transform: scale(1); 
 
    transform: scale(1); 
 
    } 
 
    50% { 
 
    -ms-transform: scale(0.8); 
 
    transform: scale(0.8); 
 
    } 
 
    100% { 
 
    -ms-transform: scale(1); 
 
    transform: scale(1); 
 
    } 
 
}
<div class="progress"> 
 
    <svg viewBox="-10 -10 220 220"> 
 
    <g fill="none" stroke-width="20" transform="translate(100,100)"> 
 
     <path d="M-100,0a100,100 0 1,0 200,0a100,100 0 1,0 -200,0" stroke="#FF1252" stroke-linejoin="round" /> 
 
    </g> 
 
    </svg> 
 
    <svg viewBox="-10 -10 220 220"> 
 
    <path d="M200,100 C200,44.771525 155.228475,0 100,0 C44.771525,0 0,44.771525 0,100 C0,155.228475 44.771525,200 100,200 C155.228475,200 200,155.228475 200,100 Z" stroke-dashoffset="629"></path> 
 
    </svg> 
 
    <div class="pulse"></div> 
 
</div>

답변

2

전체 코드를 다시 작성했습니다.

첫 번째 질문에 대해서는 간단히 stroke-linecap="round"을 사용할 수 있습니다.

지연에 대한 추가 @keyframes 규칙을 추가해야합니다.

body { 
 
    background: #072237; 
 
} 
 
h3 { 
 
    color: #ffffff; 
 
} 
 
#loader { 
 
    position: relative; 
 
    width: 80px; 
 
    height: 80px; 
 
} 
 
#ring { 
 
    -webkit-animation: load 6s 1 forwards; 
 
    animation: load 6s 1 forwards; 
 
} 
 
#circle { 
 
    position: absolute; 
 
    width: 20px; 
 
    height: 20px; 
 
    top: 50%; 
 
    left: 50%; 
 
    margin-left: -10px; 
 
    margin-top: -10px; 
 
    background: #FF1251; 
 
    border-radius: 50%; 
 
    transform: scale(0.8); 
 
    -webkit-animation: pulse 1.2s 3; 
 
    animation: pulse 1.2s 3; 
 
    -webkit-transform-origin: 50% 50%; 
 
    transform-origin: 50% 50%; 
 
} 
 
@-webkit-keyframes pulse { 
 
    0% { 
 
    transform: scale(0.8); 
 
    } 
 
    20% { 
 
    transform: scale(1); 
 
    } 
 
    40% { 
 
    transform: scale(0.8); 
 
    } 
 
    100% { 
 
    transform: scale(0.8); 
 
    } 
 
} 
 
@keyframes pulse { 
 
    0% { 
 
    transform: scale(0.8); 
 
    } 
 
    20% { 
 
    transform: scale(1); 
 
    } 
 
    40% { 
 
    transform: scale(0.8); 
 
    } 
 
    100% { 
 
    transform: scale(0.8); 
 
    } 
 
} 
 
@-webkit-keyframes load { 
 
    80% { 
 
    stroke-dashoffset: 0; 
 
    } 
 
    100% { 
 
    stroke-dashoffset: 0; 
 
    } 
 
} 
 
@keyframes load { 
 
    80% { 
 
    stroke-dashoffset: 0; 
 
    } 
 
    100% { 
 
    stroke-dashoffset: 0; 
 
    } 
 
}
<div id="loader"> 
 
    <svg height="80" width="80" viewBox="-10 -10 220 220"> 
 
    <path id="back" d="M0,100 a100,100 0 1 0 200,0 a100,100 0 1 0 -200,0" fill="#FFFFFF" stroke="#034870" stroke-width="20" stroke-linecap="round" /> 
 
    <path id="ring" d="M100,0 a100,100 0 0 1 0,200 a100,100 0 0 1 0,-200,0" fill="none" stroke="#FF1251" stroke-width="20" stroke-dasharray="629" stroke-linecap="round" stroke-dashoffset="629" /> 
 
    </svg> 
 
    <div id="circle"></div> 
 
</div>

+0

그게 사랑스러운 친구 고마워요! 단지 빠른 것, 그것이 성장하고 축소 할 때를 알 수 있습니다. 다시 성장하기 전에 잠시 멈출 수 있습니까? –

+0

@JamesBrandon - 업데이트를 확인하십시오. 이게 네가 말하는거야? 나는 그것을 다시 업데이트했다. –

+0

차이점을 볼 수 있을지 모르겠으니, 이론적으로는 grow/skrink (1 초 정지) 성장/축소 (1 초 정지) 등입니다. –

0

1 호는 stroke-linecap를 사용 가능하지만, 귀하의 경우 빨간색 선은 실제로 배경과 스트로크 회색 변경할 수 없기은, 코드의 일부를 변경해야합니다 - 그래서 그것은 붉은 선의 끝 부분에 "(", "not") 오목한 원을 만들 것입니다. 2. alternate으로 설정된 긴 애니메이션을 사용하여 수행 할 수 있으므로 50 %에서 100 % 사이에서 "잠자기"됩니다.

SVG에서

http://jsfiddle.net/3yq3kmo1/

변경 (두 번째 요소) :

<svg viewBox="-10 -10 220 220"> 
    <circle r="100" cx="100" cy="100" stroke-dashoffset="0" /> 
</svg> 

CSS합니다 (dashoffset이 역전되어 있습니다, 그래서 지금은 빨간색 스트로크가 성장하고 가죽 나는 약간 변경 한 대신 적색 수축 및 회색을 드러내는 회색; 제 SVG 요소 경로상의 stroke 지금 회색)

.progress svg:nth-child(2) circle { 
    fill: none; 
    stroke-width: 20; 
    stroke-dasharray: 629; 
    stroke: #ff1251; 
    stroke-linecap:round; 
    animation: load 8s; 
} 

일시 정지한다. 애니메이션 :

.pulse { 
    animation: pulse 1.6s linear infinite alternate; 
} 
@keyframes pulse { 
0% { 
    transform: scale(0.8); 
    } 
    50% { 
    transform: scale(1); 
    } 
    100% { 
    transform: scale(1); 
    } 
} 
+0

아이 많은 덕분에 좋은 이잖아! 어떤 이유로 중간 펄스 원이 작동하지 않습니다 ... 어떤 생각입니까? –

+0

나를 위해 일하지만 모든 접두사 접두어를 붙인 코드 인'-webkit-'만 업데이트하도록 신경 쓰지는 않았다. – pawel

+0

Ahh yea 나는 그것을 지금 본다, 멈추고 멈추는 것을 멈춘다, 성장하는 길은 그 다음 멈추고 다시 멈춘다? 또한 애니메이션 전환이 부드럽지 않고 분홍색 진행률 표시 줄 뒤에 회색이 약간 나타날 수 있다는 사실을 알게되었습니다 ... 그 어떤 아이디어라도 모든 도움을 주셔서 감사합니다! masisve 도움이되었습니다! –