Commit 9a912761 by Arjun Jhukal

updated the minor changes

parent 4256076a
...@@ -132,32 +132,63 @@ ...@@ -132,32 +132,63 @@
$(".category-list").removeClass("active"); $(".category-list").removeClass("active");
}); });
const tocObserver = new IntersectionObserver( // const tocObserver = new IntersectionObserver(
function (entries) { // function (entries) {
entries.forEach((entry) => { // entries.forEach((entry) => {
if (entry.isIntersecting) { // if (entry.isIntersecting) {
$(".toc h6").show(); // $(".toc h6").show();
console.log("is intersecting") // console.log("is intersecting")
} else { // } else {
$(".toc h6").hide(); // $(".toc h6").hide();
console.log("is not intersecting") // console.log("is not intersecting")
} // }
}); // });
}, // },
{ // {
threshold: 0.3, // threshold: 0.1,
}, // },
); // );
// const sections = [
// document.querySelector(".BLOGDETAIL-LIST-ITEM-SECTION"),
// document.querySelector(".BLOGLISTING-LIST-ITEM-SECTION"),
// document.querySelector(".case-study-general"),
// ];
// sections.length &&
// sections.forEach((section) => {
// if (section) tocObserver.observe(section);
// });
const sections = [ const sections = [
document.querySelector(".BLOGDETAIL-LIST-ITEM-SECTION"), document.querySelector(".BLOGDETAIL-LIST-ITEM-SECTION"),
document.querySelector(".BLOGLISTING-LIST-ITEM-SECTION"), document.querySelector(".BLOGLISTING-LIST-ITEM-SECTION"),
document.querySelector(".case-study-general"), document.querySelector(".case-study-general"),
]; ];
sections.length &&
sections.forEach((section) => { // Filter out any null sections
if (section) tocObserver.observe(section); const validSections = sections.filter(Boolean);
});
if (validSections.length) {
const handleScroll = () => {
const scrollTop = $(window).scrollTop();
const viewportHeight = $(window).height();
if (scrollTop > viewportHeight) {
$(".toc h6").show();
console.log("Scrolled past 100vh");
} else {
$(".toc h6").hide();
console.log("Above 100vh");
}
};
// Bind scroll event
$(window).on("scroll", handleScroll);
// Run on page load too
$(document).ready(handleScroll);
}
}); });
/** MOBILE OFFCANVAS TOC ENDS HERE */ /** MOBILE OFFCANVAS TOC ENDS HERE */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment