feat:slider added
This commit is contained in:
parent
c1e9de0e63
commit
b9d0c66dd7
32
index.html
32
index.html
@ -565,6 +565,32 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
<div id="slider-placeholder"></div>
|
||||
|
||||
<script>
|
||||
fetch("slider.html")
|
||||
.then(res => res.text())
|
||||
.then(data => {
|
||||
const placeholder = document.getElementById("slider-placeholder");
|
||||
placeholder.innerHTML = data;
|
||||
|
||||
// Run the slider initialization function
|
||||
const scripts = placeholder.querySelectorAll("script");
|
||||
scripts.forEach(oldScript => {
|
||||
if (oldScript.textContent.includes("initSlider")) {
|
||||
const newScript = document.createElement("script");
|
||||
newScript.textContent = oldScript.textContent + "\ninitSlider();";
|
||||
document.body.appendChild(newScript);
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(err => console.error("Failed to load slider:", err));
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<section class="our-numbers">
|
||||
<h2>Our Numbers</h2>
|
||||
|
||||
@ -601,6 +627,9 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
<div id="footer-placeholder"></div>
|
||||
<script>
|
||||
fetch("footer.html")
|
||||
@ -613,6 +642,9 @@
|
||||
window.location.href = "/login";
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
48
slider.html
48
slider.html
@ -1,5 +1,22 @@
|
||||
<div class="slider-container">
|
||||
<div class="slider-wrapper">
|
||||
<div class="slider-track" id="sliderTrack">
|
||||
<div class="slide"></div>
|
||||
<div class="slide"></div>
|
||||
<div class="slide"></div>
|
||||
<div class="slide"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button class="nav-button prev-btn" id="prevBtn"></button>
|
||||
<button class="nav-button next-btn" id="nextBtn"></button>
|
||||
|
||||
<div class="dots-container" id="dotsContainer"></div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.slider-container {
|
||||
margin: 0 auto;
|
||||
max-width: 800px;
|
||||
width: 100%;
|
||||
position: relative;
|
||||
@ -139,24 +156,9 @@
|
||||
}
|
||||
</style>
|
||||
|
||||
<body>
|
||||
<div class="slider-container">
|
||||
<div class="slider-wrapper">
|
||||
<div class="slider-track" id="sliderTrack">
|
||||
<div class="slide"></div>
|
||||
<div class="slide"></div>
|
||||
<div class="slide"></div>
|
||||
<div class="slide"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button class="nav-button prev-btn" id="prevBtn"></button>
|
||||
<button class="nav-button next-btn" id="nextBtn"></button>
|
||||
|
||||
<div class="dots-container" id="dotsContainer"></div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script>
|
||||
function initSlider() {
|
||||
class SimpleSlider {
|
||||
constructor() {
|
||||
this.track = document.getElementById('sliderTrack');
|
||||
@ -223,13 +225,6 @@
|
||||
this.nextBtn.addEventListener('click', () => this.nextSlide());
|
||||
this.prevBtn.addEventListener('click', () => this.prevSlide());
|
||||
|
||||
// Keyboard navigation
|
||||
document.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'ArrowLeft') this.prevSlide();
|
||||
if (e.key === 'ArrowRight') this.nextSlide();
|
||||
});
|
||||
|
||||
// Touch navigation for mobile
|
||||
let startX = 0;
|
||||
this.track.addEventListener('touchstart', (e) => {
|
||||
startX = e.touches[0].clientX;
|
||||
@ -247,7 +242,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
new SimpleSlider();
|
||||
});
|
||||
</script>
|
||||
}
|
||||
</script>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user