feat(interaction): implement sophisticated hover effects and parallax
- Add moving shine effect and glow on card hover - Implement coffee drip animation for link underlines - Add JS-driven parallax scroll effect for floating elements - Enhance button micro-interactions - Refine animations for smoothness
This commit is contained in:
27
main.js
27
main.js
@@ -154,6 +154,32 @@ function initTestimonials() {
|
||||
});
|
||||
}
|
||||
|
||||
// ===== PARALLAX EFFECT FOR DECORATIVE ELEMENTS =====
|
||||
function initParallax() {
|
||||
const floatingElements = document.querySelectorAll('.floating-bean, .floating-cup');
|
||||
if (!floatingElements.length) return;
|
||||
|
||||
let ticking = false;
|
||||
|
||||
window.addEventListener('scroll', () => {
|
||||
if (!ticking) {
|
||||
window.requestAnimationFrame(() => {
|
||||
const scrolled = window.scrollY;
|
||||
|
||||
floatingElements.forEach((el, index) => {
|
||||
const speed = 0.05 + (index * 0.02); // Vary speed per element
|
||||
const yPos = -(scrolled * speed);
|
||||
// Use CSS variable to avoid overwriting the float animation transform
|
||||
el.style.transform = `translateY(${yPos}px)`;
|
||||
});
|
||||
|
||||
ticking = false;
|
||||
});
|
||||
ticking = true;
|
||||
}
|
||||
}, { passive: true });
|
||||
}
|
||||
|
||||
// ===== INITIALIZE ALL =====
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
initTypewriter();
|
||||
@@ -161,4 +187,5 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
initSkillBars();
|
||||
initParticles();
|
||||
initTestimonials();
|
||||
initParallax();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user