Skip to content

Commit b9e506a

Browse files
committed
Mark loneliness
1 parent 596de34 commit b9e506a

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

pages/drumheller-marathon-24.html

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,11 @@
234234
width: var(--size);
235235
}
236236

237+
.diagram #orbit-offset-calc {
238+
width: var(--orbit-offset);
239+
height: 0;
240+
}
241+
237242
.diagram .toy-overlay {
238243
width: 100%;
239244
height: 100%;
@@ -281,6 +286,11 @@
281286
width: var(--dot-width);
282287
border-radius: 50%;
283288
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);
284294
}
285295

286296
.wavy-button {
@@ -531,6 +541,8 @@
531541
<div class="display-text">The <a href="{{ site.baseurl }}/" class="text-decoration-none">Race Condition Running</a> <h1>Drumheller&nbsp;Marathon</h1> will run June&nbsp;1st,&nbsp;2024.</div>
532542

533543
<div class="diagram" id="hero-toy">
544+
<!-- Disgusting hack to get value of calc variable in js -->
545+
<div id="orbit-offset-calc"></div>
534546
<img src="{{ site.baseurl }}/img/dm24/jets-grad.svg" alt="" class="jets"/>
535547
<img src="{{ site.baseurl }}/img/dm24/basin.svg" alt="" class="toy-overlay">
536548
<div class="interactive toy-overlay clickable-circle"></div>
@@ -873,5 +885,47 @@ <h3 class="accordion-header" id="faq-headingTwelve">
873885
}
874886
</script>
875887

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+
876930
</body>
877931
</html>

0 commit comments

Comments
 (0)