| 56 | |
| 57 | // The bar follows the lit label; it only slides once it has a place. |
| 58 | const placeBar = () => { |
| 59 | const bar = barRef.current; |
| 60 | const lit = row.querySelector<HTMLElement>(litSelector); |
| 61 | const label = lit?.querySelector<HTMLElement>('[data-tab-label]'); |
| 62 | |
| 63 | if (!bar || !lit || !label) { |
| 64 | if (bar) { |
| 65 | bar.style.opacity = '0'; |
| 66 | } |
| 67 | return; |
| 68 | } |
| 69 | |
| 70 | const left = |
| 71 | lit.offsetLeft + |
| 72 | label.offsetLeft + |
| 73 | label.offsetWidth / 2 - |
| 74 | barWidth / 2; |
| 75 | const isPlaced = bar.style.opacity === '1'; |
| 76 | bar.style.transition = isPlaced ? '' : 'none'; |
| 77 | bar.style.transform = `translateX(${left}px)`; |
| 78 | bar.style.opacity = '1'; |
| 79 | }; |
| 80 | |
| 81 | const reveal = () => { |
| 82 | placeBar(); |