Fireworks na oknie wygranej i zamykanie modala
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { ref } from 'vue';
|
||||
import { usePuzzleStore } from '@/stores/puzzle';
|
||||
import confetti from 'canvas-confetti';
|
||||
|
||||
export function useNonogram() {
|
||||
const store = usePuzzleStore();
|
||||
@@ -49,7 +48,6 @@ export function useNonogram() {
|
||||
const stopDrag = () => {
|
||||
isDragging.value = false;
|
||||
dragMode.value = null;
|
||||
checkWinEffect();
|
||||
};
|
||||
|
||||
const applyDrag = (r, c) => {
|
||||
@@ -86,38 +84,6 @@ export function useNonogram() {
|
||||
store.setCell(r, c, dragMode.value);
|
||||
};
|
||||
|
||||
const checkWinEffect = () => {
|
||||
if (store.isGameWon) {
|
||||
triggerConfetti();
|
||||
}
|
||||
};
|
||||
|
||||
const triggerConfetti = () => {
|
||||
const duration = 3000;
|
||||
const end = Date.now() + duration;
|
||||
|
||||
(function frame() {
|
||||
confetti({
|
||||
particleCount: 5,
|
||||
angle: 60,
|
||||
spread: 55,
|
||||
origin: { x: 0 },
|
||||
colors: ['#00f2ff', '#ff0055', '#ffffff']
|
||||
});
|
||||
confetti({
|
||||
particleCount: 5,
|
||||
angle: 120,
|
||||
spread: 55,
|
||||
origin: { x: 1 },
|
||||
colors: ['#00f2ff', '#ff0055', '#ffffff']
|
||||
});
|
||||
|
||||
if (Date.now() < end) {
|
||||
requestAnimationFrame(frame);
|
||||
}
|
||||
}());
|
||||
};
|
||||
|
||||
return {
|
||||
startDrag,
|
||||
onMouseEnter,
|
||||
|
||||
Reference in New Issue
Block a user