Skip to content

Commit 3c0fccb

Browse files
committed
fix: fade-in viewport detection, gauge CSS transition timing, framework bar observer
1 parent fca16e8 commit 3c0fccb

3 files changed

Lines changed: 37 additions & 11 deletions

File tree

assets/js/site.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,15 @@
225225
io.unobserve(e.target);
226226
}
227227
});
228-
}, { threshold: 0.08 });
229-
document.querySelectorAll('.fade-in').forEach(el => io.observe(el));
228+
}, { threshold: 0.01, rootMargin: '0px 0px -20px 0px' });
229+
document.querySelectorAll('.fade-in').forEach(el => {
230+
const r = el.getBoundingClientRect();
231+
if (r.top < window.innerHeight && r.bottom > 0) {
232+
el.classList.add('visible');
233+
} else {
234+
io.observe(el);
235+
}
236+
});
230237

231238
/* ── HERO TITLE CHARACTER REVEAL ────────────────────────────── */
232239
function wrapChars(el, delayStart) {

pages/framework.html

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -406,15 +406,22 @@ <h3 class="section-heading-compact">The knowledge lifecycle</h3>
406406
<script>
407407
(function(){
408408
var targets = [
409-
{ el: document.querySelector('.standard-box'), cls: 'visible' },
410-
{ el: document.querySelector('.lifecycle'), cls: 'visible' }
411-
];
409+
document.querySelector('.standard-box'),
410+
document.querySelector('.lifecycle')
411+
].filter(Boolean);
412412
var io = new IntersectionObserver(function(entries){
413413
entries.forEach(function(e){
414414
if (e.isIntersecting) { e.target.classList.add('visible'); io.unobserve(e.target); }
415415
});
416-
}, { threshold: 0 });
417-
targets.forEach(function(t){ if (t.el) io.observe(t.el); });
416+
}, { threshold: 0.01, rootMargin: '0px 0px -20px 0px' });
417+
targets.forEach(function(el){
418+
var r = el.getBoundingClientRect();
419+
if (r.top < window.innerHeight && r.bottom > 0) {
420+
el.classList.add('visible');
421+
} else {
422+
io.observe(el);
423+
}
424+
});
418425
}());
419426
</script>
420427
</body>

pages/whynow.html

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -470,10 +470,22 @@ <h3>AI performance is downstream of knowledge quality.</h3>
470470
}
471471
var gauges = document.getElementById('ki-gauges');
472472
if (!gauges) return;
473-
var io = new IntersectionObserver(function(entries){
474-
if (entries[0].isIntersecting) { runGauges(); io.unobserve(gauges); }
475-
}, { threshold: 0.3 });
476-
io.observe(gauges);
473+
function triggerGauges() {
474+
// rAF ensures CSS transitions are active before strokeDashoffset changes
475+
requestAnimationFrame(function() {
476+
requestAnimationFrame(function() { runGauges(); });
477+
});
478+
}
479+
// Check if already in viewport on load (threshold 0.3 would miss this)
480+
var gr = gauges.getBoundingClientRect();
481+
if (gr.top < window.innerHeight && gr.bottom > 0) {
482+
triggerGauges();
483+
} else {
484+
var io = new IntersectionObserver(function(entries){
485+
if (entries[0].isIntersecting) { triggerGauges(); io.unobserve(gauges); }
486+
}, { threshold: 0.1 });
487+
io.observe(gauges);
488+
}
477489
}());
478490
</script>
479491
</body>

0 commit comments

Comments
 (0)