FossilRepo
Fix anchor scroll position — line appears at ~40% from top, not pinned to edge - Use scroll-margin-top: 40vh on .line-row in both code file and diff views - Anchored line shows with space above for context and popover visibility - Remove JS scrollIntoView — CSS handles all anchor positioning natively - Works on both page load and in-page click navigation
Commit
2b89620ac0413784803530ef85e6df527ff0254698c7ae0d67f724c933a03720
Parent
ec8c08f6d5fc757…
2 files changed
+2
-6
+1
-6
| --- templates/fossil/checkin_detail.html | ||
| +++ templates/fossil/checkin_detail.html | ||
| @@ -15,10 +15,11 @@ | ||
| 15 | 15 | .diff-gutter { width: 1%; user-select: none; color: #4b5563; text-align: right; padding: 0 6px; border-right: 1px solid #374151; cursor: pointer; white-space: nowrap; } |
| 16 | 16 | .diff-gutter:hover { color: #DC394C; } |
| 17 | 17 | .diff-gutter a { color: inherit; text-decoration: none; display: block; } |
| 18 | 18 | .line-row:target { background: rgba(220, 57, 76, 0.15) !important; } |
| 19 | 19 | .line-row:target .diff-gutter { color: #DC394C; font-weight: 600; } |
| 20 | + .line-row { scroll-margin-top: 40vh; } | |
| 20 | 21 | .line-popover { |
| 21 | 22 | position: absolute; left: 100%; top: 50%; transform: translateY(-50%); |
| 22 | 23 | margin-left: 4px; z-index: 20; white-space: nowrap; |
| 23 | 24 | background: #1f2937; border: 1px solid #374151; border-radius: 6px; |
| 24 | 25 | box-shadow: 0 4px 12px rgba(0,0,0,0.4); padding: 2px; |
| @@ -144,12 +145,7 @@ | ||
| 144 | 145 | </div> |
| 145 | 146 | </div> |
| 146 | 147 | {% endfor %} |
| 147 | 148 | {% endif %} |
| 148 | 149 | </div> |
| 149 | -<script> | |
| 150 | - if (window.location.hash) { | |
| 151 | - const el = document.querySelector(window.location.hash); | |
| 152 | - if (el) el.scrollIntoView({ behavior: 'smooth', block: 'center' }); | |
| 153 | - } | |
| 154 | -</script> | |
| 150 | +<!-- scroll-margin-top on .line-row handles anchor positioning via CSS --> | |
| 155 | 151 | {% endblock %} |
| 156 | 152 |
| --- templates/fossil/checkin_detail.html | |
| +++ templates/fossil/checkin_detail.html | |
| @@ -15,10 +15,11 @@ | |
| 15 | .diff-gutter { width: 1%; user-select: none; color: #4b5563; text-align: right; padding: 0 6px; border-right: 1px solid #374151; cursor: pointer; white-space: nowrap; } |
| 16 | .diff-gutter:hover { color: #DC394C; } |
| 17 | .diff-gutter a { color: inherit; text-decoration: none; display: block; } |
| 18 | .line-row:target { background: rgba(220, 57, 76, 0.15) !important; } |
| 19 | .line-row:target .diff-gutter { color: #DC394C; font-weight: 600; } |
| 20 | .line-popover { |
| 21 | position: absolute; left: 100%; top: 50%; transform: translateY(-50%); |
| 22 | margin-left: 4px; z-index: 20; white-space: nowrap; |
| 23 | background: #1f2937; border: 1px solid #374151; border-radius: 6px; |
| 24 | box-shadow: 0 4px 12px rgba(0,0,0,0.4); padding: 2px; |
| @@ -144,12 +145,7 @@ | |
| 144 | </div> |
| 145 | </div> |
| 146 | {% endfor %} |
| 147 | {% endif %} |
| 148 | </div> |
| 149 | <script> |
| 150 | if (window.location.hash) { |
| 151 | const el = document.querySelector(window.location.hash); |
| 152 | if (el) el.scrollIntoView({ behavior: 'smooth', block: 'center' }); |
| 153 | } |
| 154 | </script> |
| 155 | {% endblock %} |
| 156 |
| --- templates/fossil/checkin_detail.html | |
| +++ templates/fossil/checkin_detail.html | |
| @@ -15,10 +15,11 @@ | |
| 15 | .diff-gutter { width: 1%; user-select: none; color: #4b5563; text-align: right; padding: 0 6px; border-right: 1px solid #374151; cursor: pointer; white-space: nowrap; } |
| 16 | .diff-gutter:hover { color: #DC394C; } |
| 17 | .diff-gutter a { color: inherit; text-decoration: none; display: block; } |
| 18 | .line-row:target { background: rgba(220, 57, 76, 0.15) !important; } |
| 19 | .line-row:target .diff-gutter { color: #DC394C; font-weight: 600; } |
| 20 | .line-row { scroll-margin-top: 40vh; } |
| 21 | .line-popover { |
| 22 | position: absolute; left: 100%; top: 50%; transform: translateY(-50%); |
| 23 | margin-left: 4px; z-index: 20; white-space: nowrap; |
| 24 | background: #1f2937; border: 1px solid #374151; border-radius: 6px; |
| 25 | box-shadow: 0 4px 12px rgba(0,0,0,0.4); padding: 2px; |
| @@ -144,12 +145,7 @@ | |
| 145 | </div> |
| 146 | </div> |
| 147 | {% endfor %} |
| 148 | {% endif %} |
| 149 | </div> |
| 150 | <!-- scroll-margin-top on .line-row handles anchor positioning via CSS --> |
| 151 | {% endblock %} |
| 152 |
+1
-6
| --- templates/fossil/code_file.html | ||
| +++ templates/fossil/code_file.html | ||
| @@ -19,10 +19,11 @@ | ||
| 19 | 19 | font-size: 0.8125rem; line-height: 1.5rem; |
| 20 | 20 | } |
| 21 | 21 | .line-row:hover { background: rgba(220, 57, 76, 0.05); } |
| 22 | 22 | .line-row:target { background: rgba(220, 57, 76, 0.12); } |
| 23 | 23 | .line-row:target .line-num { color: #DC394C; font-weight: 600; } |
| 24 | + .line-row { scroll-margin-top: 40vh; } | |
| 24 | 25 | .line-popover { |
| 25 | 26 | position: absolute; left: 100%; top: 50%; transform: translateY(-50%); |
| 26 | 27 | margin-left: 4px; z-index: 20; white-space: nowrap; |
| 27 | 28 | background: #1f2937; border: 1px solid #374151; border-radius: 6px; |
| 28 | 29 | box-shadow: 0 4px 12px rgba(0,0,0,0.4); padding: 2px; |
| @@ -88,15 +89,9 @@ | ||
| 88 | 89 | </div> |
| 89 | 90 | </div> |
| 90 | 91 | |
| 91 | 92 | {% if not is_binary %} |
| 92 | 93 | <script> |
| 93 | - // Highlight each code cell | |
| 94 | 94 | document.querySelectorAll('.line-code code').forEach(el => hljs.highlightElement(el)); |
| 95 | - // Scroll to line if hash present | |
| 96 | - if (window.location.hash) { | |
| 97 | - const el = document.querySelector(window.location.hash); | |
| 98 | - if (el) el.scrollIntoView({ behavior: 'smooth', block: 'center' }); | |
| 99 | - } | |
| 100 | 95 | </script> |
| 101 | 96 | {% endif %} |
| 102 | 97 | {% endblock %} |
| 103 | 98 |
| --- templates/fossil/code_file.html | |
| +++ templates/fossil/code_file.html | |
| @@ -19,10 +19,11 @@ | |
| 19 | font-size: 0.8125rem; line-height: 1.5rem; |
| 20 | } |
| 21 | .line-row:hover { background: rgba(220, 57, 76, 0.05); } |
| 22 | .line-row:target { background: rgba(220, 57, 76, 0.12); } |
| 23 | .line-row:target .line-num { color: #DC394C; font-weight: 600; } |
| 24 | .line-popover { |
| 25 | position: absolute; left: 100%; top: 50%; transform: translateY(-50%); |
| 26 | margin-left: 4px; z-index: 20; white-space: nowrap; |
| 27 | background: #1f2937; border: 1px solid #374151; border-radius: 6px; |
| 28 | box-shadow: 0 4px 12px rgba(0,0,0,0.4); padding: 2px; |
| @@ -88,15 +89,9 @@ | |
| 88 | </div> |
| 89 | </div> |
| 90 | |
| 91 | {% if not is_binary %} |
| 92 | <script> |
| 93 | // Highlight each code cell |
| 94 | document.querySelectorAll('.line-code code').forEach(el => hljs.highlightElement(el)); |
| 95 | // Scroll to line if hash present |
| 96 | if (window.location.hash) { |
| 97 | const el = document.querySelector(window.location.hash); |
| 98 | if (el) el.scrollIntoView({ behavior: 'smooth', block: 'center' }); |
| 99 | } |
| 100 | </script> |
| 101 | {% endif %} |
| 102 | {% endblock %} |
| 103 |
| --- templates/fossil/code_file.html | |
| +++ templates/fossil/code_file.html | |
| @@ -19,10 +19,11 @@ | |
| 19 | font-size: 0.8125rem; line-height: 1.5rem; |
| 20 | } |
| 21 | .line-row:hover { background: rgba(220, 57, 76, 0.05); } |
| 22 | .line-row:target { background: rgba(220, 57, 76, 0.12); } |
| 23 | .line-row:target .line-num { color: #DC394C; font-weight: 600; } |
| 24 | .line-row { scroll-margin-top: 40vh; } |
| 25 | .line-popover { |
| 26 | position: absolute; left: 100%; top: 50%; transform: translateY(-50%); |
| 27 | margin-left: 4px; z-index: 20; white-space: nowrap; |
| 28 | background: #1f2937; border: 1px solid #374151; border-radius: 6px; |
| 29 | box-shadow: 0 4px 12px rgba(0,0,0,0.4); padding: 2px; |
| @@ -88,15 +89,9 @@ | |
| 89 | </div> |
| 90 | </div> |
| 91 | |
| 92 | {% if not is_binary %} |
| 93 | <script> |
| 94 | document.querySelectorAll('.line-code code').forEach(el => hljs.highlightElement(el)); |
| 95 | </script> |
| 96 | {% endif %} |
| 97 | {% endblock %} |
| 98 |