init
This commit is contained in:
commit
95a2de8058
3 changed files with 955 additions and 0 deletions
66
script.js
Normal file
66
script.js
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
document.documentElement.classList.add("js-ready");
|
||||
|
||||
const revealItems = document.querySelectorAll(".reveal");
|
||||
|
||||
const revealObserver = new IntersectionObserver(
|
||||
(entries) => {
|
||||
entries.forEach((entry) => {
|
||||
if (entry.isIntersecting) {
|
||||
entry.target.classList.add("is-visible");
|
||||
revealObserver.unobserve(entry.target);
|
||||
}
|
||||
});
|
||||
},
|
||||
{
|
||||
threshold: 0.18,
|
||||
}
|
||||
);
|
||||
|
||||
revealItems.forEach((item) => revealObserver.observe(item));
|
||||
|
||||
const counters = document.querySelectorAll(".counter");
|
||||
|
||||
const animateCounter = (element) => {
|
||||
const target = Number(element.dataset.target);
|
||||
const duration = 1400;
|
||||
const startTime = performance.now();
|
||||
|
||||
const tick = (now) => {
|
||||
const progress = Math.min((now - startTime) / duration, 1);
|
||||
const eased = 1 - Math.pow(1 - progress, 3);
|
||||
element.textContent = Math.round(target * eased);
|
||||
|
||||
if (progress < 1) {
|
||||
requestAnimationFrame(tick);
|
||||
}
|
||||
};
|
||||
|
||||
requestAnimationFrame(tick);
|
||||
};
|
||||
|
||||
const counterObserver = new IntersectionObserver(
|
||||
(entries) => {
|
||||
entries.forEach((entry) => {
|
||||
if (entry.isIntersecting) {
|
||||
animateCounter(entry.target);
|
||||
counterObserver.unobserve(entry.target);
|
||||
}
|
||||
});
|
||||
},
|
||||
{
|
||||
threshold: 0.4,
|
||||
}
|
||||
);
|
||||
|
||||
counters.forEach((counter) => counterObserver.observe(counter));
|
||||
|
||||
const contactForm = document.querySelector(".contact-form");
|
||||
|
||||
contactForm?.addEventListener("submit", (event) => {
|
||||
event.preventDefault();
|
||||
const button = contactForm.querySelector("button");
|
||||
if (button) {
|
||||
button.textContent = "Request Received";
|
||||
button.disabled = true;
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue