generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 193
West Midlands | 25-ITP-Sep | Baba Yusuf | Sprint 3 | Slideshow #907
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Baba05206
wants to merge
7
commits into
CodeYourFuture:main
Choose a base branch
from
Baba05206: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.
+67
−5
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
11e30f5
Add initial implementation of mean calculation and tests
Baba05206 3cb29a0
Refactor mean calculation and tests for clarity and functionality
Baba05206 3d4c407
Update mean.js
Baba05206 17dea8e
deleted prep
805fee7
Merge branch 'main' of https://github.com/Baba05206/Module-Data-Groups
Baba05206 532d29e
Implement image carousel functionality with auto-forward and auto-bac…
Baba05206 6990322
added a new cat image to the carousel + implemented all the suggested…
Baba05206 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 |
|---|---|---|
| @@ -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", | ||
Baba05206 marked this conversation as resolved.
Show resolved
Hide resolved
Baba05206 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "./assets/cute-cat-d.png", | ||
| ]; | ||
|
|
||
| //Write your code here | ||
| let currentIndex = 0; | ||
| let slideshowIntervalId = null; | ||
|
|
||
| // Write your code here | ||
| const carouselImage = document.querySelector("#carousel-img"); | ||
| const forwardButton = document.querySelector("#forward-btn"); | ||
| const backwardButton = document.querySelector("#backward-btn"); | ||
|
|
||
| const autoForwardButton = document.querySelector("#auto-forward"); | ||
| const autoBackwardButton = document.querySelector("#auto-backward"); | ||
| const stopButton = document.querySelector("#stop"); | ||
|
|
||
| function updateImage() { | ||
| carouselImage.src = images[currentIndex]; | ||
| } | ||
|
|
||
| function moveForward() { | ||
| currentIndex = (currentIndex + 1) % images.length; | ||
| updateImage(); | ||
| } | ||
|
|
||
| function moveBackward() { | ||
| currentIndex = (currentIndex - 1 + images.length) % images.length; | ||
| updateImage(); | ||
| } | ||
|
|
||
| forwardButton.addEventListener("click", moveForward); | ||
| backwardButton.addEventListener("click", moveBackward); | ||
|
|
||
| // ---- AUTOMATIC SLIDESHOW ---- | ||
|
|
||
| function startAutoSlideshow(direction) { | ||
| stopAutoSlideshow(); // clear any previous interval | ||
|
|
||
| // Disable auto buttons | ||
| autoForwardButton.disabled = true; | ||
| autoBackwardButton.disabled = true; | ||
|
|
||
| slideshowIntervalId = setInterval(() => { | ||
| direction === "forward" ? moveForward() : moveBackward(); | ||
| }, 2000); | ||
| } | ||
|
|
||
| function stopAutoSlideshow() { | ||
| clearInterval(slideshowIntervalId); | ||
| slideshowIntervalId = null; | ||
|
|
||
| // Re-enable buttons | ||
| autoForwardButton.disabled = false; | ||
| autoBackwardButton.disabled = false; | ||
| } | ||
|
|
||
| autoForwardButton.addEventListener("click", () => | ||
| startAutoSlideshow("forward") | ||
| ); | ||
| autoBackwardButton.addEventListener("click", () => | ||
| startAutoSlideshow("backward") | ||
| ); | ||
| stopButton.addEventListener("click", stopAutoSlideshow); | ||
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 work! @Baba05206
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.
Many thanks @jaymes15.