-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #186 from SimonStnn/dev
1.9.0 update
- Loading branch information
Showing
30 changed files
with
232 additions
and
65 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.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,17 @@ | ||
@keyframes bang { | ||
from { | ||
transform: translate3d(0, 0, 0); | ||
opacity: 1; | ||
} | ||
} | ||
|
||
i.particle { | ||
animation: bang 750ms ease-out forwards; | ||
position: absolute; | ||
display: block; | ||
left: 50%; | ||
top: 0; | ||
width: 3px; | ||
height: 8px; | ||
opacity: 0; | ||
} |
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.
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
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,83 @@ | ||
import Balloon, { balloonResourceLocation } from '@/balloon'; | ||
import { random } from '@/utils'; | ||
import '@/../resources/balloons/confetti/confetti.css'; | ||
|
||
export default class Confetti extends Balloon { | ||
public readonly name = 'confetti'; | ||
public static readonly spawn_chance = 0.1; | ||
|
||
private readonly mask = document.createElement('img'); | ||
|
||
constructor() { | ||
super(); | ||
|
||
this.element.appendChild(this.mask); | ||
this.mask.src = balloonResourceLocation + this.name + '/mask.png'; | ||
this.mask.style.position = 'absolute'; | ||
this.mask.style.top = '-10px'; | ||
this.mask.style.left = '0'; | ||
// Give it a random rotation | ||
this.mask.style.transform = `rotate(${Math.random() * 360}deg)`; | ||
} | ||
|
||
public pop(event?: MouseEvent) { | ||
// Get the click position | ||
const x = event?.clientX || window.innerWidth / 2; | ||
const y = event?.clientY || window.innerHeight / 2; | ||
// Add an element to that position | ||
const confetti = document.createElement('div'); | ||
confetti.style.position = 'absolute'; | ||
confetti.style.top = `${y}px`; | ||
confetti.style.left = `${x}px`; | ||
confetti.style.zIndex = '1000'; | ||
confetti.style.pointerEvents = 'none'; | ||
document.body.appendChild(confetti); | ||
// Throw confetti | ||
throwConfetti(confetti, 100); | ||
// Remove the confetti after 2 seconds | ||
setTimeout(() => { | ||
confetti.remove(); | ||
}, 2000); | ||
} | ||
} | ||
|
||
function throwConfetti(element: HTMLElement, amount: number = 100) { | ||
const df = document.createDocumentFragment(); | ||
const offset = 10; | ||
const particles: HTMLElement[] = []; | ||
for (let i = 0; i < amount; i++) { | ||
const c = document.createElement('i'); | ||
c.className = 'particle'; | ||
const angle = random(360); | ||
const radius = random(250); | ||
let x = radius * Math.cos(angle); | ||
let y = radius * Math.sin(angle); | ||
c.style.cssText = ` | ||
transform: translate3d(${x}px, ${y}px, 0) | ||
rotate(${angle}deg); | ||
background: hsla(${random(360)},100%,50%,1); | ||
`; | ||
df.appendChild(c); | ||
particles.push(c); | ||
} | ||
element.appendChild(df); | ||
|
||
function checkBounds() { | ||
particles.forEach((particle, index) => { | ||
const rect = particle.getBoundingClientRect(); | ||
if ( | ||
rect.bottom < +offset || | ||
rect.top > window.innerHeight - offset || | ||
rect.left > window.innerWidth - offset || | ||
rect.right < +offset | ||
) { | ||
particle.remove(); | ||
particles.splice(index, 1); | ||
} | ||
}); | ||
if (particles.length > 0) { | ||
requestAnimationFrame(checkBounds); | ||
} | ||
} | ||
requestAnimationFrame(checkBounds); | ||
} |
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 |
---|---|---|
@@ -1,11 +1,6 @@ | ||
import Balloon from '@/balloon'; | ||
import { generateRandomNumber } from '@/utils'; | ||
import Balloon, { defaultBalloonFolderName } from '@/balloon'; | ||
|
||
export default class Default extends Balloon { | ||
public readonly name = 'default'; | ||
public static readonly spawn_chance = 0.95; | ||
|
||
getRandomDuration() { | ||
return generateRandomNumber(10000, 15000); | ||
} | ||
public readonly name = defaultBalloonFolderName; | ||
public static readonly spawn_chance = 0.9; | ||
} |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export { default as Default } from './default'; | ||
export { default as Confetti } from './confetti'; |
Oops, something went wrong.