-
Notifications
You must be signed in to change notification settings - Fork 429
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
1 parent
50127e2
commit c8e86e9
Showing
8 changed files
with
186 additions
and
58 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
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
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
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 |
---|---|---|
|
@@ -45,6 +45,4 @@ document.addEventListener('DOMContentLoaded', () => { | |
starButton.classList.remove('greyed'); | ||
}); | ||
} | ||
}); | ||
|
||
|
||
}); |
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,24 @@ | ||
/* #icons-container { | ||
display: none; | ||
} */ | ||
.food-icon { | ||
width: 50px; | ||
height: 50px; | ||
position: absolute; | ||
pointer-events: none; /* Ensure the icon does not block mouse events */ | ||
transform: translate(-0%, -0%) scale(1); | ||
transition: transform 1.2s, opacity 1s; | ||
opacity: 1; | ||
z-index: 1000; | ||
} | ||
.food-icon.active { | ||
transform: translate(-50%, 120%) scale(0); | ||
opacity: 0; | ||
} | ||
#food-icon { | ||
width: 50px; | ||
height: 50px; | ||
position: absolute; | ||
pointer-events: none; /* Ensure the icon does not block mouse events */ | ||
display: none; /* Hide initially */ | ||
} |
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,53 @@ | ||
document.addEventListener('DOMContentLoaded', () => { | ||
const foodIcon = document.getElementById('food-icon'); | ||
|
||
document.addEventListener('mousemove', (e) => { | ||
foodIcon.style.left = `${e.pageX - 20}px`; | ||
foodIcon.style.top = `${e.pageY - 13}px`; | ||
foodIcon.style.display = 'block'; // Show the icon when the mouse moves | ||
}); | ||
|
||
document.addEventListener('mouseout', () => { | ||
foodIcon.style.display = 'none'; // Hide the icon when the mouse leaves the document | ||
}); | ||
}); | ||
document.addEventListener('DOMContentLoaded', () => { | ||
const foodIcons = Array.from(document.getElementsByClassName('food-icon')); | ||
let isAnimating = false; | ||
|
||
document.addEventListener('mousemove', (e) => { | ||
if (isAnimating) return; | ||
|
||
const randomIndex = Math.floor(Math.random() * foodIcons.length); | ||
const selectedIcon = foodIcons[randomIndex].cloneNode(true); | ||
document.body.appendChild(selectedIcon); | ||
|
||
let x = e.clientX; | ||
let y = e.clientY; | ||
let scrollLeft = window.pageXOffset; | ||
let scrollTop = window.pageYOffset; | ||
let relativeX = x + scrollLeft; | ||
let relativeY = y + scrollTop; | ||
|
||
selectedIcon.style.left = `${relativeX}px`; | ||
selectedIcon.style.top = `${relativeY}px`; | ||
|
||
// Trigger the animation by adding the class after a short delay | ||
setTimeout(() => { | ||
selectedIcon.classList.add('active'); | ||
}, 10); | ||
|
||
isAnimating = true; | ||
|
||
// Allow new animation after 0.5 seconds | ||
setTimeout(() => { | ||
isAnimating = false; | ||
}, 80); | ||
|
||
// Remove the icon element after the animation ends | ||
selectedIcon.addEventListener('transitionend', () => { | ||
selectedIcon.remove(); | ||
}); | ||
}); | ||
}); | ||
|
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