| |
| |
|
|
| class VorkflowApp { |
| constructor() { |
| this.init(); |
| } |
|
|
| init() { |
| |
| this.initCursorFollower(); |
| |
| |
| this.initScrollAnimations(); |
| |
| |
| this.initPageTransitions(); |
| |
| |
| this.initSectionObserver(); |
| } |
|
|
| initCursorFollower() { |
| const cursor = document.querySelector('.cursor-follower'); |
| if (!cursor) return; |
|
|
| let mouseX = 0; |
| let mouseY = 0; |
| let cursorX = 0; |
| let cursorY = 0; |
|
|
| document.addEventListener('mousemove', (e) => { |
| mouseX = e.clientX; |
| mouseY = e.clientY; |
| }); |
|
|
| function animateCursor() { |
| |
| const dx = mouseX - cursorX; |
| const dy = mouseY - cursorY; |
| |
| cursorX += dx * 0.1; |
| cursorY += dy * 0.1; |
| |
| cursor.style.left = cursorX + 'px'; |
| cursor.style.top = cursorY + 'px'; |
| |
| requestAnimationFrame(animateCursor); |
| } |
|
|
| animateCursor(); |
|
|
| |
| const interactiveElements = document.querySelectorAll('a, button, .hover-card, .cursor-parallax'); |
| interactiveElements.forEach(el => { |
| el.addEventListener('mouseenter', () => { |
| cursor.style.width = '60px'; |
| cursor.style.height = '60px'; |
| cursor.style.borderColor = 'rgba(56, 189, 248, 0.5)'; |
| }); |
|
|
| el.addEventListener('mouseleave', () => { |
| cursor.style.width = '40px'; |
| cursor.style.height = '40px'; |
| cursor.style.borderColor = 'rgba(56, 189, 248, 0.3)'; |
| }); |
| }); |
| } |
|
|
| initScrollAnimations() { |
| |
| if (typeof gsap !== 'undefined' && typeof ScrollTrigger !== 'undefined') { |
| gsap.registerPlugin(ScrollTrigger); |
|
|
| |
| gsap.utils.toArray('section').forEach(section => { |
| gsap.from(section, { |
| opacity: 0, |
| y: 50, |
| duration: 1, |
| ease: "power3.out", |
| scrollTrigger: { |
| trigger: section, |
| start: "top 80%", |
| end: "bottom 20%", |
| toggleActions: "play none none reverse", |
| } |
| }); |
| }); |
|
|
| |
| gsap.to('.parallax-bg', { |
| yPercent: 20, |
| ease: "none", |
| scrollTrigger: { |
| trigger: 'main', |
| start: "top top", |
| end: "bottom top", |
| scrub: true, |
| } |
| }); |
| } |
| } |
| } |
|
|
| initPageTransitions() { |
| |
| document.addEventListener('click', (e) => { |
| const link = e.target.closest('a'); |
| if (!link) return; |
|
|
| const href = link.getAttribute('href'); |
| |
| |
| if (href && href.startsWith('/') || href.endsWith('.html')) { |
| e.preventDefault(); |
| |
| |
| const overlay = document.createElement('div'); |
| overlay.className = 'page-transition active'; |
| document.body.appendChild(overlay); |
| |
| |
| setTimeout(() => { |
| window.location.href = href; |
| }, 600); |
| } |
| }); |
| } |
|
|
| initSectionObserver() { |
| const sections = document.querySelectorAll('section'); |
| const observer = new IntersectionObserver((entries) => { |
| entries.forEach(entry => { |
| if (entry.isIntersecting) { |
| entry.target.classList.add('visible'); |
| } |
| }); |
| }, { |
| threshold: 0.1, |
| rootMargin: '0px 0px -100px 0px' |
| }); |
|
|
| sections.forEach(section => { |
| observer.observe(section); |
| }); |
| } |
|
|
| |
| handleFormSubmit(formId) { |
| const form = document.getElementById(formId); |
| if (!form) return; |
|
|
| form.addEventListener('submit', async (e) => { |
| e.preventDefault(); |
| |
| const submitBtn = form.querySelector('button[type="submit"]'); |
| const originalText = submitBtn.textContent; |
| |
| |
| submitBtn.innerHTML = '<span class="loading-dots"><span></span><span></span><span></span></span>'; |
| submitBtn.disabled = true; |
| |
| |
| setTimeout(() => { |
| |
| const successMessage = document.createElement('div'); |
| successMessage.className = 'fixed top-4 right-4 bg-gradient-to-r from-green-500 to-emerald-600 text-white px-6 py-4 rounded-xl shadow-2xl z-50 animate-slide-up'; |
| successMessage.innerHTML = ` |
| <div class="flex items-center gap-3"> |
| <i data-feather="check-circle" class="w-6 h-6"></i> |
| <div> |
| <p class="font-semibold">Strategic Session Requested</p> |
| <p class="text-sm opacity-90">Our AI team will contact you within 24 hours.</p> |
| </div> |
| `; |
| document.body.appendChild(successMessage); |
| |
| |
| form.reset(); |
| submitBtn.textContent = originalText; |
| submitBtn.disabled = false; |
| |
| |
| setTimeout(() => { |
| successMessage.remove(); |
| }, 5000); |
| |
| |
| if (window.feather) { |
| feather.replace(); |
| } |
| }, 1500); |
| }); |
| } |
|
|
| |
| animateCounter(elementId, targetValue, duration = 2000) { |
| const element = document.getElementById(elementId); |
| if (!element) return; |
|
|
| let startValue = 0; |
| const increment = targetValue / (duration / 16.67); |
| const timer = setInterval(() => { |
| startValue += increment; |
| if (startValue >= targetValue) { |
| element.textContent = targetValue + '+'; |
| clearInterval(timer); |
| } else { |
| element.textContent = Math.floor(startValue) + '+'; |
| } |
| }, 16.67); |
| } |
| } |
|
|
| |
| document.addEventListener('DOMContentLoaded', () => { |
| window.vorkflowApp = new VorkflowApp(); |
| |
| |
| vorkflowApp.handleFormSubmit('contact-form'); |
| vorkflowApp.handleFormSubmit('strategy-form'); |
| |
| |
| vorkflowApp.animateCounter('counter-1', 42); |
| vorkflowApp.animateCounter('counter-2', 65); |
| vorkflowApp.animateCounter('counter-3', 87); |
| vorkflowApp.animateCounter('counter-4', 98); |
| }); |
|
|
| |
| function setActiveNavLink() { |
| const currentPath = window.location.pathname; |
| const navLinks = document.querySelectorAll('custom-navbar a'); |
| |
| navLinks.forEach(link => { |
| const href = link.getAttribute('href'); |
| if (currentPath.includes(href) || (currentPath === '/' && href === 'index.html')) { |
| link.classList.add('active'); |
| } else { |
| link.classList.remove('active'); |
| } |
| }); |
| } |
|
|
| |
| setActiveNavLink(); |
| window.addEventListener('popstate', setActiveNavLink); |