forked from bpd01001/dmd-3475-assignment-repo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ryan-cohutt
committed
Apr 23, 2024
1 parent
6b33262
commit 6dda17d
Showing
8 changed files
with
482 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 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 |
---|---|---|
@@ -0,0 +1,126 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Slice Haven</title> | ||
<link rel="stylesheet" href="css/style.css"> | ||
<link rel="stylesheet" href="https://use.typekit.net/oxo3yif.css"> | ||
</head> | ||
<body> | ||
<section class="main-sect"> | ||
<div class="main-nav"> | ||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="main-icons" style="grid-column: 1; justify-self: flex-start;"> | ||
<path d="M399 384.2C376.9 345.8 335.4 320 288 320H224c-47.4 0-88.9 25.8-111 64.2c35.2 39.2 86.2 63.8 143 63.8s107.8-24.7 143-63.8zM0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256zm256 16a72 72 0 1 0 0-144 72 72 0 1 0 0 144z"/> | ||
</svg> | ||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="main-icons" style="grid-column: 2; justify-self: flex-end;"> | ||
<path d="M3.9 54.9C10.5 40.9 24.5 32 40 32H472c15.5 0 29.5 8.9 36.1 22.9s4.6 30.5-5.2 42.5L320 320.9V448c0 12.1-6.8 23.2-17.7 28.6s-23.8 4.3-33.5-3l-64-48c-8.1-6-12.8-15.5-12.8-25.6V320.9L9 97.3C-.7 85.4-2.8 68.8 3.9 54.9z"/> | ||
</svg> | ||
</div> | ||
<h1 class="fraunces-reg black main-headline">Find Your Pie!</h1> | ||
<div class="carousel"> | ||
<div class="carousel-item"> | ||
<div class="carousel-box"> | ||
<img src="images/pie1.png"/> | ||
<div class="carousel-text"> | ||
<h1 class="title fraunces-reg">Pepperoni</h1> | ||
<h2 class="num basic-semi orange">$12.50</h2> | ||
<button class="carousel-btn white fraunces-reg">Add to Cart</button> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="carousel-item"> | ||
<div class="carousel-box"> | ||
<img src="images/pie2.png"/> | ||
<div class="carousel-text"> | ||
<h1 class="title fraunces-reg">Tomato & Onions</h1> | ||
<h2 class="num basic-semi orange">$13.50</h2> | ||
<button class="carousel-btn white fraunces-reg">Add to Cart</button> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="carousel-item"> | ||
<div class="carousel-box"> | ||
<img src="images/pie3.png"/> | ||
<div class="carousel-text"> | ||
<h1 class="title fraunces-reg">Mushroom & Olives</h1> | ||
<h2 class="num basic-semi orange">$13.50</h2> | ||
<button class="carousel-btn white fraunces-reg">Add to Cart</button> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="carousel-item"> | ||
<div class="carousel-box"> | ||
<img src="images/pie1.png"/> | ||
<div class="carousel-text"> | ||
<h1 class="title fraunces-reg">Pepperoni</h1> | ||
<h2 class="num basic-semi orange">$12.50</h2> | ||
<button class="carousel-btn white fraunces-reg">Add to Cart</button> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="carousel-item"> | ||
<div class="carousel-box"> | ||
<img src="images/pie2.png"/> | ||
<div class="carousel-text"> | ||
<h1 class="title fraunces-reg">Tomato & Onions</h1> | ||
<h2 class="num basic-semi orange">$13.50</h2> | ||
<button class="carousel-btn white fraunces-reg">Add to Cart</button> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="carousel-item"> | ||
<div class="carousel-box"> | ||
<img src="images/pie3.png"/> | ||
<div class="carousel-text"> | ||
<h1 class="title fraunces-reg">Mushroom & Olives</h1> | ||
<h2 class="num basic-semi orange">$13.50</h2> | ||
<button class="carousel-btn white fraunces-reg">Add to Cart</button> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="carousel-item"> | ||
<div class="carousel-box"> | ||
<img src="images/pie1.png"/> | ||
<div class="carousel-text"> | ||
<h1 class="title fraunces-reg">Pepperoni</h1> | ||
<h2 class="num basic-semi orange">$12.50</h2> | ||
<button class="carousel-btn white fraunces-reg">Add to Cart</button> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="carousel-item"> | ||
<div class="carousel-box"> | ||
<img src="images/pie2.png"/> | ||
<div class="carousel-text"> | ||
<h1 class="title fraunces-reg">Tomato & Onions</h1> | ||
<h2 class="num basic-semi orange">$13.50</h2> | ||
<button class="carousel-btn white fraunces-reg">Add to Cart</button> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="carousel-item"> | ||
<div class="carousel-box"> | ||
<img src="images/pie3.png"/> | ||
<div class="carousel-text"> | ||
<h1 class="title fraunces-reg">Mushroom & Olives</h1> | ||
<h2 class="num basic-semi orange">$13.50</h2> | ||
<button class="carousel-btn white fraunces-reg">Add to Cart</button> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="carousel-item"> | ||
<div class="carousel-box"> | ||
<img src="images/pie1.png"/> | ||
<div class="carousel-text"> | ||
<h1 class="title fraunces-reg">Pepperoni</h1> | ||
<h2 class="num basic-semi orange">$12.50</h2> | ||
<button class="carousel-btn white fraunces-reg">Add to Cart</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</section> | ||
<script src="script.js"></script> | ||
</body> | ||
</html> |
This file contains 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 |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/*-------------------- | ||
Vars | ||
--------------------*/ | ||
let progress = 50; | ||
let startX = 0; | ||
let active = 0; | ||
let isDown = false; | ||
|
||
/*-------------------- | ||
Contants | ||
--------------------*/ | ||
const speedWheel = 0.02; | ||
const speedDrag = -0.1; | ||
|
||
/*-------------------- | ||
Get Z | ||
--------------------*/ | ||
const getZindex = (array, index) => (array.map((_, i) => (index === i) ? array.length : array.length - Math.abs(index - i))); | ||
|
||
/*-------------------- | ||
Items | ||
--------------------*/ | ||
const $items = document.querySelectorAll('.carousel-item'); | ||
const $cursors = document.querySelectorAll('.cursor'); | ||
|
||
const displayItems = (item, index, active) => { | ||
const zIndex = getZindex([...$items], active)[index]; | ||
item.style.setProperty('--zIndex', zIndex); | ||
item.style.setProperty('--active', (index - active) / $items.length); | ||
|
||
// Fade in/out carousel-text based on active item | ||
const carouselText = item.querySelector('.carousel-text'); | ||
if (index === active) { | ||
carouselText.style.opacity = '1'; | ||
} else { | ||
carouselText.style.opacity = '0'; | ||
} | ||
}; | ||
|
||
/*-------------------- | ||
Animate | ||
--------------------*/ | ||
const animate = () => { | ||
progress = Math.max(0, Math.min(progress, 100)); | ||
active = Math.floor(progress / 100 * ($items.length - 1)); | ||
|
||
$items.forEach((item, index) => displayItems(item, index, active)); | ||
}; | ||
animate(); | ||
|
||
/*-------------------- | ||
Click on Items | ||
--------------------*/ | ||
$items.forEach((item, i) => { | ||
item.addEventListener('click', () => { | ||
progress = (i / $items.length) * 100 + 10; | ||
animate(); | ||
}); | ||
}); | ||
|
||
/*-------------------- | ||
Handlers | ||
--------------------*/ | ||
const handleWheel = e => { | ||
const wheelProgress = e.deltaY * speedWheel; | ||
progress = progress + wheelProgress; | ||
animate(); | ||
}; | ||
|
||
const handleMouseMove = (e) => { | ||
if (e.type === 'mousemove') { | ||
$cursors.forEach(($cursor) => { | ||
$cursor.style.transform = `translate(${e.clientX}px, ${e.clientY}px)`; | ||
}); | ||
} | ||
if (!isDown) return; | ||
const x = e.clientX || (e.touches && e.touches[0].clientX) || 0; | ||
const mouseProgress = (x - startX) * speedDrag; | ||
progress = progress + mouseProgress; | ||
startX = x; | ||
animate(); | ||
}; | ||
|
||
const handleMouseDown = e => { | ||
isDown = true; | ||
startX = e.clientX || (e.touches && e.touches[0].clientX) || 0; | ||
}; | ||
|
||
const handleMouseUp = () => { | ||
isDown = false; | ||
}; | ||
|
||
/*-------------------- | ||
Listeners | ||
--------------------*/ | ||
document.addEventListener('mousewheel', handleWheel); | ||
document.addEventListener('mousedown', handleMouseDown); | ||
document.addEventListener('mousemove', handleMouseMove); | ||
document.addEventListener('mouseup', handleMouseUp); | ||
document.addEventListener('touchstart', handleMouseDown); | ||
document.addEventListener('touchmove', handleMouseMove); | ||
document.addEventListener('touchend', handleMouseUp); |
Oops, something went wrong.