Skip to content

Commit 45daf9f

Browse files
committed
Some fixes for scroll
1 parent bc7cf3c commit 45daf9f

File tree

2 files changed

+68
-24
lines changed

2 files changed

+68
-24
lines changed

index.html

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -529,39 +529,48 @@ <h2 class="sponsors-subtitle text-title">
529529
What are you doing here? You should go register for BSDC instead: https://bsdc25.eventbrite.com
530530
`);
531531

532-
// Improved navbar scroll handling for smoother experience, especially on mobile
533-
(function () {
532+
// Improved scroll performance with requestAnimationFrame
533+
(function() {
534534
const nav = document.querySelector('#navbar');
535-
let lastScrollY = window.scrollY;
535+
let lastKnownScrollPosition = 0;
536536
let ticking = false;
537-
538-
function checkNav () {
539-
// Use getBoundingClientRect for more accurate position on mobile
540-
const top = window.innerHeight / 3;
541-
if (window.scrollY >= top) {
537+
538+
function updateNavbar(scrollPos) {
539+
const threshold = window.innerHeight / 3;
540+
if (scrollPos >= threshold) {
542541
nav.classList.add('fixed');
543542
} else {
544543
nav.classList.remove('fixed');
545544
}
546-
ticking = false;
547545
}
548546

549-
function onScroll () {
547+
// Throttled scroll handler
548+
document.addEventListener('scroll', function(e) {
549+
lastKnownScrollPosition = window.scrollY;
550+
550551
if (!ticking) {
551-
window.requestAnimationFrame(checkNav);
552+
window.requestAnimationFrame(function() {
553+
updateNavbar(lastKnownScrollPosition);
554+
ticking = false;
555+
});
556+
552557
ticking = true;
553558
}
554-
}
555-
556-
window.addEventListener('scroll', onScroll, { passive: true });
559+
}, {passive: true}); // Passive listener for better performance
557560

558-
// Also check on resize, as viewport height may change on mobile
559-
window.addEventListener('resize', function () {
560-
checkNav();
561-
}, { passive: true });
561+
// Handle resize events
562+
let resizeTimeout;
563+
window.addEventListener('resize', function() {
564+
if (resizeTimeout) {
565+
clearTimeout(resizeTimeout);
566+
}
567+
resizeTimeout = setTimeout(function() {
568+
updateNavbar(lastKnownScrollPosition);
569+
}, 66); // Debounced to run max every 66ms
570+
}, {passive: true});
562571

563572
// Initial check
564-
checkNav();
573+
updateNavbar(window.scrollY);
565574
})();
566575

567576
document.querySelectorAll('.speakers > #speakers-images > .speaker-info').forEach(function ($speaker) {

style.css

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ body {
88
position: relative;
99
margin: 0;
1010
overflow-x: hidden;
11+
-webkit-font-smoothing: antialiased;
12+
-moz-osx-font-smoothing: grayscale;
1113
}
1214

1315
html {
@@ -24,7 +26,7 @@ html {
2426
overflow: hidden;
2527
/* background: white; */
2628
position: fixed;
27-
z-index: 1;
29+
z-index: 100;
2830
left: 0;
2931
right: 0;
3032
top: 0;
@@ -35,12 +37,17 @@ html {
3537
align-self: stretch;
3638
height: 180px;
3739
transition: all ease-in-out 0.4s;
40+
will-change: transform, height;
41+
transform: translateZ(0);
42+
backface-visibility: hidden;
43+
background: transparent;
3844
}
3945

4046
#navbar.fixed {
4147
background: rgba(255, 255, 255, 0.8);
4248
height: 60px;
43-
z-index: 100;
49+
backdrop-filter: blur(8px);
50+
-webkit-backdrop-filter: blur(8px);
4451
}
4552

4653
.text-background {
@@ -425,6 +432,9 @@ x p {
425432
display: flex;
426433
align-items: center;
427434
justify-content: center;
435+
will-change: transform;
436+
transform: translateZ(0);
437+
backface-visibility: hidden;
428438
}
429439

430440
.bison-herd {
@@ -1337,13 +1347,15 @@ a {
13371347
flex-direction: column;
13381348
align-items: center;
13391349
gap: 1rem;
1340-
transition: all 0.2s ease-in-out;
1350+
transition: transform 0.2s ease-in-out;
13411351
position: relative;
13421352
cursor: pointer;
1353+
will-change: transform;
1354+
transform: translateZ(0);
13431355
}
13441356

13451357
.speaker:hover {
1346-
transform: scale(1.02);
1358+
transform: scale(1.02) translateZ(0);
13471359
z-index: 5;
13481360
}
13491361

@@ -1407,7 +1419,9 @@ a {
14071419
gap: 0.5rem;
14081420
border-left: 6px solid #D6FF62;
14091421
position: relative;
1410-
transition: box-shadow 0.2s;
1422+
transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
1423+
will-change: transform, box-shadow;
1424+
transform: translateZ(0);
14111425
}
14121426

14131427
.schedule-block > .block-extra {
@@ -1427,6 +1441,7 @@ a {
14271441

14281442
.schedule-block:hover {
14291443
box-shadow: 0 0 0 2px #D6FF62, 0 10px 24px -8px rgba(0,0,0,0.7);
1444+
transform: translateY(-2px) translateZ(0);
14301445
z-index: 2;
14311446
}
14321447

@@ -1515,3 +1530,23 @@ a {
15151530
pointer-events: none;
15161531
}
15171532

1533+
/* Optimize animations */
1534+
@media (prefers-reduced-motion: reduce) {
1535+
* {
1536+
animation-duration: 0.01ms !important;
1537+
animation-iteration-count: 1 !important;
1538+
transition-duration: 0.01ms !important;
1539+
scroll-behavior: auto !important;
1540+
}
1541+
}
1542+
1543+
/* Force hardware acceleration for fixed elements */
1544+
.fixed {
1545+
transform: translateZ(0);
1546+
backface-visibility: hidden;
1547+
perspective: 1000;
1548+
-webkit-transform: translateZ(0);
1549+
-webkit-backface-visibility: hidden;
1550+
-webkit-perspective: 1000;
1551+
}
1552+

0 commit comments

Comments
 (0)