Fireworks na oknie wygranej i zamykanie modala

This commit is contained in:
2026-02-08 15:36:06 +01:00
parent bd24ca16bc
commit eb206ddd01
5 changed files with 74 additions and 50 deletions

View File

@@ -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,