-
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
Showing
6 changed files
with
147 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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import confetti from "canvas-confetti"; | ||
|
||
// ------------ Confetti sources ------------- | ||
// confetti package https://github.com/catdad/canvas-confetti | ||
// positioning to element https://codepen.io/catdad/pen/VwjRLoM | ||
|
||
const randomInRange = (min, max) => Math.random() * (max - min) + min; | ||
|
||
const fireConfetti = (x, y) => { | ||
confetti({ | ||
angle: randomInRange(55, 125), | ||
spread: randomInRange(50, 70), | ||
particleCount: randomInRange(50, 100), | ||
origin: { | ||
x: x, | ||
y: y, | ||
}, | ||
}); | ||
}; | ||
|
||
const fireConfettiFrom = (element) => { | ||
let width = window.innerWidth; | ||
let height = window.innerHeight; | ||
|
||
window.addEventListener("resize", () => { | ||
width = window.innerWidth; | ||
height = window.innerHeight; | ||
}); | ||
const rect = element.getBoundingClientRect(); | ||
|
||
const originX = (rect.x + 0.5 * rect.width) / width; | ||
const originY = (rect.y + 0.5 * rect.height) / height; | ||
|
||
fireConfetti(originX, originY); | ||
|
||
// fire(0.25, { | ||
// spread: 26, | ||
// startVelocity: 55, | ||
// }); | ||
// fire(0.2, { | ||
// spread: 60, | ||
// }); | ||
// fire(0.35, { | ||
// spread: 100, | ||
// decay: 0.91, | ||
// scalar: 0.8, | ||
// }); | ||
// fire(0.1, { | ||
// spread: 120, | ||
// startVelocity: 25, | ||
// decay: 0.92, | ||
// scalar: 1.2, | ||
// }); | ||
// fire(0.1, { | ||
// spread: 120, | ||
// startVelocity: 45, | ||
// }); | ||
|
||
// const count = 200; | ||
// const defaults = { | ||
// origin: { y: -10 }, | ||
// }; | ||
|
||
// const fire = (particleRatio, opts) => { | ||
// confetti( | ||
// Object.assign({}, defaults, opts, { | ||
// particleCount: Math.floor(count * particleRatio), | ||
// }) | ||
// ); | ||
// }; | ||
}; | ||
|
||
export default fireConfettiFrom; |
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
6c358f8
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.
Successfully deployed to the following URLs:
portfolio – ./
portfolio-paalss.vercel.app
paalss.vercel.app
portfolio-git-master-paalss.vercel.app