-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
112 lines (91 loc) · 2.76 KB
/
Copy pathscript.js
File metadata and controls
112 lines (91 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
document.addEventListener('DOMContentLoaded', () => {
// --- SLIDER ---
const slides = document.querySelectorAll('.slide');
const prevBtn = document.querySelector('.slider-nav.prev');
const nextBtn = document.querySelector('.slider-nav.next');
const dots = document.querySelectorAll('.dot');
let current = 0;
let intervalId;
function showSlide(index) {
slides.forEach((slide, i) => {
slide.classList.toggle('active', i === index);
dots[i].classList.toggle('active', i === index);
});
current = index;
}
function startAutoSlide() {
clearInterval(intervalId);
intervalId = setInterval(() => {
current = (current + 1) % slides.length;
showSlide(current);
}, 5000);
}
// İlk slaytı göster ve otomatik başlat
showSlide(current);
startAutoSlide();
// Ok navigasyonu
prevBtn.addEventListener('click', () => {
current = (current - 1 + slides.length) % slides.length;
showSlide(current);
startAutoSlide();
});
nextBtn.addEventListener('click', () => {
current = (current + 1) % slides.length;
showSlide(current);
startAutoSlide();
});
// Nokta navigasyonu
dots.forEach(dot => {
dot.addEventListener('click', () => {
current = Number(dot.dataset.index);
showSlide(current);
startAutoSlide();
});
});
// --- SABİT MENÜ GÖSTER/GİZLE ---
const menu = document.querySelector('.scroll-menu');
window.addEventListener('scroll', () => {
menu.classList.toggle('visible', window.scrollY > 0);
});
// --- SMOOTH SCROLL + OFFSET ---
const links = document.querySelectorAll(
'.scroll-menu a[href^="#"], .slide-content a[href^="#"]'
);
links.forEach(link => {
link.addEventListener('click', e => {
e.preventDefault();
const targetId = link.getAttribute('href').slice(1);
const targetEl = document.getElementById(targetId);
if (!targetEl || !menu) return;
const menuHeight = menu.offsetHeight;
const elementY = targetEl.getBoundingClientRect().top + window.pageYOffset;
const targetY = elementY - menuHeight;
window.scrollTo({
top: targetY,
behavior: 'smooth'
});
history.pushState(null, '', `#${targetId}`);
});
});
});
// --- ScrollTop ---
var scrollTop = document.getElementById("scrollTop");
window.onscroll = function(){
scrollfunction()
};
function scrollfunction(){
if( document.body.scrollTop > 20 || document.documentElement.scrollTop > 20){
scrollTop.style.display = "block";
} else {
scrollTop.style.display = "none";
}
}
scrollTop.addEventListener("click", function(){
window.scrollTo({
left: 0,
top: 0,
behavior: "smooth"
})
})
// --- Call ScrollTop ---
$('#scrollTop').popup();