|
4 | 4 | mission: "nav-link-mission",
|
5 | 5 | news: "nav-link-news",
|
6 | 6 | facilities: "nav-link-facilities",
|
| 7 | + partners: "nav-link-partners", |
7 | 8 | team: "nav-link-team",
|
8 | 9 | repositories: "nav-link-repositories",
|
9 | 10 | documentation: "nav-link-documentation",
|
|
18 | 19 | }
|
19 | 20 | }
|
20 | 21 |
|
21 |
| - // Given a specific element Id, check if the element is currenty visible on the screen |
| 22 | + // Given a specific element Id, check if more than 50% of the element is currently visible on the screen |
22 | 23 | function isElementVisible(elemId) {
|
23 | 24 | let elm = document.getElementById(elemId).getBoundingClientRect();
|
24 | 25 | let viewHeight = Math.max(document.documentElement.clientHeight, window.innerHeight);
|
25 |
| - return !(elm.bottom < 0 || elm.top - viewHeight >= 0); |
| 26 | + let elementHeight = elm.height || (elm.bottom - elm.top); |
| 27 | + let visibleHeight = Math.min(elm.bottom, viewHeight) - Math.max(elm.top, 0); |
| 28 | + return visibleHeight > elementHeight / 2; |
26 | 29 | }
|
27 | 30 |
|
28 | 31 | /*
|
|
85 | 88 | </li>
|
86 | 89 | <li class="nav-item mx-lg-3">
|
87 | 90 | <a class="page-scroll nav-link" id="nav-link-facilities" href="{{'#facilities' | relative_url }}" onclick="onClick(event);">Facilities</a>
|
| 91 | + </li> |
| 92 | + <li class="nav-item mx-lg-3"> |
| 93 | + <a class="page-scroll nav-link" id="nav-link-partners" href="{{'#partners' | relative_url }}" onclick="onClick(event);">Industry Partners</a> |
88 | 94 | </li>
|
89 | 95 | <li class="nav-item mx-lg-3">
|
90 | 96 | <a class="page-scroll nav-link" id="nav-link-team" href="{{'#team' | relative_url }}" onclick="onClick(event);">Team</a>
|
|
0 commit comments