Skip to content

Commit

Permalink
Update scriptKarGec.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Oytun12 authored Aug 4, 2024
1 parent a7f273f commit c05b5bd
Showing 1 changed file with 3 additions and 33 deletions.
36 changes: 3 additions & 33 deletions scriptKarGec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,6 @@ const toggleMenu = () => {
}
};

// En yakın başlık (h1, h2, h3, h4, h5, h6) bulma fonksiyonu
const findNearestHeading = (element) => {
let sibling = element.previousElementSibling;
while (sibling) {
if (/^H[1-6]$/.test(sibling.tagName)) {
return sibling;
}
sibling = sibling.previousElementSibling;
}
return null;
};

// Bir sonraki başlığı bulma fonksiyonu
const findNextVisibleHeading = (element) => {
let sibling = element.nextElementSibling;
while (sibling) {
if (/^H[1-6]$/.test(sibling.tagName) && sibling.offsetParent !== null) {
return sibling;
}
sibling = sibling.nextElementSibling;
}
return null;
};

// Menü dışında bir yere tıklanınca menüyü gizle
document.addEventListener('click', (event) => {
const menu = document.getElementById('hamburger-menu');
Expand All @@ -56,26 +32,20 @@ document.addEventListener('click', (event) => {
if (content && content.classList.contains('visible') && !collapsible.contains(event.target) && !content.contains(event.target)) {
content.classList.remove('visible');
content.classList.add('hidden');

// Bir sonraki başlığa kaydır
const nextHeading = findNextVisibleHeading(collapsible);
if (nextHeading) {
nextHeading.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
}
});
});

document.addEventListener("DOMContentLoaded", function() {
document.addEventListener("DOMContentLoaded", () => {
const collapsibles = document.querySelectorAll(".collapsible");

collapsibles.forEach(collapsible => {
collapsible.addEventListener("click", function() {
const content = this.nextElementSibling;
if (content) {
const isVisible = content.classList.contains('visible');
content.classList.toggle("hidden");
content.classList.toggle("visible");
content.classList.toggle("hidden", isVisible);
content.classList.toggle("visible", !isVisible);

// İçeriğin açılma/kapanma işlemi tamamlandıktan sonra kaydırma işlemini gerçekleştir
setTimeout(() => {
Expand Down

0 comments on commit c05b5bd

Please sign in to comment.