ok
This commit is contained in:
		@@ -144,6 +144,8 @@ window.onload = function () {
 | 
			
		||||
        'www.ourworld.tf',
 | 
			
		||||
        'ourworld.tf',
 | 
			
		||||
        'www2.ourworld.tf',
 | 
			
		||||
        'www2.freezone.ourworld.tf',
 | 
			
		||||
        'freezone.ourworld.tf',
 | 
			
		||||
        'localhost',
 | 
			
		||||
        '127.0.0.1'
 | 
			
		||||
    ]
 | 
			
		||||
@@ -169,3 +171,160 @@ window.onload = function () {
 | 
			
		||||
function openInNewTab(url) {
 | 
			
		||||
    window.open(url, '_blank').focus()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Animation System for Homepage Components
 | 
			
		||||
class AnimationController {
 | 
			
		||||
    constructor() {
 | 
			
		||||
        this.observer = null;
 | 
			
		||||
        this.isPageLoaded = false;
 | 
			
		||||
        this.init();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    init() {
 | 
			
		||||
        // Set up intersection observer for scroll animations
 | 
			
		||||
        this.setupIntersectionObserver();
 | 
			
		||||
        
 | 
			
		||||
        // Handle initial page load animations
 | 
			
		||||
        this.handlePageLoad();
 | 
			
		||||
        
 | 
			
		||||
        // Initialize animations when DOM is ready
 | 
			
		||||
        if (document.readyState === 'loading') {
 | 
			
		||||
            document.addEventListener('DOMContentLoaded', () => this.initializeAnimations());
 | 
			
		||||
        } else {
 | 
			
		||||
            this.initializeAnimations();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    setupIntersectionObserver() {
 | 
			
		||||
        const options = {
 | 
			
		||||
            root: null,
 | 
			
		||||
            rootMargin: '0px 0px -10% 0px', // Trigger when element is 10% visible
 | 
			
		||||
            threshold: 0.1
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        this.observer = new IntersectionObserver((entries) => {
 | 
			
		||||
            entries.forEach(entry => {
 | 
			
		||||
                if (entry.isIntersecting) {
 | 
			
		||||
                    this.animateElement(entry.target);
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }, options);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    animateElement(element) {
 | 
			
		||||
        // Add visible class to trigger CSS animations
 | 
			
		||||
        element.classList.add('animate-visible');
 | 
			
		||||
        
 | 
			
		||||
        // Animate child elements with stagger effect
 | 
			
		||||
        const children = element.querySelectorAll('.animate-stagger-1, .animate-stagger-2, .animate-stagger-3, .animate-stagger-4, .animate-stagger-5');
 | 
			
		||||
        children.forEach((child, index) => {
 | 
			
		||||
            setTimeout(() => {
 | 
			
		||||
                child.classList.add('animate-visible');
 | 
			
		||||
            }, index * 100);
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        // Stop observing this element once animated
 | 
			
		||||
        this.observer.unobserve(element);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    handlePageLoad() {
 | 
			
		||||
        // Add loading class initially
 | 
			
		||||
        document.body.classList.add('page-loading');
 | 
			
		||||
        
 | 
			
		||||
        window.addEventListener('load', () => {
 | 
			
		||||
            this.isPageLoaded = true;
 | 
			
		||||
            document.body.classList.remove('page-loading');
 | 
			
		||||
            document.body.classList.add('page-loaded');
 | 
			
		||||
            
 | 
			
		||||
            // Animate hero section immediately on load
 | 
			
		||||
            this.animateHeroSection();
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    animateHeroSection() {
 | 
			
		||||
        const heroElements = document.querySelectorAll('.hero-title, .hero-subtitle, .hero-button');
 | 
			
		||||
        heroElements.forEach(element => {
 | 
			
		||||
            element.classList.add('animate-visible');
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    initializeAnimations() {
 | 
			
		||||
        // Find all elements that should be animated
 | 
			
		||||
        const animatedElements = document.querySelectorAll(
 | 
			
		||||
            '.animate-fade-in, .animate-slide-left, .animate-slide-right, .animate-scale-up, .animate-text-content, .animate-image'
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        // Start observing each element
 | 
			
		||||
        animatedElements.forEach(element => {
 | 
			
		||||
            this.observer.observe(element);
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        // Add animation classes to row containers
 | 
			
		||||
        this.addAnimationClassesToRows();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    addAnimationClassesToRows() {
 | 
			
		||||
        // Get all row containers from the homepage
 | 
			
		||||
        const rows = document.querySelectorAll('[id*="row"], .relative.justify-center.flex.overflow-hidden');
 | 
			
		||||
        
 | 
			
		||||
        rows.forEach((row, index) => {
 | 
			
		||||
            // Add different animation types based on position
 | 
			
		||||
            const animationType = this.getAnimationTypeForRow(index);
 | 
			
		||||
            row.classList.add(animationType);
 | 
			
		||||
            
 | 
			
		||||
            // Add text content animation to text columns
 | 
			
		||||
            const textColumns = row.querySelectorAll('div[class*="flex-1"]');
 | 
			
		||||
            textColumns.forEach(column => {
 | 
			
		||||
                if (this.hasTextContent(column)) {
 | 
			
		||||
                    column.classList.add('animate-text-content');
 | 
			
		||||
                }
 | 
			
		||||
                
 | 
			
		||||
                // Add image animation to image containers
 | 
			
		||||
                const images = column.querySelectorAll('img');
 | 
			
		||||
                images.forEach(img => {
 | 
			
		||||
                    img.parentElement.classList.add('animate-image');
 | 
			
		||||
                });
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    getAnimationTypeForRow(index) {
 | 
			
		||||
        const animations = ['animate-fade-in', 'animate-slide-left', 'animate-slide-right', 'animate-scale-up'];
 | 
			
		||||
        return animations[index % animations.length];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    hasTextContent(element) {
 | 
			
		||||
        const textElements = element.querySelectorAll('h1, h2, h3, h4, p, button, a');
 | 
			
		||||
        return textElements.length > 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Method to trigger animations on scroll direction change
 | 
			
		||||
    handleScrollDirection() {
 | 
			
		||||
        let lastScrollTop = 0;
 | 
			
		||||
        
 | 
			
		||||
        window.addEventListener('scroll', () => {
 | 
			
		||||
            const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
 | 
			
		||||
            const scrollDirection = scrollTop > lastScrollTop ? 'down' : 'up';
 | 
			
		||||
            
 | 
			
		||||
            // You can add specific animations based on scroll direction here
 | 
			
		||||
            document.body.setAttribute('data-scroll-direction', scrollDirection);
 | 
			
		||||
            
 | 
			
		||||
            lastScrollTop = scrollTop <= 0 ? 0 : scrollTop;
 | 
			
		||||
        }, false);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Initialize animation system
 | 
			
		||||
let animationController;
 | 
			
		||||
 | 
			
		||||
// Enhanced window.onload to include animations
 | 
			
		||||
const originalWindowOnload = window.onload;
 | 
			
		||||
window.onload = function() {
 | 
			
		||||
    // Call original onload function
 | 
			
		||||
    if (originalWindowOnload) {
 | 
			
		||||
        originalWindowOnload();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    // Initialize animation controller
 | 
			
		||||
    animationController = new AnimationController();
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user