Skip to content

Commit c9e1b37

Browse files
author
cakePhone
committed
reduced motion shenanigans
1 parent 0ef9417 commit c9e1b37

5 files changed

Lines changed: 39 additions & 2 deletions

File tree

‎_includes/footer.liquid‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
function animateCookie(timestamp, cookie, data) {
4141
// make a physics based animation
4242
const deltaTime = timestamp - data.startTime;
43-
const gravity = 1; // Gravity effect
43+
const gravity = 0.7; // Gravity effect
4444
4545
data.velocity = {
4646
x: data.velocity.x * 0.99, // Simulate air resistance

‎_includes/post_layout.liquid‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
</div>
1818
</body>
1919
<script>
20-
document.getElementsByClassName('title-fade-out')[0].classList.add('gone');
20+
setTimeout(() => {
21+
document.getElementsByClassName('title-fade-out')[0].classList.add('gone');
22+
}, 2000);
2123
</script>
2224
</html>

‎assets/css/global.css‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,14 @@ a {
154154
font-size: 14pt;
155155
}
156156
}
157+
158+
@media (prefers-reduced-motion: reduce) {
159+
* {
160+
animation: none !important;
161+
transition: none !important;
162+
}
163+
164+
body {
165+
scroll-behavior: auto;
166+
}
167+
}

‎assets/css/post.css‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@
6262
}
6363
}
6464

65+
@media (prefers-reduced-motion: reduce) {
66+
.title-fade-out {
67+
animation: none !important;
68+
display: none !important;
69+
visibility: hidden !important;
70+
opacity: 0 !important;
71+
pointer-events: none !important;
72+
backdrop-filter: none !important;
73+
}
74+
}
75+
6576
.post-content {
6677
font-family: var(--ff-content);
6778
text-align: justify;

‎assets/js/bubble.js‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,18 @@ function bubbleLifeLoop(currentTimestamp, bubbles) {
143143

144144
document.addEventListener('DOMContentLoaded', () => {
145145
const bubblesElements = document.getElementsByClassName('bubble');
146+
147+
if (window.matchMedia(`(prefers-reduced-motion: reduce)`)) {
148+
const angle_offset = Math.random() * TWO_PI;
149+
// assign triangle position and return
150+
for (let i = 0; i < bubblesElements.length; i++) {
151+
const bubble = bubblesElements[i];
152+
position = polarToCartesian({ magnitude: 50, angle: TWO_PI * i / 3 + angle_offset });
153+
bubble.style.transform = `translate(${position.x}%, ${position.y}%)`;
154+
}
155+
return;
156+
}
157+
146158
const bubbleCount = bubblesElements.length;
147159

148160
const data = new Array(bubbleCount).fill(null).map(() => ({
@@ -163,6 +175,7 @@ document.addEventListener('DOMContentLoaded', () => {
163175
};
164176
};
165177

178+
166179
// Start the animation loop
167180
requestAnimationFrame((timestamp) => {
168181
bubbleLifeLoop(timestamp, data);

0 commit comments

Comments
 (0)