Skip to content
party.js logoparty.js logo

ReferenceCustom effectsFunction

createEffect()

Creates and starts a custom effect.

function createEffect(options: CreateEffectOptions): Effect;

Creates and starts a custom effect, using the provided options.

The built-in effects like confetti() are made using this function. You can use it directly if your needs are not covered by them.

optionsCreateEffectOptions

Everything that defines the effect.

Effect

A handle to pause, resume or stop the effect early.

createEffect({
origin: { x: 200, y: 300 },
schedule: { bursts: [{ count: 30 }] },
particleInit: {
position: emitFrom({ type: "disk", radius: 20 }),
velocity: cone(90, 30, range(200, 400)),
orientation: randomOrientation(),
angularVelocity: randomSpin(90, 270),
size: range(8, 14),
color: pick(["#ff5a5f", "#ffb400", "#00a699"]),
shape: { type: "circle" },
lifetime: range(2, 3),
},
behaviors: [gravity(800), fade(0, 0.5)],
});