Skip to content

Commit fea7a28

Browse files
Update index.html
1 parent cfefb89 commit fea7a28

1 file changed

Lines changed: 75 additions & 33 deletions

File tree

index.html

Lines changed: 75 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,6 @@
8484
z-index: 10;
8585
}
8686

87-
.carousel-dot {
88-
width: 12px;
89-
height: 12px;
90-
border-radius: 50%;
91-
background: rgba(255, 255, 255, 0);
92-
cursor: pointer;
93-
transition: background 0.3s;
94-
}
95-
96-
.carousel-dot.active {
97-
background: rgba(255, 255, 255, 0);
98-
}
99-
10087
.carousel-arrow {
10188
position: absolute;
10289
top: 50%;
@@ -146,6 +133,44 @@
146133
padding-top: 60px;
147134
padding-bottom: 0px;
148135
}
136+
137+
/* Progress Bar Styles */
138+
.carousel-progress {
139+
position: absolute;
140+
bottom: 15px;
141+
left: 50%;
142+
transform: translateX(-50%);
143+
display: flex;
144+
gap: 6px;
145+
z-index: 10;
146+
}
147+
148+
.progress-segment {
149+
width: 40px;
150+
height: 4px;
151+
background: rgba(255, 255, 255, 0.4);
152+
border-radius: 2px;
153+
overflow: hidden;
154+
cursor: pointer;
155+
}
156+
157+
.progress-fill {
158+
height: 100%;
159+
width: 0%;
160+
background: white;
161+
border-radius: 2px;
162+
}
163+
164+
.progress-fill.animating {
165+
width: 100%;
166+
transition: width 5s linear;
167+
}
168+
169+
.progress-fill.done {
170+
width: 100%;
171+
transition: none;
172+
}
173+
149174
</style>
150175
</head>
151176

@@ -193,7 +218,7 @@
193218
</div>
194219
</div>
195220
</header>
196-
221+
197222
<!-- Image Carousel -->
198223
<div class="image-carousel">
199224
<div class="carousel-slides" id="carouselTrack">
@@ -227,14 +252,14 @@
227252
<button class="carousel-arrow prev" onclick="moveSlide(-1)">&#10094;</button>
228253
<button class="carousel-arrow next" onclick="moveSlide(1)">&#10095;</button>
229254

230-
<!-- Navigation Dots -->
231-
<div class="carousel-nav">
232-
<span class="carousel-dot active" onclick="currentSlide(0)"></span>
233-
<span class="carousel-dot" onclick="currentSlide(1)"></span>
234-
<span class="carousel-dot" onclick="currentSlide(2)"></span>
235-
<span class="carousel-dot" onclick="currentSlide(3)"></span>
236-
<span class="carousel-dot" onclick="currentSlide(4)"></span>
237-
<span class="carousel-dot" onclick="currentSlide(5)"></span>
255+
<!-- Progress Bar -->
256+
<div class="carousel-progress">
257+
<div class="progress-segment" onclick="currentSlide(0)"><div class="progress-fill" id="prog-0"></div></div>
258+
<div class="progress-segment" onclick="currentSlide(1)"><div class="progress-fill" id="prog-1"></div></div>
259+
<div class="progress-segment" onclick="currentSlide(2)"><div class="progress-fill" id="prog-2"></div></div>
260+
<div class="progress-segment" onclick="currentSlide(3)"><div class="progress-fill" id="prog-3"></div></div>
261+
<div class="progress-segment" onclick="currentSlide(4)"><div class="progress-fill" id="prog-4"></div></div>
262+
<div class="progress-segment" onclick="currentSlide(5)"><div class="progress-fill" id="prog-5"></div></div>
238263
</div>
239264
</div>
240265

@@ -494,15 +519,10 @@ <h4>Follow Us</h4>
494519

495520
<!-- Carousel Script -->
496521
<script>
497-
// Seamless infinite loop using cloned first/last slides.
498-
// Track order: [clone of last] [slide1] [slide2] ... [slideN] [clone of first]
499-
500522
const track = document.getElementById("carouselTrack");
501-
const dots = document.querySelectorAll(".carousel-dot");
502523
const realSlides = Array.from(track.querySelectorAll(".carousel-slide"));
503524
const total = realSlides.length;
504525

505-
// Clone first and last slides and insert them
506526
const firstClone = realSlides[0].cloneNode(true);
507527
const lastClone = realSlides[total - 1].cloneNode(true);
508528
track.appendChild(firstClone);
@@ -511,21 +531,40 @@ <h4>Follow Us</h4>
511531
let current = 1;
512532
let isTransitioning = false;
513533

534+
function getProgressFills() {
535+
return Array.from({ length: total }, (_, i) => document.getElementById(`prog-${i}`));
536+
}
537+
538+
function startProgress(index) {
539+
const fills = getProgressFills();
540+
fills.forEach((fill, i) => {
541+
fill.classList.remove("animating", "done");
542+
if (i < index) {
543+
fill.classList.add("done");
544+
}
545+
});
546+
void fills[index].offsetWidth;
547+
fills[index].classList.add("animating");
548+
}
549+
514550
function goTo(index, animate) {
515551
track.style.transition = animate === false ? "none" : "transform 0.8s ease-in-out";
516552
track.style.transform = `translateX(-${index * 100}%)`;
517553
current = index;
518554

519-
const dotIndex = (index - 1 + total) % total;
520-
dots.forEach(dot => dot.classList.remove("active"));
521-
dots[dotIndex].classList.add("active");
555+
if (animate !== false) {
556+
const dotIndex = (index - 1 + total) % total;
557+
startProgress(dotIndex);
558+
}
522559
}
523560

524561
track.addEventListener("transitionend", () => {
525562
if (current === 0) {
526563
goTo(total, false);
564+
startProgress(total - 1);
527565
} else if (current === total + 1) {
528566
goTo(1, false);
567+
startProgress(0);
529568
}
530569
isTransitioning = false;
531570
});
@@ -546,10 +585,16 @@ <h4>Follow Us</h4>
546585

547586
function resetTimer() {
548587
clearInterval(autoSlide);
588+
const fills = getProgressFills();
589+
const dotIndex = (current - 1 + total) % total;
590+
fills[dotIndex].classList.remove("animating", "done");
591+
void fills[dotIndex].offsetWidth;
592+
fills[dotIndex].classList.add("animating");
549593
autoSlide = setInterval(() => moveSlide(1), 5000);
550594
}
551595

552596
goTo(1, false);
597+
startProgress(0);
553598

554599
let autoSlide = setInterval(() => moveSlide(1), 5000);
555600
</script>
@@ -620,6 +665,3 @@ <h4>Follow Us</h4>
620665

621666

622667
</html>
623-
624-
625-

0 commit comments

Comments
 (0)