Skip to content

Commit 376eba6

Browse files
committed
docs: Speed up animation when moving internally
1 parent 19adb1a commit 376eba6

File tree

3 files changed

+37
-24
lines changed

3 files changed

+37
-24
lines changed

docs/404.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@
3030
</head>
3131

3232
<body>
33+
<script>
34+
// Check if user is coming from within the same domain
35+
document.addEventListener('DOMContentLoaded', function() {
36+
const referrer = document.referrer;
37+
debugger;
38+
39+
// Check if the referrer is from posit-dev.github.io/shinychat
40+
if (referrer && referrer.includes('posit-dev.github.io/shinychat')) {
41+
// Set a faster animation speed
42+
document.documentElement.style.setProperty('--animation-speed', '0.2'); // 5x faster
43+
}
44+
});
45+
</script>
3346
<header class="header">
3447
<div class="logo">
3548
<div>

docs/chat-styles.css

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
box-sizing: border-box;
55
}
66

7+
:root {
8+
--animation-speed: 1;
9+
}
10+
711
body {
812
font-family: -apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui,
913
helvetica neue, Adwaita Sans, Cantarell, Ubuntu, roboto, noto, helvetica,
@@ -67,30 +71,30 @@ body {
6771
display: flex;
6872
opacity: 0;
6973
transform: translateY(20px);
70-
animation: slideIn 0.6s ease-out forwards;
74+
animation: slideIn calc(0.6s * var(--animation-speed)) ease-out forwards;
7175
align-items: flex-start;
7276
gap: 0.75rem;
7377
}
7478

7579
.chat-message.user {
7680
flex-direction: row-reverse;
77-
animation-delay: 0.5s;
81+
animation-delay: calc(0.5s * var(--animation-speed));
7882
}
7983

8084
.chat-message.ai {
8185
flex-direction: row;
8286
}
8387

8488
.chat-message:nth-child(2) {
85-
animation-delay: 1.5s;
89+
animation-delay: calc(1.5s * var(--animation-speed));
8690
}
8791

8892
.chat-message:nth-child(3) {
89-
animation-delay: 3s;
93+
animation-delay: calc(3s * var(--animation-speed));
9094
}
9195

9296
.chat-message:nth-child(4) {
93-
animation-delay: 4s;
97+
animation-delay: calc(4s * var(--animation-speed));
9498
}
9599

96100
.message-bubble {
@@ -190,7 +194,8 @@ body {
190194
padding: 2rem;
191195
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
192196
opacity: 0;
193-
animation: slideIn 0.6s ease-out forwards;
197+
animation: slideIn calc(0.6s * var(--animation-speed)) ease-out forwards;
198+
animation-delay: calc(1s * var(--animation-speed));;
194199
}
195200

196201
.features h3 {
@@ -245,17 +250,6 @@ body {
245250
font-size: 0.9rem;
246251
}
247252

248-
.chat-input-area {
249-
border-top: 1px solid #e5e7eb;
250-
padding: 1.5rem 2rem;
251-
background: #f9fafb;
252-
display: flex;
253-
align-items: center;
254-
gap: 1rem;
255-
opacity: 0;
256-
animation: slideIn 0.6s ease-out 8s forwards;
257-
}
258-
259253
@keyframes slideIn {
260254
to {
261255
opacity: 1;

docs/index.html

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@
3030
</head>
3131

3232
<body>
33+
<script>
34+
// Check if user is coming from within the same domain
35+
document.addEventListener('DOMContentLoaded', function() {
36+
const referrer = document.referrer;
37+
debugger;
38+
39+
// Check if the referrer is from posit-dev.github.io/shinychat
40+
if (referrer && referrer.includes('posit-dev.github.io/shinychat')) {
41+
// Set a faster animation speed
42+
document.documentElement.style.setProperty('--animation-speed', '0.2'); // 5x faster
43+
}
44+
});
45+
</script>
3346
<header class="header">
3447
<div class="logo">
3548
<div>
@@ -167,13 +180,6 @@ <h4>In Your Favorite Language</h4>
167180
<script>
168181
// Update footer year dynamically
169182
document.querySelector('.footer-year').textContent = new Date().getFullYear();
170-
171-
// // Animate chat messages on load
172-
// document.querySelectorAll('.chat-message').forEach((message, index) => {
173-
// message.style.animationDelay = `${index * 0.5}s`;
174-
// message.style.opacity = '1';
175-
// message.style.transform = 'translateY(0)';
176-
// });
177183
</script>
178184
</body>
179185

0 commit comments

Comments
 (0)