Skip to content

Commit

Permalink
Disconnected javascript
Browse files Browse the repository at this point in the history
  • Loading branch information
blip-cmd committed Nov 28, 2023
1 parent 1822f83 commit ebecb52
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
44 changes: 22 additions & 22 deletions script.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@


// Function to check if an element is in the viewport
function isInViewport(element) {
const rect = element.getBoundingClientRect();
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
rect.right <= (window.innerWidth || document.documentElement.clientWidth)
);
}
// // Function to check if an element is in the viewport
// function isInViewport(element) {
// const rect = element.getBoundingClientRect();
// return (
// rect.top >= 0 &&
// rect.left >= 0 &&
// rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
// rect.right <= (window.innerWidth || document.documentElement.clientWidth)
// );
// }

// Function to handle scroll event
function handleScroll() {
const whatWeOfferSection = document.querySelector('.what-we-offer');
if (isInViewport(whatWeOfferSection)) {
whatWeOfferSection.classList.add('show');
window.removeEventListener('scroll', handleScroll);
}
}
// // Function to handle scroll event
// function handleScroll() {
// const whatWeOfferSection = document.querySelector('.what-we-offer');
// if (isInViewport(whatWeOfferSection)) {
// whatWeOfferSection.classList.add('show');
// window.removeEventListener('scroll', handleScroll);
// }
// }

// Add event listener for scroll
window.addEventListener('scroll', handleScroll);
// // Add event listener for scroll
// window.addEventListener('scroll', handleScroll);

// Initial check in case the element is already visible on page load
handleScroll();
// // Initial check in case the element is already visible on page load
// handleScroll();
8 changes: 4 additions & 4 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -148,16 +148,16 @@ body {
padding: 60px 0;
}

.what-we-offer {
/* .what-we-offer {
opacity: 0;
transform: translateY(20px);
transition: opacity 1s ease, transform 1s ease;
}

} */
/*
.what-we-offer.show {
opacity: 1;
transform: translateY(0);
}
} */


h2 {
Expand Down

0 comments on commit ebecb52

Please sign in to comment.