Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark loneliness #17

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions pages/drumheller-marathon-24.html
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,11 @@
width: var(--size);
}

.diagram #orbit-offset-calc {
width: var(--orbit-offset);
height: 0;
}

.diagram .toy-overlay {
width: 100%;
height: 100%;
Expand Down Expand Up @@ -281,6 +286,11 @@
width: var(--dot-width);
border-radius: 50%;
background-color: black;
transition: background-color 0.5s cubic-bezier(1,1,1,1);
}
.dot.lonely span {
background-color: var(--branding-color);
transition: background-color 0.5s cubic-bezier(1,1,1,1);
}

.wavy-button {
Expand Down Expand Up @@ -531,6 +541,8 @@
<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>

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

<script type="text/javascript">
setInterval(function() {
var ring = document.getElementsByClassName("ring")[0];
var dots = ring.querySelectorAll(".dot");

var offset = parseFloat(getComputedStyle(
document.getElementById("orbit-offset-calc"))
.getPropertyValue("width"));

// XXX: this might not be exactly right, this should be the radius to the center of the dots
var radius = parseFloat(ring.getBoundingClientRect().width) / 2.0 + offset;

var limit = 2 * radius * Math.sin(Math.PI / dots.length);

function dotIsLonely(dot) {
let rect = dot.getElementsByClassName("pulse")[0].getBoundingClientRect();

for (let other of dots) {
if (other === dot) {
continue;
}
let otherRect = other.getElementsByClassName("pulse")[0].getBoundingClientRect();
let distance = Math.sqrt(
(rect.left - otherRect.left)**2 +
(rect.top - otherRect.top)**2);
if (distance <= limit) {
return false;
}
}
return true;
}

for (let dot of dots) {
if (dotIsLonely(dot)) {
dot.classList.add("lonely");
} else {
dot.classList.remove("lonely");
}
}
}, 200);
</script>

</body>
</html>