IntersectionObserver
を使って, ドーナツチャートがスクリーンに入った(入りきった)ことを検知してからアニメーションを開始するようすればよいでしょう.
IntersectionObserver
の使い方の例
JavaScript
1const observer = new IntersectionObserver(
2 changes => changes[0].intersectionRatio >= 1 ? draw() : null,
3 {threshold: 1}
4);
5observer.observe(canvas);
6function draw(){
7 canvas.width = canvas.height = 200;
8 const ctx = canvas.getContext("2d");
9 ctx.fillStyle = "blue";
10 ctx.fillRect(0, 0, 200, 200);
11 observer.unobserve(canvas);
12}
参考
https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/03/23 02:55 編集
2018/03/23 12:04
2018/03/23 12:08