質問編集履歴
2
1つで動くバージョンの追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -34,6 +34,8 @@
|
|
34
34
|
|
35
35
|
### 該当のソースコード
|
36
36
|
|
37
|
+
【複数で2個目以降が動かないバージョン】
|
38
|
+
|
37
39
|
|
38
40
|
|
39
41
|
```html
|
@@ -131,3 +133,79 @@
|
|
131
133
|
|
132
134
|
|
133
135
|
```
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
【1つで動くバージョン】
|
140
|
+
|
141
|
+
```html
|
142
|
+
|
143
|
+
<div class="wrap">
|
144
|
+
|
145
|
+
<svg id="test" width="750" height="400">
|
146
|
+
|
147
|
+
<path x="0" y="0" id="js-svg-body" d="M653.452 394.933c-18.731 4.276-60.67-5.921-84.289-11.759-88.179-21.8-236.886-19.2-338.194 6.414-67.639 17.1-98.764 8.775-132.156 5.345C67.6 391.726.157 369.306 13.484 317.965c20.812-80.175 5.657-125.213-3.121-151.8C3.259 144.656-2.359 111.177 1 98.821c12.487-45.967 54.55-60.744 103.019-80.175 42.665-17.1 106.141-21.38 148.806-17.1 84.9 8.509 192.541 51.993 262.23 21.38C558.855 3.68 646.078 5.773 675.3 20.784c18.731 9.621 74.923 35.277 63.477 94.072-5.211 26.763-9.366 78.037 1.04 103.692 8.5 20.969 12.931 75.144 8.325 94.072-12.483 51.312-56.763 73.655-94.69 82.313z"/>
|
148
|
+
|
149
|
+
</svg>
|
150
|
+
|
151
|
+
</div>
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
```
|
156
|
+
|
157
|
+
```js
|
158
|
+
|
159
|
+
let $svgBody = Snap('#js-svg-body'),
|
160
|
+
|
161
|
+
path =['M653.452 394.933c-18.731 4.276-60.67-5.921-84.289-11.759-88.179-21.8-236.886-19.2-338.194 6.414-67.639 17.1-98.764 8.775-132.156 5.345C67.6 391.726.157 369.306 13.484 317.965c20.812-80.175 5.657-125.213-3.121-151.8C3.259 144.656-2.359 111.177 1 98.821c12.487-45.967 54.55-60.744 103.019-80.175 42.665-17.1 106.141-21.38 148.806-17.1 84.9 8.509 192.541 51.993 262.23 21.38C558.855 3.68 646.078 5.773 675.3 20.784c18.731 9.621 74.923 35.277 63.477 94.072-5.211 26.763-9.366 78.037 1.04 103.692 8.5 20.969 12.931 75.144 8.325 94.072-12.483 51.312-56.763 73.655-94.69 82.313z',
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
'M646.924 390.1c-53.039-5.959-83.193-4.684-107.079 0-85.225 16.715-190.888 8.9-293.215 1-59.013-4.557-87.085-4.1-148.3 5.892-30.836 5.033-86.8-23.782-85.392-76.446 1.517-56.58-13.494-93.329-3.124-150.77C13.817 147.625-2.91 90.5.449 78.23 12.945 32.574 51.9 15.319 103.541 23.251c54.023 8.3 112.066 1.344 180.116-17.527C372.881-19.019 475.77 45.83 548.852 23.6 610.9 4.731 673.718 6.706 702.965 21.616c18.745 9.555 25.5 18.161 33.025 48.668C748 118.952 750 159.674 750 203.376c0 64.123-1.289 78.037-10.007 122.167-10.008 50.657-54.385 68.907-93.069 64.557z',
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
'M653.667 391.333c-52.723 8.487-79.008 8.146-114.167.716-85.046-17.972-190.864-6.4-293.248 1.012-88.639 6.418-146.646 9.473-181.65 4.382-30.933-4.5-56.006-18.33-52.063-76.228 3.633-53.342 25.516-86.246 2.058-140.674C4.777 157.757.446 87.413.044 74.463-1.4 27.793 33.058 24.889 84.6 20.665 138.623 16.237 215.619-3.775 283.284.629c92.412 6.014 194.364 13.926 265.224 18.2 64.745 3.911 81.191-4.5 136.163-9.371 20.963-1.857 61.017 25.576 58.006 59.063-4.57 50.833-30 90.653-10 131.363 28.693 58.4 17 124.235-1 145.619-33.608 39.927-41.93 40.021-78.01 45.83z'],
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
SPEED =1500,
|
174
|
+
|
175
|
+
EASING = mina.linear,
|
176
|
+
|
177
|
+
i = 0;
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
function AnimationSvg(){
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
$svgBody.animate({d: path[i] },SPEED,EASING,AnimationSvg);
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
i++;
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
if(i === path.length){
|
194
|
+
|
195
|
+
i = 0;
|
196
|
+
|
197
|
+
}
|
198
|
+
|
199
|
+
}
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
AnimationSvg();
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
```
|
1
codepenURLを追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -19,6 +19,16 @@
|
|
19
19
|
|
20
20
|
|
21
21
|
どのように指定すれば2つ目以降も同様のjsを適用できるでしょうか??
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
codepenにもソースコードを載せています。
|
30
|
+
|
31
|
+
https://codepen.io/lisaaaan/pen/poJdxqZ
|
22
32
|
|
23
33
|
|
24
34
|
|