This repository was archived by the owner on Dec 18, 2024. It is now read-only.
generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 41
NW6 | Hadika Malik | Module JS2 | Week 4 | Slideshow #220
Open
HadikaMalik
wants to merge
1
commit into
CodeYourFuture:main
Choose a base branch
from
HadikaMalik:week-4-slideshow
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,39 @@ const images = [ | |
"./assets/cute-cat-a.png", | ||
"./assets/cute-cat-b.jpg", | ||
"./assets/cute-cat-c.jpg", | ||
"./assets/cute-cat.jpg" | ||
]; | ||
|
||
|
||
// Write your code here | ||
// Write your code here | ||
|
||
const autoBackBtn = document.getElementById("auto-backward-btn"); | ||
const backBtn = document.getElementById("backward-btn"); | ||
const stopBtn = document.getElementById("stop-btn"); | ||
const fwrdBtn = document.getElementById("forward-btn"); | ||
const autoFwrdBtn = document.getElementById("auto-forward-btn"); | ||
const carouselImages = document.getElementById("carousel-img"); | ||
let currentIndex = 1; | ||
let autoIntervalId; | ||
|
||
function forward (){ | ||
currentIndex = (currentIndex+1) % images.length; | ||
carouselImages.src = images[currentIndex]; | ||
} | ||
|
||
function backward (){ | ||
currentIndex = (currentIndex+3) % images.length; | ||
carouselImages.src = images[currentIndex]; | ||
} | ||
|
||
backBtn.addEventListener("click", backward); | ||
fwrdBtn.addEventListener("click", forward); | ||
autoBackBtn.addEventListener("click", ()=>{ | ||
autoIntervalId = setInterval(backward,2000); | ||
}); | ||
autoFwrdBtn.addEventListener("click", ()=>{ | ||
autoIntervalId = setInterval(forward,2000); | ||
}); | ||
stopBtn.addEventListener("click", ()=>{ | ||
clearInterval(autoIntervalId); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. great job with the event listeners and intervals, consider what happens though when the autoForward button is clicked multiple times. |
||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,36 @@ | ||
/** Write your CSS in here **/ | ||
body{ | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
background-color:azure; | ||
} | ||
|
||
#box{ | ||
display: flex; | ||
flex-direction: row; | ||
} | ||
|
||
img{ | ||
width: 500px; | ||
height: 400px; | ||
margin: 50px 0px; | ||
border: solid black 2px; | ||
border-radius: 5px; | ||
} | ||
|
||
button{ | ||
border: black solid 2px; | ||
border-radius: 5px; | ||
background-color:lightsteelblue; | ||
padding: 10px; | ||
margin: 0px 5px; | ||
font-size: large; | ||
} | ||
|
||
h1{ | ||
margin:50px 0px -10px 0px; | ||
color: rgb(10, 72, 153); | ||
font-weight: bold; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good job on adding the 4th cat!