|
193 | 193 | color: grey;
|
194 | 194 | }
|
195 | 195 |
|
196 |
| - .reference .symbol-name { |
| 196 | + .reference .symbol .symbol-name { |
197 | 197 | text-decoration: none;
|
198 | 198 | color: #0277BD;
|
199 | 199 | margin-right: 0.33em;
|
|
317 | 317 |
|
318 | 318 | <script>
|
319 | 319 | document.addEventListener('DOMContentLoaded', function(e) {
|
| 320 | + var isInViewport = function(elem) { |
| 321 | + var bounding = elem.getBoundingClientRect(); |
| 322 | + return ( |
| 323 | + bounding.top >= 0 && |
| 324 | + bounding.left >= 0 && |
| 325 | + bounding.bottom <= (window.innerHeight || document.documentElement.clientHeight) && |
| 326 | + bounding.right <= (window.innerWidth || document.documentElement.clientWidth) |
| 327 | + ); |
| 328 | + }; |
| 329 | + |
320 | 330 | // Find the symbol closest to the top of the page in the reference
|
321 | 331 | // section and highlight it in the TOC section.
|
322 | 332 |
|
|
342 | 352 | }
|
343 | 353 |
|
344 | 354 | if (found) {
|
345 |
| - tocFound = tocArea.querySelector(`[href="#${found.getAttribute('name')}"]`) |
| 355 | + tocFound = tocArea.querySelectorAll(`[href="#${found.getAttribute('name')}"]`) |
| 356 | + |
| 357 | + // The first subheading in a section shares an href with its parent. |
| 358 | + tocFound = tocFound.length > 1 ? tocFound[1] : tocFound[0]; |
346 | 359 |
|
347 | 360 | if (lastHighlightedTocElement) {
|
348 | 361 | lastHighlightedTocElement.classList.remove('highlighted');
|
349 | 362 | }
|
350 | 363 | tocFound.classList.add('highlighted');
|
351 |
| - // tocFound.scrollIntoView(false); |
| 364 | + if(!isInViewport(tocFound)) { |
| 365 | + tocFound.scrollIntoView(false); |
| 366 | + } |
352 | 367 | lastHighlightedTocElement = tocFound;
|
353 | 368 | }
|
354 | 369 | }
|
|
401 | 416 | </div>
|
402 | 417 | {{#headings}}
|
403 | 418 | <div class="section">
|
404 |
| - <div class="section-title mdl-typography--title">{{name}}</div> |
| 419 | + <div class="section-title mdl-typography--title"> |
| 420 | + <a href="#{{name}}-{{subheadings.0.name}}">{{name}}</a> |
| 421 | + </div> |
405 | 422 | {{#subheadings}}
|
406 | 423 | <div class="subsection">
|
407 |
| - <div class="sub-section-title mdl-typography--subhead">{{name}}</div> |
| 424 | + <div class="sub-section-title mdl-typography--subhead"> |
| 425 | + <a href="#{{../name}}-{{name}}">{{name}}</a> |
| 426 | + </div> |
408 | 427 | {{#symbols}}
|
409 | 428 | <div class="symbol">
|
410 | 429 | <a href="#{{urlHash}}">{{displayName}}</a>
|
|
421 | 440 | <div class="section">
|
422 | 441 | {{#subheadings}}
|
423 | 442 | <div class="subsection">
|
424 |
| - <div class="subsection-title mdl-typography--display-3">{{../name}} / {{name}}</div> |
| 443 | + <div id="{{../name}}-{{name}}" name="{{../name}}-{{name}}" class="symbol-name subsection-title mdl-typography--display-3">{{../name}} / {{name}}</div> |
425 | 444 | <div class="subsection-description mdl-typography--headline">{{{description}}}</div>
|
426 | 445 | {{#symbols}}
|
427 | 446 | <div class="symbol">
|
|
0 commit comments