|
1389 | 1389 | var target = document.getElementById(this.getAttribute('href').substring(1)); |
1390 | 1390 | if (target) { |
1391 | 1391 | e.preventDefault(); |
1392 | | - // Scroll so the target line sits just below the sticky header |
1393 | | - var header = document.querySelector('.main-header'); |
1394 | | - var headerBottom = header ? header.getBoundingClientRect().bottom : 0; |
1395 | | - var gap = 16; // breathing room below header |
1396 | | - var targetTop = target.getBoundingClientRect().top + window.scrollY; |
1397 | | - window.scrollTo({ top: targetTop - headerBottom - gap, behavior: 'smooth' }); |
| 1392 | + // Scroll within the source-table-container |
| 1393 | + var scrollBox = document.querySelector('.source-table-container'); |
| 1394 | + var row = target.closest('tr'); |
| 1395 | + if (scrollBox && row) { |
| 1396 | + var thead = scrollBox.querySelector('thead'); |
| 1397 | + var theadHeight = thead ? thead.offsetHeight : 0; |
| 1398 | + scrollBox.scrollTo({ top: row.offsetTop - theadHeight - 8, behavior: 'smooth' }); |
| 1399 | + } |
1398 | 1400 | history.replaceState(null, '', this.getAttribute('href')); |
1399 | 1401 | // Highlight the target row (clear any previous highlight first) |
1400 | 1402 | var prev = document.querySelector('.highlight-target'); |
1401 | 1403 | if (prev) prev.classList.remove('highlight-target'); |
1402 | | - var row = target.closest('tr'); |
1403 | 1404 | if (row) row.classList.add('highlight-target'); |
1404 | 1405 | } |
1405 | 1406 | }); |
|
1422 | 1423 | var row = el.closest('tr'); |
1423 | 1424 | if (row) { |
1424 | 1425 | row.classList.add('highlight-target'); |
1425 | | - if (scroll) row.scrollIntoView({ block: 'center' }); |
| 1426 | + if (scroll) { |
| 1427 | + var scrollBox = document.querySelector('.source-table-container'); |
| 1428 | + if (scrollBox) { |
| 1429 | + var thead = scrollBox.querySelector('thead'); |
| 1430 | + var theadHeight = thead ? thead.offsetHeight : 0; |
| 1431 | + scrollBox.scrollTo({ top: row.offsetTop - theadHeight - 8, behavior: 'smooth' }); |
| 1432 | + } else { |
| 1433 | + row.scrollIntoView({ block: 'center' }); |
| 1434 | + } |
| 1435 | + } |
1426 | 1436 | } |
1427 | 1437 | } |
1428 | 1438 |
|
|
0 commit comments