File tree Expand file tree Collapse file tree 2 files changed +41
-1
lines changed
Week-3/Homework/mandatory/3-slideshow Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 2323.image
2424{
2525 width : 50em ;
26- height : auto ;
26+ height : 30 em ;
2727 border : 10px solid;
2828 border-color : rgb (241 , 203 , 192 );
2929}
You can’t perform that action at this time.
0 commit comments