Skip to content

Commit cca0539

Browse files
committed
Fastened blobs
1 parent 7c23d6e commit cca0539

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

layouts/index.html

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
position: absolute;
2525
border-radius: 50%;
2626
opacity: 0.4;
27-
animation: float 120s linear infinite;
27+
animation: float var(--particle-duration, 120s) linear infinite;
2828
transform-origin: 50vw 50vh;
2929
}
3030
@keyframes float {
@@ -39,11 +39,28 @@
3939
<script>
4040
(function() {
4141
const container = document.getElementById('particles');
42+
const baseSize = 1920 * 1080;
43+
44+
// 画面サイズに応じてアニメーション速度を計算
45+
function calcDuration() {
46+
const currentSize = window.innerWidth * window.innerHeight;
47+
const ratio = Math.sqrt(currentSize / baseSize);
48+
return Math.max(20, Math.min(80, 80 * ratio));
49+
}
50+
51+
function updateParticleDuration() {
52+
const duration = calcDuration();
53+
document.documentElement.style.setProperty('--particle-duration', duration + 's');
54+
}
55+
updateParticleDuration();
56+
window.addEventListener('resize', updateParticleDuration);
57+
4258
const colors = {
4359
h: ['#7c6cae', '#8b7cb8', '#6a5a9e', '#9b8bc8', '#5d4d8e'],
4460
e: ['#e8a0b0', '#f0b0c0', '#dca0b0', '#f5c0d0', '#d890a0']
4561
};
4662
const count = 20;
63+
const initialDuration = calcDuration();
4764
for (let i = 0; i < count; i++) {
4865
const el = document.createElement('div');
4966
el.className = 'particle';
@@ -56,7 +73,7 @@
5673
el.style.left = Math.random() * 100 + '%';
5774
el.style.top = Math.random() * 100 + '%';
5875
el.style.background = `radial-gradient(circle, ${color} 0%, transparent 70%)`;
59-
el.style.animationDelay = -Math.random() * 120 + 's';
76+
el.style.animationDelay = -Math.random() * initialDuration + 's';
6077
el.style.animationDirection = Math.random() > 0.5 ? 'normal' : 'reverse';
6178
container.appendChild(el);
6279
}

0 commit comments

Comments
 (0)