Refactor CSS and JavaScript to implement advanced GSAP animations, resolve image overlay issues, and ensure sponsor visibility. Replit-Commit-Author: Agent Replit-Commit-Session-Id: f13f685e-aa76-4721-bd29-73edf2f9795d Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: c95103aa-b9ba-4a37-8cab-7bb946a4dee9 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/705de26f-a3c1-41e6-845d-88f96627134c/f13f685e-aa76-4721-bd29-73edf2f9795d/2yHlFNO Replit-Helium-Checkpoint-Created: true
82 lines
2.9 KiB
JavaScript
82 lines
2.9 KiB
JavaScript
/* =====================================================
|
|
TSCB — Cross-page Utilities
|
|
===================================================== */
|
|
|
|
(function () {
|
|
'use strict';
|
|
|
|
/* ---- Scroll Progress Bar ---- */
|
|
(function () {
|
|
var bar = document.createElement('div');
|
|
bar.id = 'tscb-progress';
|
|
document.body.appendChild(bar);
|
|
|
|
function onScroll() {
|
|
var scrollTop = window.scrollY || document.documentElement.scrollTop;
|
|
var docHeight = document.documentElement.scrollHeight - document.documentElement.clientHeight;
|
|
var pct = docHeight > 0 ? (scrollTop / docHeight) * 100 : 0;
|
|
bar.style.width = pct + '%';
|
|
}
|
|
|
|
window.addEventListener('scroll', onScroll, { passive: true });
|
|
})();
|
|
|
|
/* ---- Hero Decorative Orbs ---- */
|
|
(function () {
|
|
var hero = document.querySelector('.hero');
|
|
if (!hero) return;
|
|
[1, 2, 3].forEach(function (n) {
|
|
var orb = document.createElement('div');
|
|
orb.className = 'hero-orb-' + n;
|
|
hero.appendChild(orb);
|
|
});
|
|
})();
|
|
|
|
/* ---- Magnetic Buttons ---- */
|
|
(function () {
|
|
var btns = document.querySelectorAll('.btn-default, .readmore-btn, .circular-arrow');
|
|
btns.forEach(function (btn) {
|
|
btn.addEventListener('mousemove', function (e) {
|
|
var rect = btn.getBoundingClientRect();
|
|
var cx = rect.left + rect.width / 2;
|
|
var cy = rect.top + rect.height / 2;
|
|
var dx = (e.clientX - cx) * 0.25;
|
|
var dy = (e.clientY - cy) * 0.25;
|
|
btn.style.transform = 'translate(' + dx + 'px, ' + dy + 'px)';
|
|
});
|
|
btn.addEventListener('mouseleave', function () {
|
|
btn.style.transform = '';
|
|
});
|
|
});
|
|
})();
|
|
|
|
/* ---- Active nav link ---- */
|
|
(function () {
|
|
var currentFile = window.location.pathname.split('/').pop() || 'index.html';
|
|
var links = document.querySelectorAll('.navbar-nav .nav-link');
|
|
links.forEach(function (link) {
|
|
var href = link.getAttribute('href') || '';
|
|
var file = href.split('/').pop();
|
|
if (file === currentFile || (currentFile === '' && file === 'index.html')) {
|
|
var item = link.closest('.nav-item');
|
|
if (item) item.classList.add('active');
|
|
}
|
|
});
|
|
})();
|
|
|
|
/* ---- Ticker pause on hover ---- */
|
|
(function () {
|
|
var ticker = document.querySelector('.ticker-wrap');
|
|
if (!ticker) return;
|
|
var inner = ticker.querySelector('.ticker');
|
|
if (!inner) return;
|
|
ticker.addEventListener('mouseenter', function () {
|
|
inner.style.animationPlayState = 'paused';
|
|
});
|
|
ticker.addEventListener('mouseleave', function () {
|
|
inner.style.animationPlayState = '';
|
|
});
|
|
})();
|
|
|
|
})();
|