forked from Nana-king-netizen/Dummy_LMS_Frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
26 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters