| 79 | }; |
| 80 | |
| 81 | const reveal = () => { |
| 82 | placeBar(); |
| 83 | const lit = row.querySelector(litSelector); |
| 84 | |
| 85 | if (!row.clientWidth || !lit) { |
| 86 | return; |
| 87 | } |
| 88 | |
| 89 | // Not scrollIntoView: it would also scroll the page to a row below the fold. |
| 90 | const rowBox = row.getBoundingClientRect(); |
| 91 | const litBox = lit.getBoundingClientRect(); |
| 92 | |
| 93 | if (litBox.right > rowBox.right - rowInset) { |
| 94 | row.scrollLeft += litBox.right - rowBox.right + rowInset; |
| 95 | } else if (litBox.left < rowBox.left + rowInset) { |
| 96 | row.scrollLeft -= rowBox.left + rowInset - litBox.left; |
| 97 | } |
| 98 | }; |
| 99 | |
| 100 | reveal(); |
| 101 | const mutations = new MutationObserver(reveal); |