|
234 | 234 | width: var(--size); |
235 | 235 | } |
236 | 236 |
|
| 237 | + .diagram #orbit-offset-calc { |
| 238 | + width: var(--orbit-offset); |
| 239 | + height: 0; |
| 240 | + } |
| 241 | + |
237 | 242 | .diagram .toy-overlay { |
238 | 243 | width: 100%; |
239 | 244 | height: 100%; |
|
281 | 286 | width: var(--dot-width); |
282 | 287 | border-radius: 50%; |
283 | 288 | background-color: black; |
| 289 | + transition: background-color 0.5s cubic-bezier(1,1,1,1); |
| 290 | + } |
| 291 | + .dot.lonely span { |
| 292 | + background-color: var(--branding-color); |
| 293 | + transition: background-color 0.5s cubic-bezier(1,1,1,1); |
284 | 294 | } |
285 | 295 |
|
286 | 296 | .wavy-button { |
|
531 | 541 | <div class="display-text">The <a href="{{ site.baseurl }}/" class="text-decoration-none">Race Condition Running</a> <h1>Drumheller Marathon</h1> will run June 1st, 2024.</div> |
532 | 542 |
|
533 | 543 | <div class="diagram" id="hero-toy"> |
| 544 | + <!-- Disgusting hack to get value of calc variable in js --> |
| 545 | + <div id="orbit-offset-calc"></div> |
534 | 546 | <img src="{{ site.baseurl }}/img/dm24/jets-grad.svg" alt="" class="jets"/> |
535 | 547 | <img src="{{ site.baseurl }}/img/dm24/basin.svg" alt="" class="toy-overlay"> |
536 | 548 | <div class="interactive toy-overlay clickable-circle"></div> |
@@ -873,5 +885,47 @@ <h3 class="accordion-header" id="faq-headingTwelve"> |
873 | 885 | } |
874 | 886 | </script> |
875 | 887 |
|
| 888 | +<script type="text/javascript"> |
| 889 | + setInterval(function() { |
| 890 | + var ring = document.getElementsByClassName("ring")[0]; |
| 891 | + var dots = ring.querySelectorAll(".dot"); |
| 892 | + |
| 893 | + var offset = parseFloat(getComputedStyle( |
| 894 | + document.getElementById("orbit-offset-calc")) |
| 895 | + .getPropertyValue("width")); |
| 896 | + |
| 897 | + // XXX: this might not be exactly right, this should be the radius to the center of the dots |
| 898 | + var radius = parseFloat(ring.getBoundingClientRect().width) / 2.0 + offset; |
| 899 | + |
| 900 | + let limit = 2 * radius * Math.sin(Math.PI / dots.length); |
| 901 | + |
| 902 | + function dotIsLonely(dot) { |
| 903 | + let rect = dot.getElementsByClassName("pulse")[0].getBoundingClientRect(); |
| 904 | + |
| 905 | + for (let other of dots) { |
| 906 | + if (other === dot) { |
| 907 | + continue; |
| 908 | + } |
| 909 | + let otherRect = other.getElementsByClassName("pulse")[0].getBoundingClientRect(); |
| 910 | + let distance = Math.sqrt( |
| 911 | + (rect.left - otherRect.left)**2 + |
| 912 | + (rect.top - otherRect.top)**2); |
| 913 | + if (distance <= limit) { |
| 914 | + return false; |
| 915 | + } |
| 916 | + } |
| 917 | + return true; |
| 918 | + } |
| 919 | + |
| 920 | + for (let dot of dots) { |
| 921 | + if (dotIsLonely(dot)) { |
| 922 | + dot.classList.add("lonely"); |
| 923 | + } else { |
| 924 | + dot.classList.remove("lonely"); |
| 925 | + } |
| 926 | + } |
| 927 | + }, 200); |
| 928 | +</script> |
| 929 | + |
876 | 930 | </body> |
877 | 931 | </html> |
0 commit comments