Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
74 changes: 19 additions & 55 deletions bundles/confetti/src/ConfettiOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,93 +12,57 @@ import {
} from "@tsparticles/engine";
import type { IConfettiOptions } from "./IConfettiOptions.js";

/**
*
*/
/** Confetti options class */
export class ConfettiOptions implements IConfettiOptions, IOptionLoader<IConfettiOptions> {
/**
*
*/
/** Confetti angle */
angle: number;

/**
*
*/
/** Confetti colors */
colors: SingleOrMultiple<string>;

/**
*
*/
/** Number of confetti particles to emit */
count: number;

/**
*
*/
/** Confetti decay rate */
decay: number;

/**
*
*/
/** Disables confetti for users who prefer reduced motion */
disableForReducedMotion: boolean;

/**
*
*/
/** Confetti drift offset */
drift: number;

/**
*
*/
/** Enables flat confetti */
flat: boolean;

/**
*
*/
/** Confetti gravity */
gravity: number;

/**
*
*/
/** Confetti position, in percent values */
position: ICoordinates;

/**
*
*/
/** Confetti size scalar */
scalar: number;

/**
*
*/
/** Per-shape options */
shapeOptions: ShapeData;

/**
*
*/
/** Confetti shape types */
shapes: SingleOrMultiple<string>;

/**
*
*/
/** Confetti spread angle */
spread: number;

/**
*
*/
/** Confetti initial velocity */
startVelocity: number;

/**
*
*/
/** Confetti animation ticks */
ticks: number;

/**
*
*/
/** Confetti z-index */
zIndex: number;

/**
*
*/
/** Creates a new ConfettiOptions instance with default values */
constructor() {
this.angle = 90;
this.count = 50;
Expand Down Expand Up @@ -156,7 +120,7 @@ export class ConfettiOptions implements IConfettiOptions, IOptionLoader<IConfett
}

/**
*
* Loads confetti options from the provided data
* @param data -
*/
load(data?: RecursivePartial<IConfettiOptions>): void {
Expand Down
16 changes: 4 additions & 12 deletions bundles/confetti/src/ConfettiParams.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
import type { IConfettiOptions } from "./IConfettiOptions.js";
import type { RecursivePartial } from "@tsparticles/engine";

/**
* The {@link confetti} parameter object definition
*/
/** The confetti parameter object definition */
export interface ConfettiParams {
/**
*
*/
/** The canvas element to use for the confetti animation */
canvas?: HTMLCanvasElement;

/**
*
*/
/** The unique identifier for the confetti canvas */
id: string;

/**
*
*/
/** The confetti options object */
options: RecursivePartial<IConfettiOptions>;
}
68 changes: 17 additions & 51 deletions bundles/confetti/src/IConfettiOptions.ts
Original file line number Diff line number Diff line change
@@ -1,47 +1,29 @@
import type { ICoordinates, SingleOrMultiple } from "@tsparticles/engine";

/**
*
*/
/** Confetti options interface */
export interface IConfettiOptions {
/**
*
*/
/** Confetti emission angle */
angle: number;

/**
*
*/
/** Confetti colors */
colors: SingleOrMultiple<string>;

/**
*
*/
/** Number of confetti particles */
count: number;

/**
*
*/
/** Confetti decay rate */
decay: number;

/**
*
*/
/** Disables confetti for users who prefer reduced motion */
disableForReducedMotion: boolean;

/**
*
*/
/** Confetti drift */
drift: number;

/**
*
*/
/** Enables flat confetti */
flat: boolean;

/**
*
*/
/** Confetti gravity */
gravity: number;

/**
Expand All @@ -54,43 +36,27 @@ export interface IConfettiOptions {
*/
particleCount: number;

/**
*
*/
/** Confetti position in percent */
position: ICoordinates;

/**
*
*/
/** Confetti size scalar */
scalar: number;

/**
*
*/
/** Per-shape options */
shapeOptions: Record<string, SingleOrMultiple<unknown>>;

/**
*
*/
/** Confetti shape types */
shapes: SingleOrMultiple<string>;

/**
*
*/
/** Confetti spread */
spread: number;

/**
*
*/
/** Confetti initial velocity */
startVelocity: number;

/**
*
*/
/** Number of animation ticks */
ticks: number;

/**
*
*/
/** Confetti z-index */
zIndex: number;
}
24 changes: 8 additions & 16 deletions bundles/confetti/src/confetti.lazy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,24 @@ import { setConfetti } from "./utils.js";
declare const __VERSION__: string;

declare global {
/**
*
*/
/** The global confetti function */
var confetti: ConfettiFunc & {
/**
*
* @param canvas -
* @param options -
* @returns the confetti function
*/
/** Creates a confetti animation bound to a specific canvas */
create: (canvas?: HTMLCanvasElement | null, options?: RecursivePartial<IConfettiOptions>) => Promise<ConfettiFunc>;

/** Initializes the confetti plugins */
init: () => Promise<void>;

/**
* the confetti version number
*/
/** The confetti bundle version */
version: string;
};
}

let initPromise: Promise<void> | null = null;

/**
* @param engine -
* Initializes all required plugins for the confetti bundle
* @param engine - The engine to register plugins with
* @returns the init plugins promise
* @internal
*/
Expand Down Expand Up @@ -186,13 +179,12 @@ confetti.create = async (
};
};

/** Initializes the confetti plugins without creating an animation */
confetti.init = async (): Promise<void> => {
await initPlugins(tsParticles);
};

/**
*
*/
/** The confetti bundle version */
confetti.version = __VERSION__;

globalThis.confetti = confetti;
24 changes: 8 additions & 16 deletions bundles/confetti/src/confetti.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,24 @@ import { setConfetti } from "./utils.js";
declare const __VERSION__: string;

declare global {
/**
*
*/
/** The global confetti function */
var confetti: ConfettiFunc & {
/**
*
* @param canvas -
* @param options -
* @returns the confetti function
*/
/** Creates a confetti animation bound to a specific canvas */
create: (canvas?: HTMLCanvasElement | null, options?: RecursivePartial<IConfettiOptions>) => Promise<ConfettiFunc>;

/** Initializes the confetti plugins */
init: () => Promise<void>;

/**
* the confetti version number
*/
/** The confetti bundle version */
version: string;
};
}

let initPromise: Promise<void> | null = null;

/**
* @param engine -
* Initializes all required plugins for the confetti bundle
* @param engine - The engine to register plugins with
* @returns the init plugins promise
* @internal
*/
Expand Down Expand Up @@ -161,13 +154,12 @@ confetti.create = async (
};
};

/** Initializes the confetti plugins without creating an animation */
confetti.init = async (): Promise<void> => {
await initPlugins(tsParticles);
};

/**
*
*/
/** The confetti bundle version */
confetti.version = __VERSION__;

globalThis.confetti = confetti;
4 changes: 1 addition & 3 deletions bundles/confetti/src/index.lazy.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import type { IConfettiOptions } from "./IConfettiOptions.js";
import type { RecursivePartial } from "@tsparticles/engine/lazy";

/**
*
*/
/** Confetti options type */
export type ConfettiOptions = RecursivePartial<IConfettiOptions>;

export * from "./confetti.lazy.js";
Expand Down
4 changes: 1 addition & 3 deletions bundles/confetti/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import type { IConfettiOptions } from "./IConfettiOptions.js";
import type { RecursivePartial } from "@tsparticles/engine";

/**
*
*/
/** Confetti options type */
export type ConfettiOptions = RecursivePartial<IConfettiOptions>;

export * from "./confetti.js";
Expand Down
Loading
Loading