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
NW-6 | Fikret Ellek | JS2| [TECH ED] Slideshow| WEEK-4 #226
Open
fikretellek
wants to merge
6
commits into
CodeYourFuture:main
Choose a base branch
from
fikretellek: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
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bd73e06
level 1 implemented
fikretTest 9906166
started for level 2, buttons added ın html
fikretTest 5fad378
autoplay functions added
fikretTest a0eda2e
stop autoplay function added
fikretTest e24b044
editted css
fikretTest 6f8f722
when clicked on the both autoplay buttons, overlaping bug detected. F…
fikretTest 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
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 |
---|---|---|
@@ -1,8 +1,66 @@ | ||
const images = [ | ||
"./assets/cute-cat-a.png", | ||
"./assets/cute-cat-b.jpg", | ||
"./assets/cute-cat-c.jpg", | ||
"./assets/cute-cat-a.png", | ||
"./assets/cute-cat-b.jpg", | ||
"./assets/cute-cat-c.jpg", | ||
]; | ||
|
||
let currentPhotoIndex = 1; | ||
|
||
// Write your code here | ||
const image = document.getElementById("carousel-img"); | ||
|
||
const backwardBtn = document.getElementById("backward-btn"); | ||
const forwardBtn = document.getElementById("forward-btn"); | ||
|
||
const stopBtn = document.getElementById("stop-btn"); | ||
|
||
const autoBackwardBtn = document.getElementById("auto-backward-btn"); | ||
const autoForwardBtn = document.getElementById("auto-forward-btn"); | ||
|
||
let autoPlayBackward; | ||
let autoPlayForward; | ||
|
||
// Write your code here | ||
|
||
function generatePhoto() { | ||
image.setAttribute("src", images[currentPhotoIndex]); | ||
} | ||
|
||
function nextPhoto() { | ||
++currentPhotoIndex; | ||
if (currentPhotoIndex === 3) { | ||
currentPhotoIndex = 0; | ||
} | ||
generatePhoto(); | ||
} | ||
|
||
function previousPhoto() { | ||
--currentPhotoIndex; | ||
if (currentPhotoIndex === -1) { | ||
currentPhotoIndex = 2; | ||
} | ||
generatePhoto(); | ||
} | ||
|
||
backwardBtn.addEventListener("click", previousPhoto); | ||
forwardBtn.addEventListener("click", nextPhoto); | ||
|
||
autoBackwardBtn.addEventListener("click", () => { | ||
autoPlayBackward = setInterval(() => { | ||
previousPhoto(); | ||
}, 1000); | ||
clearInterval(autoPlayForward); | ||
}); | ||
|
||
autoForwardBtn.addEventListener("click", () => { | ||
autoPlayForward = setInterval(() => { | ||
nextPhoto(); | ||
}, 1000); | ||
clearInterval(autoPlayBackward); | ||
}); | ||
|
||
stopBtn.addEventListener("click", () => { | ||
clearInterval(autoPlayBackward); | ||
clearInterval(autoPlayForward); | ||
}); | ||
|
||
window.onload = generatePhoto; |
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,7 @@ | ||
/** Write your CSS in here **/ | ||
|
||
#carousel-img { | ||
width: auto; | ||
height: 400px; | ||
display: block; | ||
} |
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.
The requirement here was to have at least 4 images!