| |
|
|
| |
| document.addEventListener('DOMContentLoaded', function() { |
| |
| const anchorLinks = document.querySelectorAll('a[href^="#"]'); |
| anchorLinks.forEach(link => { |
| link.addEventListener('click', function(e) { |
| e.preventDefault(); |
| const targetId = this.getAttribute('href'); |
| const targetElement = document.querySelector(targetId); |
| if (targetElement) { |
| targetElement.scrollIntoView({ |
| behavior: 'smooth', |
| block: 'start' |
| }); |
| } |
| }); |
| }); |
|
|
| |
| const observerOptions = { |
| threshold: 0.1, |
| rootMargin: '0px 0px -50px 0px' |
| }; |
|
|
| const observer = new IntersectionObserver(function(entries) { |
| entries.forEach(entry => { |
| if (entry.isIntersecting) { |
| entry.target.classList.add('opacity-100', 'translate-y-0'); |
| entry.target.classList.remove('opacity-0', 'translate-y-8'); |
| } |
| }); |
| }, observerOptions); |
|
|
| |
| const animatedElements = document.querySelectorAll('.feature-card, .explore-card'); |
| animatedElements.forEach(el => { |
| el.classList.add('opacity-0', 'translate-y-8', 'transition-all', 'duration-700'); |
| observer.observe(el); |
| }); |
|
|
| |
| window.addEventListener('scroll', function() { |
| const scrolled = window.pageYOffset; |
| const parallaxElements = document.querySelectorAll('.parallax'); |
| parallaxElements.forEach(el => { |
| const speed = el.dataset.speed || 0.5; |
| el.style.transform = `translateY(${scrolled * speed}px)`; |
| }); |
|
|
| |
| const themeToggle = document.querySelector('#theme-toggle'); |
| if (themeToggle) { |
| themeToggle.addEventListener('click', function() { |
| document.body.classList.toggle('dark'); |
| |
| const isDark = document.body.classList.contains('dark'); |
| localStorage.setItem('bumdfun-theme', isDark ? 'dark' : 'light'); |
| }); |
| } |
|
|
| |
| const savedTheme = localStorage.getItem('bumdfun-theme'); |
| if (savedTheme === 'dark') { |
| document.body.classList.add('dark'); |
| } |
|
|
| |
| const initTooltips = () => { |
| const tooltipElements = document.querySelectorAll('[data-tooltip]'); |
| tooltipElements.forEach(el => { |
| el.addEventListener('mouseenter', function() { |
| const tooltip = document.createElement('div'); |
| tooltip.className = 'absolute z-50 px-3 py-2 text-sm font-medium text-white bg-gray-900 rounded-lg shadow-sm tooltip'; |
| tooltip.textContent = this.dataset.tooltip; |
| document.body.appendChild(tooltip); |
|
|
| const rect = this.getBoundingClientRect(); |
| tooltip.style.left = `${rect.left + window.scrollX}px`; |
| tooltip.style.top = `${rect.top + window.scrollY - 40}px`; |
|
|
| this.addEventListener('mouseleave', function() { |
| tooltip.remove(); |
| }, { once: true }); |
| }); |
| }); |
| }; |
|
|
| initTooltips(); |
| }); |
|
|
| |
| async function fetchBumdData(endpoint) { |
| try { |
| const response = await fetch(`https://api.bumdfun.com/${endpoint}`); |
| if (!response.ok) { |
| throw new Error('Network response was not ok'); |
| } |
| return await response.json(); |
| } catch (error) { |
| console.error('Error fetching data:', error); |
| return null; |
| } |
| } |
|
|
| |
| window.BumdFunUtils = { |
| fetchBumdData |
| }; |