Skip to content

Commit

Permalink
fix: fixed confetti shape
Browse files Browse the repository at this point in the history
  • Loading branch information
matteobruni committed Apr 4, 2021
1 parent 0c39078 commit a6fbc72
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
17 changes: 11 additions & 6 deletions shapes/confetti/src/shape.ts
Expand Up @@ -12,6 +12,7 @@ interface IConfettiData extends IShapeValues {
}

interface IConfettiParticle extends IParticle {
confettiType?: string;
wobble?: Vector;
wobbleInc?: number;
wobbleSpeed?: number;
Expand All @@ -32,12 +33,16 @@ export function loadConfettiShape(tsParticles: Main): void {
delta: IDelta,
pixelRatio: number
): void {
const shapeData = (particle.shapeData ?? {}) as IConfettiData;
if (!particle.confettiType) {
const shapeData = (particle.shapeData ?? {}) as IConfettiData;

if (shapeData.type === undefined) {
shapeData.type = Utils.itemFromArray(types);
} else if (shapeData.type instanceof Array) {
shapeData.type = Utils.itemFromArray(shapeData.type);
if (shapeData.type === undefined) {
shapeData.type = Utils.itemFromArray(types);
} else if (shapeData.type instanceof Array) {
shapeData.type = Utils.itemFromArray(shapeData.type);
}

particle.confettiType = shapeData.type;
}

if (particle.wobble === undefined) {
Expand Down Expand Up @@ -75,7 +80,7 @@ export function loadConfettiShape(tsParticles: Main): void {
x2 = particle.wobble.x + random * particle.tilt.x,
y2 = particle.wobble.y + random * particle.tilt.y;

if (shapeData.type === "circle") {
if (particle.confettiType === "circle") {
context.ellipse(
0,
0,
Expand Down
7 changes: 1 addition & 6 deletions website/configs/confetti.json
Expand Up @@ -15,12 +15,7 @@
]
},
"shape": {
"type": "confetti",
"options": {
"confetti": {
"type": "circle"
}
}
"type": "confetti"
},
"opacity": {
"value": 1,
Expand Down
6 changes: 5 additions & 1 deletion website/package.json
Expand Up @@ -27,6 +27,10 @@
"gh-pages": "^3.1.0",
"minify": "^6.0.1",
"rimraf": "^3.0.2",
"sass": "^1.32.5"
"sass": "^1.32.5",
"tsparticles": "^1.24.3",
"tsparticles-editor": "^1.24.4",
"tsparticles-preset-basic": "^1.9.3",
"tsparticles-shape-confetti": "^1.9.3"
}
}

0 comments on commit a6fbc72

Please sign in to comment.