Skip to content

Commit 1eb9d28

Browse files
committed
V3.3 week3
completed the first challenge in image slider.
1 parent 69d58f4 commit 1eb9d28

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,41 @@
11
// Write your code here
2+
3+
window.onload=function()
4+
{
5+
var imageSource=[
6+
"https://images.unsplash.com/photo-1595589981991-7f37459639c5?ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60",
7+
"https://images.unsplash.com/photo-1595100930017-8d4112e87959?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60",
8+
"https://images.unsplash.com/photo-1595024600400-2a49b9fce270?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60",
9+
"https://images.unsplash.com/photo-1508269757141-a5eaf8a31ef4?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60",
10+
"https://images.unsplash.com/photo-1432889490240-84df33d47091?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60",
11+
"https://images.unsplash.com/photo-1484896104369-90eb48a7596b?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60"
12+
13+
];
14+
15+
let backButton=document.querySelector(".back");
16+
let forwardButton=document.querySelector(".forward");
17+
18+
var imageEl=document.querySelector(".image");
19+
var currentIndex=0;
20+
21+
backButton.addEventListener("click",function(){
22+
if(currentIndex <= 0)
23+
return;
24+
else
25+
{
26+
currentIndex=currentIndex-1;
27+
imageEl.src=imageSource[currentIndex];
28+
}
29+
30+
31+
});
32+
forwardButton.addEventListener("click",function(){
33+
if(currentIndex >= imageSource.length -1)
34+
return
35+
else{
36+
currentIndex=currentIndex+1;
37+
imageEl.src=imageSource[currentIndex];
38+
}
39+
40+
});
41+
}

Week-3/Homework/mandatory/3-slideshow/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
.image
2424
{
2525
width:50em;
26-
height: auto;
26+
height: 30em;
2727
border: 10px solid;
2828
border-color: rgb(241, 203, 192);
2929
}

0 commit comments

Comments
 (0)