الملفات
talabatuk_plus_1/index.js
Muhammad Kadi 1fad70df4a ١
2026-03-16 17:25:57 +04:00

52 أسطر
1.8 KiB
JavaScript

/* ============================================
index.js - طلباتك بلس - الصفحة الرئيسية
============================================ */
// ---- تأثير العداد (Counter Animation) ----
function animateCounter(id, target, duration = 2000, suffix = '') {
let start = 0;
const increment = target / (duration / 16);
const el = document.getElementById(id);
const timer = setInterval(() => {
start += increment;
if (start >= target) {
clearInterval(timer);
el.textContent = Math.floor(target) + suffix;
} else {
el.textContent = Math.floor(start) + suffix;
}
}, 16);
}
// ---- مراقب التمرير للـ Fade-in والعدادات ----
function setupScrollAnimations() {
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
if (entry.target.id === 'stats') {
animateCounter('stat1', 35);
animateCounter('stat2', 2800, 1800);
animateCounter('stat3', 136);
animateCounter('stat4', 93, 1200, '%');
}
}
});
}, { threshold: 0.3 });
document.querySelectorAll('section').forEach(section => {
section.classList.add('fade-in');
observer.observe(section);
});
observer.observe(document.getElementById('stats'));
}
// ---- تهيئة كل شيء عند تحميل الصفحة ----
window.onload = function () {
setupScrollAnimations();
console.log('%c✅ موقع طلباتك بلس جاهز للاستخدام!', 'color:#ff661c; font-size:13px; font-weight:bold');
};