回答編集履歴
1
コードの修正 説明の修正
test
CHANGED
@@ -14,6 +14,16 @@
|
|
14
14
|
|
15
15
|
|
16
16
|
|
17
|
+
ガーベージコレクションを強制実行させようと格闘しましたが上手くいかなかったので、
|
18
|
+
|
19
|
+
一度画面外に出てフェードアウトしたときにチャートを破棄しているのですが、再度画面に
|
20
|
+
|
21
|
+
入ってきたときに、前のチャートが残ってしまってます。その状態から再描画されます。
|
22
|
+
|
23
|
+
申し訳ありません。
|
24
|
+
|
25
|
+
|
26
|
+
|
17
27
|
|
18
28
|
|
19
29
|
```HTML
|
@@ -84,7 +94,7 @@
|
|
84
94
|
|
85
95
|
transform : translate(0, 50px);
|
86
96
|
|
87
|
-
transition : all
|
97
|
+
transition : all 8000ms;
|
88
98
|
|
89
99
|
}
|
90
100
|
|
@@ -116,11 +126,17 @@
|
|
116
126
|
|
117
127
|
<script>
|
118
128
|
|
129
|
+
|
130
|
+
|
131
|
+
var drowing = false;
|
132
|
+
|
133
|
+
|
134
|
+
|
119
135
|
$('#doughnut07').on('inview', function(event, isInView){ /* doughnut07はidなので、#で始めなければならない */
|
120
136
|
|
121
137
|
/*▼▼▼スクロール効果▼▼▼*/
|
122
138
|
|
123
|
-
if (isInView){
|
139
|
+
if (isInView){ /*画面内に入ったか判定*/
|
124
140
|
|
125
141
|
$('#doughnut07').addClass('scrollin');
|
126
142
|
|
@@ -130,6 +146,18 @@
|
|
130
146
|
|
131
147
|
}
|
132
148
|
|
149
|
+
|
150
|
+
|
151
|
+
setTimeout(drawChart, 8000, isInView, drowing); /* CSSのスクロールアニメーション時間と合わせる*/
|
152
|
+
|
153
|
+
});
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
function drawChart(isInView, drowing) {
|
158
|
+
|
159
|
+
|
160
|
+
|
133
161
|
/*▼▼▼グラフ▼▼▼*/
|
134
162
|
|
135
163
|
var data = [
|
@@ -154,19 +182,85 @@
|
|
154
182
|
|
155
183
|
|
156
184
|
|
185
|
+
if (isInView && !drowing) {
|
186
|
+
|
157
|
-
|
187
|
+
window.myDoughnut = new Chart(document.getElementById("doughnut07").
|
158
|
-
|
188
|
+
|
159
|
-
getContext("2d")).Doughnut(data, {
|
189
|
+
getContext("2d")).Doughnut(data, {
|
160
|
-
|
190
|
+
|
161
|
-
tooltipTemplate: "<%=value%> %",
|
191
|
+
tooltipTemplate: "<%=value%> %",
|
162
|
-
|
192
|
+
|
163
|
-
animation:true,
|
193
|
+
animation:true,
|
164
|
-
|
194
|
+
|
165
|
-
enabled:false,
|
195
|
+
enabled:false,
|
166
196
|
|
167
197
|
});
|
168
198
|
|
169
|
-
}
|
199
|
+
}
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
if (isInView) {
|
204
|
+
|
205
|
+
drowing = true;
|
206
|
+
|
207
|
+
} else {
|
208
|
+
|
209
|
+
if (myDoughnut) {
|
210
|
+
|
211
|
+
myDoughnut.destroy();
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
/*
|
216
|
+
|
217
|
+
// 強制ガーベージコレクション実行
|
218
|
+
|
219
|
+
var userAgent = window.navigator.userAgent.toLowerCase();
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
if (userAgent.indexOf('msie') != -1 || userAgent.indexOf('trident') != -1) {
|
224
|
+
|
225
|
+
//IE向けの記述
|
226
|
+
|
227
|
+
window.CollectGarbage();
|
228
|
+
|
229
|
+
} else if(userAgent.indexOf('edge') != -1) {
|
230
|
+
|
231
|
+
//旧Edge向けの記述
|
232
|
+
|
233
|
+
} else if(userAgent.indexOf('chrome') != -1) {
|
234
|
+
|
235
|
+
//Google Chrome向けの記述
|
236
|
+
|
237
|
+
window.gc();
|
238
|
+
|
239
|
+
} else if(userAgent.indexOf('safari') != -1) {
|
240
|
+
|
241
|
+
//Safari向けの記述
|
242
|
+
|
243
|
+
} else if(userAgent.indexOf('firefox') != -1) {
|
244
|
+
|
245
|
+
//FireFox向けの記述
|
246
|
+
|
247
|
+
} else {
|
248
|
+
|
249
|
+
//その他のブラウザ向けの記述
|
250
|
+
|
251
|
+
}
|
252
|
+
|
253
|
+
*/
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
drowing = false;
|
258
|
+
|
259
|
+
}
|
260
|
+
|
261
|
+
}
|
262
|
+
|
263
|
+
}
|
170
264
|
|
171
265
|
</script>
|
172
266
|
|