|
4 | 4 | let right: SVGPathElement | null = null;
|
5 | 5 | let play: SVGPathElement | null = null;
|
6 | 6 | let first = true;
|
| 7 | + let playTimeout = 0; |
7 | 8 | let animate = (el: SVGPathElement, from: string, to: string, reverse: boolean) => {
|
8 | 9 | let anim: SVGAnimateElement | null = el.querySelector('animate');
|
9 | 10 | if (!anim) {
|
|
40 | 41 | 'M 49.9 30, L 85 50, l 0 0, L 49.9 70, Z',
|
41 | 42 | playing
|
42 | 43 | );
|
43 |
| - animate(play, 'M 50 50, l 0 0, l 0 0, Z', 'M 15 10, L 85 50, L 15 90, Z', playing); |
| 44 | + if (!playing) { |
| 45 | + playTimeout = window.setTimeout(() => { |
| 46 | + play.setAttribute('d', 'M 15 10, L 85 50, L 15 90, Z'); |
| 47 | + }, 200); |
| 48 | + } else { |
| 49 | + play.setAttribute('d', 'M 50 50, l 0 0, l 0 0, Z'); |
| 50 | + window.clearTimeout(playTimeout); |
| 51 | + } |
44 | 52 | }
|
45 | 53 | $: {
|
46 | 54 | if (left && right && play) transition(left, right, play, playing);
|
|
62 | 70 | <path bind:this={right} d="M 49.9 30, L 85 50, l 0 0, L 49.9 70, Z">
|
63 | 71 | <animate attributeName="d" dur="0.2s" fill="freeze" begin="indefinite" />
|
64 | 72 | </path>
|
65 |
| - <path bind:this={play} d="M 15 10, L 85 50, L 15 90, Z"> |
66 |
| - <animate attributeName="d" dur="0.2s" fill="freeze" begin="indefinite" /> |
67 |
| - </path> |
| 73 | + <path bind:this={play} d="M 15 10, L 85 50, L 15 90, Z" /> |
68 | 74 | </svg>
|
0 commit comments