回答編集履歴
1
chousei
test
CHANGED
@@ -27,3 +27,82 @@
|
|
27
27
|
<circle cx="100" cy="100" r="50" fill="transparent" stroke="#fff" stroke-width="10" class="circle-animation" />
|
28
28
|
</svg>
|
29
29
|
```
|
30
|
+
|
31
|
+
# 調整版
|
32
|
+
別の所をクリックしたときにアクティブが外れる処理って感じですかね?
|
33
|
+
一応ざっと入れておきました
|
34
|
+
|
35
|
+
```css
|
36
|
+
<style>
|
37
|
+
.circle-animation.leave {
|
38
|
+
animation: dashFadeOut linear 2s forwards;
|
39
|
+
}
|
40
|
+
@keyframes dashFadeOut {
|
41
|
+
0% {
|
42
|
+
stroke-dashoffset: 314;
|
43
|
+
opacity: 1;
|
44
|
+
}
|
45
|
+
70% {
|
46
|
+
stroke-dashoffset: 0;
|
47
|
+
opacity: 1;
|
48
|
+
}
|
49
|
+
100% {
|
50
|
+
stroke-dashoffset: 0;
|
51
|
+
opacity: 0;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
.circle-wrapper-sp.active .circle-animation{
|
55
|
+
r:10px;
|
56
|
+
fill:white;
|
57
|
+
}
|
58
|
+
.circle-wrapper-sp:not(.leave) .circle{
|
59
|
+
opacity:0;
|
60
|
+
}
|
61
|
+
.circle-wrapper-sp{
|
62
|
+
transform: rotate(-90deg);
|
63
|
+
}
|
64
|
+
.circle-wrapper-sp.leave .circle{
|
65
|
+
animation: circle 1s forwards;
|
66
|
+
}
|
67
|
+
|
68
|
+
@keyframes circle {
|
69
|
+
0% { stroke-dasharray: 0 502; opacity:1; }
|
70
|
+
50% { opacity:1; }
|
71
|
+
99.9%,to { stroke-dasharray: 502 502; opacity:0;}
|
72
|
+
}
|
73
|
+
</style>
|
74
|
+
<script>
|
75
|
+
document.addEventListener('animationend',({target})=>{
|
76
|
+
const c=target.closest('.leave')?.classList;
|
77
|
+
if(target.matches('.circle') && c){
|
78
|
+
c.remove('leave');
|
79
|
+
c.remove('active');
|
80
|
+
}
|
81
|
+
});
|
82
|
+
document.addEventListener('click',({target})=>{
|
83
|
+
const c1=target.closest('.circle-wrapper-sp:not(.active,.leave)')?.classList;
|
84
|
+
const c2=document.querySelector('.circle-wrapper-sp.active')?.classList;
|
85
|
+
if(c1){
|
86
|
+
if(c2) c2.add('leave');
|
87
|
+
c1.add('active');
|
88
|
+
}
|
89
|
+
});
|
90
|
+
|
91
|
+
</script>
|
92
|
+
<svg viewBox="0 0 200 200" width=100 height=100 class="circle-wrapper-sp">
|
93
|
+
<rect width="200" height="200" fill="red" />
|
94
|
+
<circle cx="100" cy="100" r="5" fill="transparent" stroke="#fff" stroke-width="10" class="circle-animation" />
|
95
|
+
<circle cx="100" cy="100" r="80" fill="transparent" stroke="#fff" stroke-width="10" class="circle" />
|
96
|
+
</svg>
|
97
|
+
<svg viewBox="0 0 200 200" width=100 height=100 class="circle-wrapper-sp">
|
98
|
+
<rect width="200" height="200" fill="red" />
|
99
|
+
<circle cx="100" cy="100" r="5" fill="transparent" stroke="#fff" stroke-width="10" class="circle-animation" />
|
100
|
+
<circle cx="100" cy="100" r="80" fill="transparent" stroke="#fff" stroke-width="10" class="circle" />
|
101
|
+
</svg>
|
102
|
+
<svg viewBox="0 0 200 200" width=100 height=100 class="circle-wrapper-sp">
|
103
|
+
<rect width="200" height="200" fill="red" />
|
104
|
+
<circle cx="100" cy="100" r="5" fill="transparent" stroke="#fff" stroke-width="10" class="circle-animation" />
|
105
|
+
<circle cx="100" cy="100" r="80" fill="transparent" stroke="#fff" stroke-width="10" class="circle" />
|
106
|
+
</svg>
|
107
|
+
|
108
|
+
```
|