File tree 1 file changed +21
-4
lines changed
1 file changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -19,13 +19,30 @@ prevBtn.addEventListener("click", function () {
19
19
} ) ;
20
20
21
21
function carousel ( ) {
22
- if ( counter > slides . length - 1 ) {
23
- counter = 0 ;
22
+ /* Working with Slides */
23
+ // if (counter > slides.length - 1) {
24
+ // counter = 0;
25
+ // }
26
+ // if (counter < 0) {
27
+ // counter = slides.length - 1;
28
+ // }
29
+
30
+ /* Working with Buttons */
31
+ if ( counter < slides . length - 1 ) {
32
+ nextBtn . style . display = "block" ;
33
+ } else {
34
+ nextBtn . style . display = "none" ;
24
35
}
25
- if ( counter < 0 ) {
26
- counter = slides . length - 1 ;
36
+
37
+ if ( counter > 0 ) {
38
+ prevBtn . style . display = "block" ;
39
+ } else {
40
+ prevBtn . style . display = "none" ;
27
41
}
42
+
28
43
slides . forEach ( function ( slide ) {
29
44
slide . style . transform = `translateX(-${ counter * 100 } %)` ;
30
45
} ) ;
31
46
}
47
+
48
+ prevBtn . style . display = "none" ;
You can’t perform that action at this time.
0 commit comments