Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Sprint-3/slideshow-extra/assets/butterfly1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Sprint-3/slideshow-extra/assets/butterfly2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Sprint-3/slideshow-extra/assets/butterfly3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Sprint-3/slideshow-extra/assets/cute-cat-a.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Sprint-3/slideshow-extra/assets/cute-cat-b.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Sprint-3/slideshow-extra/assets/cute-cat-c.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions Sprint-3/slideshow-extra/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Image Carousel</title>
<script defer src="slideshow.js"></script>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<label for="delay">Delay (ms):</label>
<input type="number" id="delay" value="2000" min="500" />

<img id="carousel-img" src="./assets/butterfly1.png" alt="butterfly-pic" />
<button type="button" id="backward-btn">Backwards</button>
<button type="button" id="forward-btn">Forward</button>
<button type="button" id="auto-forward">Auto-Forward</button>
<button type="button" id="auto-backward">Auto-Backward</button>
<button type="button" id="stop">Stop</button>
</body>
</html>
68 changes: 68 additions & 0 deletions Sprint-3/slideshow-extra/slideshow-extra.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
const images = [
"./assets/butterfly1.png",
"./assets/butterfly2.png",
"./assets/butterfly3.png",
"./assets/cute-cat-a.png",
"./assets/cute-cat-b.jpg",
"./assets/cute-cat-c.jpg",
];
// Write your code here

const imageElement = document.getElementById("carousel-img");
const forwardBtn = document.getElementById("forward-btn");
const backwardBtn = document.getElementById("backward-btn");
const autoForwardBtn = document.getElementById("auto-forward");
const autoBackwardBtn = document.getElementById("auto-backward");
const stopBtn = document.getElementById("stop");
const delayInput = document.getElementById("delay");

let currentIndex = 0;
imageElement.src = images[currentIndex];

function showNextImage() {
currentIndex++;
if (currentIndex >= images.length) {
currentIndex = 0;
}
imageElement.src = images[currentIndex];
}

function showPreviousImage() {
currentIndex--;
if (currentIndex < 0) {
currentIndex = images.length - 1;
}
imageElement.src = images[currentIndex];
}

let autoForwardInterval;
function startAutoForward() {
autoForwardBtn.disabled = true;
autoBackwardBtn.disabled = true;

const delay = Number(delayInput.value);

autoForwardInterval = setInterval(showNextImage, delay);
}
let autoBackwardInterval;
function startAutoBackward() {
autoForwardBtn.disabled = true;
autoBackwardBtn.disabled = true;

const delay = Number(delayInput.value);

autoBackwardInterval = setInterval(showPreviousImage, delay);
}

function stopAutoSlideshow() {
clearInterval(autoForwardInterval);
clearInterval(autoBackwardInterval);
autoForwardBtn.disabled = false;
autoBackwardBtn.disabled = false;
}

forwardBtn.addEventListener("click", showNextImage);
backwardBtn.addEventListener("click", showPreviousImage);
autoForwardBtn.addEventListener("click", startAutoForward);
autoBackwardBtn.addEventListener("click", startAutoBackward);
stopBtn.addEventListener("click", stopAutoSlideshow);
93 changes: 93 additions & 0 deletions Sprint-3/slideshow-extra/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
body {
font-family: Arial, sans-serif;
background-color: #f9f9f9;
margin: 0;
padding: 20px;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
color: #333;
}

.container {
background-color: white;
padding: 30px;
border-radius: 10px;
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
width: 100%;
max-width: 800px;
text-align: center;
}

img {
width: 100%;
max-width: 600px;
height: auto;
margin-bottom: 20px;
border-radius: 10px;
border: 4px solid #ddd;
}

button {
padding: 12px 24px;
font-size: 16px;
cursor: pointer;
background-color: #4caf50;
color: white;
border: none;
border-radius: 5px;
margin: 10px;
transition: background-color 0.3s;
}

button:hover {
background-color: #45a049;
}

button:disabled {
background-color: #ddd;
cursor: not-allowed;
}

label {
font-size: 16px;
color: #666;
display: block;
margin: 20px 0 5px;
font-weight: bold;
}

input[type="number"] {
padding: 10px;
font-size: 16px;
width: 150px;
margin-bottom: 20px;
border-radius: 5px;
border: 2px solid #ddd;
box-sizing: border-box;
}

input[type="number"]:focus {
border-color: #4caf50;
outline: none;
}

@media (max-width: 600px) {
.container {
padding: 20px;
}

button {
width: 100%;
margin: 10px 0;
}

input[type="number"] {
width: 100%;
}

img {
max-width: 100%;
}
}