@tsparticles/updater-out-modes
Advanced tools
Comparing version 3.1.0 to 3.2.0
import { calculateBounds, } from "@tsparticles/engine"; | ||
import { bounceHorizontal, bounceVertical } from "./Utils.js"; | ||
export class BounceOutMode { | ||
@@ -8,10 +7,6 @@ constructor(container) { | ||
"bounce", | ||
"bounce-vertical", | ||
"bounce-horizontal", | ||
"bounceVertical", | ||
"bounceHorizontal", | ||
"split", | ||
]; | ||
} | ||
update(particle, direction, delta, outMode) { | ||
async update(particle, direction, delta, outMode) { | ||
if (!this.modes.includes(outMode)) { | ||
@@ -24,3 +19,3 @@ return; | ||
if (plugin.particleBounce !== undefined) { | ||
handled = plugin.particleBounce(particle, delta, direction); | ||
handled = await plugin.particleBounce(particle, delta, direction); | ||
} | ||
@@ -34,3 +29,3 @@ if (handled) { | ||
} | ||
const pos = particle.getPosition(), offset = particle.offset, size = particle.getRadius(), bounds = calculateBounds(pos, size), canvasSize = container.canvas.size; | ||
const pos = particle.getPosition(), offset = particle.offset, size = particle.getRadius(), bounds = calculateBounds(pos, size), canvasSize = container.canvas.size, { bounceHorizontal, bounceVertical } = await import("./Utils.js"); | ||
bounceHorizontal({ particle, outMode, direction, bounds, canvasSize, offset, size }); | ||
@@ -37,0 +32,0 @@ bounceVertical({ particle, outMode, direction, bounds, canvasSize, offset, size }); |
@@ -8,3 +8,3 @@ import { Vector, getDistances, isPointInside, } from "@tsparticles/engine"; | ||
} | ||
update(particle, direction, _delta, outMode) { | ||
async update(particle, direction, _delta, outMode) { | ||
if (!this.modes.includes(outMode)) { | ||
@@ -22,4 +22,3 @@ return; | ||
case "inside": { | ||
const { dx, dy } = getDistances(particle.position, particle.moveCenter); | ||
const { x: vx, y: vy } = particle.velocity; | ||
const { dx, dy } = getDistances(particle.position, particle.moveCenter), { x: vx, y: vy } = particle.velocity; | ||
if ((vx < minVelocity && dx > particle.moveCenter.radius) || | ||
@@ -35,3 +34,4 @@ (vy < minVelocity && dy > particle.moveCenter.radius) || | ||
container.particles.remove(particle, undefined, true); | ||
await Promise.resolve(); | ||
} | ||
} |
@@ -1,4 +0,6 @@ | ||
import { OutOfCanvasUpdater } from "./OutOfCanvasUpdater.js"; | ||
export async function loadOutModesUpdater(engine, refresh = true) { | ||
await engine.addParticleUpdater("outModes", (container) => new OutOfCanvasUpdater(container), refresh); | ||
await engine.addParticleUpdater("outModes", async (container) => { | ||
const { OutOfCanvasUpdater } = await import("./OutOfCanvasUpdater.js"); | ||
return new OutOfCanvasUpdater(container); | ||
}, refresh); | ||
} |
@@ -8,3 +8,3 @@ import { Vector, isPointInside, } from "@tsparticles/engine"; | ||
} | ||
update(particle, direction, delta, outMode) { | ||
async update(particle, direction, delta, outMode) { | ||
if (!this.modes.includes(outMode)) { | ||
@@ -19,5 +19,3 @@ return; | ||
} | ||
const gravityOptions = particle.options.move.gravity, container = this.container; | ||
const canvasSize = container.canvas.size; | ||
const pRadius = particle.getRadius(); | ||
const gravityOptions = particle.options.move.gravity, container = this.container, canvasSize = container.canvas.size, pRadius = particle.getRadius(); | ||
if (!gravityOptions.enable) { | ||
@@ -43,3 +41,4 @@ if ((particle.velocity.y > minVelocity && particle.position.y <= canvasSize.height + pRadius) || | ||
} | ||
await Promise.resolve(); | ||
} | ||
} |
@@ -1,21 +0,37 @@ | ||
import { BounceOutMode } from "./BounceOutMode.js"; | ||
import { DestroyOutMode } from "./DestroyOutMode.js"; | ||
import { NoneOutMode } from "./NoneOutMode.js"; | ||
import { OutOutMode } from "./OutOutMode.js"; | ||
const checkOutMode = (outModes, outMode) => { | ||
return (outModes.default === outMode || | ||
outModes.bottom === outMode || | ||
outModes.left === outMode || | ||
outModes.right === outMode || | ||
outModes.top === outMode); | ||
}; | ||
export class OutOfCanvasUpdater { | ||
constructor(container) { | ||
this._updateOutMode = (particle, delta, outMode, direction) => { | ||
this._updateOutMode = async (particle, delta, outMode, direction) => { | ||
for (const updater of this.updaters) { | ||
updater.update(particle, direction, delta, outMode); | ||
await updater.update(particle, direction, delta, outMode); | ||
} | ||
}; | ||
this.container = container; | ||
this.updaters = [ | ||
new BounceOutMode(container), | ||
new DestroyOutMode(container), | ||
new OutOutMode(container), | ||
new NoneOutMode(container), | ||
]; | ||
this.updaters = []; | ||
} | ||
init() { | ||
async init(particle) { | ||
this.updaters = []; | ||
const outModes = particle.options.move.outModes; | ||
if (checkOutMode(outModes, "bounce")) { | ||
const { BounceOutMode } = await import("./BounceOutMode.js"); | ||
this.updaters.push(new BounceOutMode(this.container)); | ||
} | ||
else if (checkOutMode(outModes, "out")) { | ||
const { OutOutMode } = await import("./OutOutMode.js"); | ||
this.updaters.push(new OutOutMode(this.container)); | ||
} | ||
else if (checkOutMode(outModes, "destroy")) { | ||
const { DestroyOutMode } = await import("./DestroyOutMode.js"); | ||
this.updaters.push(new DestroyOutMode(this.container)); | ||
} | ||
else if (checkOutMode(outModes, "none")) { | ||
const { NoneOutMode } = await import("./NoneOutMode.js"); | ||
this.updaters.push(new NoneOutMode(this.container)); | ||
} | ||
} | ||
@@ -25,9 +41,9 @@ isEnabled(particle) { | ||
} | ||
update(particle, delta) { | ||
async update(particle, delta) { | ||
const outModes = particle.options.move.outModes; | ||
this._updateOutMode(particle, delta, outModes.bottom ?? outModes.default, "bottom"); | ||
this._updateOutMode(particle, delta, outModes.left ?? outModes.default, "left"); | ||
this._updateOutMode(particle, delta, outModes.right ?? outModes.default, "right"); | ||
this._updateOutMode(particle, delta, outModes.top ?? outModes.default, "top"); | ||
await this._updateOutMode(particle, delta, outModes.bottom ?? outModes.default, "bottom"); | ||
await this._updateOutMode(particle, delta, outModes.left ?? outModes.default, "left"); | ||
await this._updateOutMode(particle, delta, outModes.right ?? outModes.default, "right"); | ||
await this._updateOutMode(particle, delta, outModes.top ?? outModes.default, "top"); | ||
} | ||
} |
@@ -8,3 +8,3 @@ import { Vector, calculateBounds, getDistances, getRandom, isPointInside, randomInRange, } from "@tsparticles/engine"; | ||
} | ||
update(particle, direction, delta, outMode) { | ||
async update(particle, direction, delta, outMode) { | ||
if (!this.modes.includes(outMode)) { | ||
@@ -111,3 +111,4 @@ return; | ||
} | ||
await Promise.resolve(); | ||
} | ||
} |
import { getRangeValue } from "@tsparticles/engine"; | ||
const minVelocity = 0, boundsMin = 0; | ||
export function bounceHorizontal(data) { | ||
if ((data.outMode !== "bounce" && | ||
data.outMode !== "bounce-horizontal" && | ||
data.outMode !== "bounceHorizontal" && | ||
data.outMode !== "split") || | ||
if ((data.outMode !== "bounce" && data.outMode !== "split") || | ||
(data.direction !== "left" && data.direction !== "right")) { | ||
@@ -42,6 +39,3 @@ return; | ||
export function bounceVertical(data) { | ||
if ((data.outMode !== "bounce" && | ||
data.outMode !== "bounce-vertical" && | ||
data.outMode !== "bounceVertical" && | ||
data.outMode !== "split") || | ||
if ((data.outMode !== "bounce" && data.outMode !== "split") || | ||
(data.direction !== "bottom" && data.direction !== "top")) { | ||
@@ -48,0 +42,0 @@ return; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BounceOutMode = void 0; | ||
const engine_1 = require("@tsparticles/engine"); | ||
const Utils_js_1 = require("./Utils.js"); | ||
class BounceOutMode { | ||
@@ -11,10 +33,6 @@ constructor(container) { | ||
"bounce", | ||
"bounce-vertical", | ||
"bounce-horizontal", | ||
"bounceVertical", | ||
"bounceHorizontal", | ||
"split", | ||
]; | ||
} | ||
update(particle, direction, delta, outMode) { | ||
async update(particle, direction, delta, outMode) { | ||
if (!this.modes.includes(outMode)) { | ||
@@ -27,3 +45,3 @@ return; | ||
if (plugin.particleBounce !== undefined) { | ||
handled = plugin.particleBounce(particle, delta, direction); | ||
handled = await plugin.particleBounce(particle, delta, direction); | ||
} | ||
@@ -37,7 +55,7 @@ if (handled) { | ||
} | ||
const pos = particle.getPosition(), offset = particle.offset, size = particle.getRadius(), bounds = (0, engine_1.calculateBounds)(pos, size), canvasSize = container.canvas.size; | ||
(0, Utils_js_1.bounceHorizontal)({ particle, outMode, direction, bounds, canvasSize, offset, size }); | ||
(0, Utils_js_1.bounceVertical)({ particle, outMode, direction, bounds, canvasSize, offset, size }); | ||
const pos = particle.getPosition(), offset = particle.offset, size = particle.getRadius(), bounds = (0, engine_1.calculateBounds)(pos, size), canvasSize = container.canvas.size, { bounceHorizontal, bounceVertical } = await Promise.resolve().then(() => __importStar(require("./Utils.js"))); | ||
bounceHorizontal({ particle, outMode, direction, bounds, canvasSize, offset, size }); | ||
bounceVertical({ particle, outMode, direction, bounds, canvasSize, offset, size }); | ||
} | ||
} | ||
exports.BounceOutMode = BounceOutMode; |
@@ -11,3 +11,3 @@ "use strict"; | ||
} | ||
update(particle, direction, _delta, outMode) { | ||
async update(particle, direction, _delta, outMode) { | ||
if (!this.modes.includes(outMode)) { | ||
@@ -25,4 +25,3 @@ return; | ||
case "inside": { | ||
const { dx, dy } = (0, engine_1.getDistances)(particle.position, particle.moveCenter); | ||
const { x: vx, y: vy } = particle.velocity; | ||
const { dx, dy } = (0, engine_1.getDistances)(particle.position, particle.moveCenter), { x: vx, y: vy } = particle.velocity; | ||
if ((vx < minVelocity && dx > particle.moveCenter.radius) || | ||
@@ -38,4 +37,5 @@ (vy < minVelocity && dy > particle.moveCenter.radius) || | ||
container.particles.remove(particle, undefined, true); | ||
await Promise.resolve(); | ||
} | ||
} | ||
exports.DestroyOutMode = DestroyOutMode; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.loadOutModesUpdater = void 0; | ||
const OutOfCanvasUpdater_js_1 = require("./OutOfCanvasUpdater.js"); | ||
async function loadOutModesUpdater(engine, refresh = true) { | ||
await engine.addParticleUpdater("outModes", (container) => new OutOfCanvasUpdater_js_1.OutOfCanvasUpdater(container), refresh); | ||
await engine.addParticleUpdater("outModes", async (container) => { | ||
const { OutOfCanvasUpdater } = await Promise.resolve().then(() => __importStar(require("./OutOfCanvasUpdater.js"))); | ||
return new OutOfCanvasUpdater(container); | ||
}, refresh); | ||
} | ||
exports.loadOutModesUpdater = loadOutModesUpdater; |
@@ -11,3 +11,3 @@ "use strict"; | ||
} | ||
update(particle, direction, delta, outMode) { | ||
async update(particle, direction, delta, outMode) { | ||
if (!this.modes.includes(outMode)) { | ||
@@ -22,5 +22,3 @@ return; | ||
} | ||
const gravityOptions = particle.options.move.gravity, container = this.container; | ||
const canvasSize = container.canvas.size; | ||
const pRadius = particle.getRadius(); | ||
const gravityOptions = particle.options.move.gravity, container = this.container, canvasSize = container.canvas.size, pRadius = particle.getRadius(); | ||
if (!gravityOptions.enable) { | ||
@@ -46,4 +44,5 @@ if ((particle.velocity.y > minVelocity && particle.position.y <= canvasSize.height + pRadius) || | ||
} | ||
await Promise.resolve(); | ||
} | ||
} | ||
exports.NoneOutMode = NoneOutMode; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.OutOfCanvasUpdater = void 0; | ||
const BounceOutMode_js_1 = require("./BounceOutMode.js"); | ||
const DestroyOutMode_js_1 = require("./DestroyOutMode.js"); | ||
const NoneOutMode_js_1 = require("./NoneOutMode.js"); | ||
const OutOutMode_js_1 = require("./OutOutMode.js"); | ||
const checkOutMode = (outModes, outMode) => { | ||
return (outModes.default === outMode || | ||
outModes.bottom === outMode || | ||
outModes.left === outMode || | ||
outModes.right === outMode || | ||
outModes.top === outMode); | ||
}; | ||
class OutOfCanvasUpdater { | ||
constructor(container) { | ||
this._updateOutMode = (particle, delta, outMode, direction) => { | ||
this._updateOutMode = async (particle, delta, outMode, direction) => { | ||
for (const updater of this.updaters) { | ||
updater.update(particle, direction, delta, outMode); | ||
await updater.update(particle, direction, delta, outMode); | ||
} | ||
}; | ||
this.container = container; | ||
this.updaters = [ | ||
new BounceOutMode_js_1.BounceOutMode(container), | ||
new DestroyOutMode_js_1.DestroyOutMode(container), | ||
new OutOutMode_js_1.OutOutMode(container), | ||
new NoneOutMode_js_1.NoneOutMode(container), | ||
]; | ||
this.updaters = []; | ||
} | ||
init() { | ||
async init(particle) { | ||
this.updaters = []; | ||
const outModes = particle.options.move.outModes; | ||
if (checkOutMode(outModes, "bounce")) { | ||
const { BounceOutMode } = await Promise.resolve().then(() => __importStar(require("./BounceOutMode.js"))); | ||
this.updaters.push(new BounceOutMode(this.container)); | ||
} | ||
else if (checkOutMode(outModes, "out")) { | ||
const { OutOutMode } = await Promise.resolve().then(() => __importStar(require("./OutOutMode.js"))); | ||
this.updaters.push(new OutOutMode(this.container)); | ||
} | ||
else if (checkOutMode(outModes, "destroy")) { | ||
const { DestroyOutMode } = await Promise.resolve().then(() => __importStar(require("./DestroyOutMode.js"))); | ||
this.updaters.push(new DestroyOutMode(this.container)); | ||
} | ||
else if (checkOutMode(outModes, "none")) { | ||
const { NoneOutMode } = await Promise.resolve().then(() => __importStar(require("./NoneOutMode.js"))); | ||
this.updaters.push(new NoneOutMode(this.container)); | ||
} | ||
} | ||
@@ -28,10 +67,10 @@ isEnabled(particle) { | ||
} | ||
update(particle, delta) { | ||
async update(particle, delta) { | ||
const outModes = particle.options.move.outModes; | ||
this._updateOutMode(particle, delta, outModes.bottom ?? outModes.default, "bottom"); | ||
this._updateOutMode(particle, delta, outModes.left ?? outModes.default, "left"); | ||
this._updateOutMode(particle, delta, outModes.right ?? outModes.default, "right"); | ||
this._updateOutMode(particle, delta, outModes.top ?? outModes.default, "top"); | ||
await this._updateOutMode(particle, delta, outModes.bottom ?? outModes.default, "bottom"); | ||
await this._updateOutMode(particle, delta, outModes.left ?? outModes.default, "left"); | ||
await this._updateOutMode(particle, delta, outModes.right ?? outModes.default, "right"); | ||
await this._updateOutMode(particle, delta, outModes.top ?? outModes.default, "top"); | ||
} | ||
} | ||
exports.OutOfCanvasUpdater = OutOfCanvasUpdater; |
@@ -11,3 +11,3 @@ "use strict"; | ||
} | ||
update(particle, direction, delta, outMode) { | ||
async update(particle, direction, delta, outMode) { | ||
if (!this.modes.includes(outMode)) { | ||
@@ -114,4 +114,5 @@ return; | ||
} | ||
await Promise.resolve(); | ||
} | ||
} | ||
exports.OutOutMode = OutOutMode; |
@@ -7,6 +7,3 @@ "use strict"; | ||
function bounceHorizontal(data) { | ||
if ((data.outMode !== "bounce" && | ||
data.outMode !== "bounce-horizontal" && | ||
data.outMode !== "bounceHorizontal" && | ||
data.outMode !== "split") || | ||
if ((data.outMode !== "bounce" && data.outMode !== "split") || | ||
(data.direction !== "left" && data.direction !== "right")) { | ||
@@ -47,6 +44,3 @@ return; | ||
function bounceVertical(data) { | ||
if ((data.outMode !== "bounce" && | ||
data.outMode !== "bounce-vertical" && | ||
data.outMode !== "bounceVertical" && | ||
data.outMode !== "split") || | ||
if ((data.outMode !== "bounce" && data.outMode !== "split") || | ||
(data.direction !== "bottom" && data.direction !== "top")) { | ||
@@ -53,0 +47,0 @@ return; |
import { calculateBounds, } from "@tsparticles/engine"; | ||
import { bounceHorizontal, bounceVertical } from "./Utils.js"; | ||
export class BounceOutMode { | ||
@@ -8,10 +7,6 @@ constructor(container) { | ||
"bounce", | ||
"bounce-vertical", | ||
"bounce-horizontal", | ||
"bounceVertical", | ||
"bounceHorizontal", | ||
"split", | ||
]; | ||
} | ||
update(particle, direction, delta, outMode) { | ||
async update(particle, direction, delta, outMode) { | ||
if (!this.modes.includes(outMode)) { | ||
@@ -24,3 +19,3 @@ return; | ||
if (plugin.particleBounce !== undefined) { | ||
handled = plugin.particleBounce(particle, delta, direction); | ||
handled = await plugin.particleBounce(particle, delta, direction); | ||
} | ||
@@ -34,3 +29,3 @@ if (handled) { | ||
} | ||
const pos = particle.getPosition(), offset = particle.offset, size = particle.getRadius(), bounds = calculateBounds(pos, size), canvasSize = container.canvas.size; | ||
const pos = particle.getPosition(), offset = particle.offset, size = particle.getRadius(), bounds = calculateBounds(pos, size), canvasSize = container.canvas.size, { bounceHorizontal, bounceVertical } = await import("./Utils.js"); | ||
bounceHorizontal({ particle, outMode, direction, bounds, canvasSize, offset, size }); | ||
@@ -37,0 +32,0 @@ bounceVertical({ particle, outMode, direction, bounds, canvasSize, offset, size }); |
@@ -8,3 +8,3 @@ import { Vector, getDistances, isPointInside, } from "@tsparticles/engine"; | ||
} | ||
update(particle, direction, _delta, outMode) { | ||
async update(particle, direction, _delta, outMode) { | ||
if (!this.modes.includes(outMode)) { | ||
@@ -22,4 +22,3 @@ return; | ||
case "inside": { | ||
const { dx, dy } = getDistances(particle.position, particle.moveCenter); | ||
const { x: vx, y: vy } = particle.velocity; | ||
const { dx, dy } = getDistances(particle.position, particle.moveCenter), { x: vx, y: vy } = particle.velocity; | ||
if ((vx < minVelocity && dx > particle.moveCenter.radius) || | ||
@@ -35,3 +34,4 @@ (vy < minVelocity && dy > particle.moveCenter.radius) || | ||
container.particles.remove(particle, undefined, true); | ||
await Promise.resolve(); | ||
} | ||
} |
@@ -1,4 +0,6 @@ | ||
import { OutOfCanvasUpdater } from "./OutOfCanvasUpdater.js"; | ||
export async function loadOutModesUpdater(engine, refresh = true) { | ||
await engine.addParticleUpdater("outModes", (container) => new OutOfCanvasUpdater(container), refresh); | ||
await engine.addParticleUpdater("outModes", async (container) => { | ||
const { OutOfCanvasUpdater } = await import("./OutOfCanvasUpdater.js"); | ||
return new OutOfCanvasUpdater(container); | ||
}, refresh); | ||
} |
@@ -8,3 +8,3 @@ import { Vector, isPointInside, } from "@tsparticles/engine"; | ||
} | ||
update(particle, direction, delta, outMode) { | ||
async update(particle, direction, delta, outMode) { | ||
if (!this.modes.includes(outMode)) { | ||
@@ -19,5 +19,3 @@ return; | ||
} | ||
const gravityOptions = particle.options.move.gravity, container = this.container; | ||
const canvasSize = container.canvas.size; | ||
const pRadius = particle.getRadius(); | ||
const gravityOptions = particle.options.move.gravity, container = this.container, canvasSize = container.canvas.size, pRadius = particle.getRadius(); | ||
if (!gravityOptions.enable) { | ||
@@ -43,3 +41,4 @@ if ((particle.velocity.y > minVelocity && particle.position.y <= canvasSize.height + pRadius) || | ||
} | ||
await Promise.resolve(); | ||
} | ||
} |
@@ -1,21 +0,37 @@ | ||
import { BounceOutMode } from "./BounceOutMode.js"; | ||
import { DestroyOutMode } from "./DestroyOutMode.js"; | ||
import { NoneOutMode } from "./NoneOutMode.js"; | ||
import { OutOutMode } from "./OutOutMode.js"; | ||
const checkOutMode = (outModes, outMode) => { | ||
return (outModes.default === outMode || | ||
outModes.bottom === outMode || | ||
outModes.left === outMode || | ||
outModes.right === outMode || | ||
outModes.top === outMode); | ||
}; | ||
export class OutOfCanvasUpdater { | ||
constructor(container) { | ||
this._updateOutMode = (particle, delta, outMode, direction) => { | ||
this._updateOutMode = async (particle, delta, outMode, direction) => { | ||
for (const updater of this.updaters) { | ||
updater.update(particle, direction, delta, outMode); | ||
await updater.update(particle, direction, delta, outMode); | ||
} | ||
}; | ||
this.container = container; | ||
this.updaters = [ | ||
new BounceOutMode(container), | ||
new DestroyOutMode(container), | ||
new OutOutMode(container), | ||
new NoneOutMode(container), | ||
]; | ||
this.updaters = []; | ||
} | ||
init() { | ||
async init(particle) { | ||
this.updaters = []; | ||
const outModes = particle.options.move.outModes; | ||
if (checkOutMode(outModes, "bounce")) { | ||
const { BounceOutMode } = await import("./BounceOutMode.js"); | ||
this.updaters.push(new BounceOutMode(this.container)); | ||
} | ||
else if (checkOutMode(outModes, "out")) { | ||
const { OutOutMode } = await import("./OutOutMode.js"); | ||
this.updaters.push(new OutOutMode(this.container)); | ||
} | ||
else if (checkOutMode(outModes, "destroy")) { | ||
const { DestroyOutMode } = await import("./DestroyOutMode.js"); | ||
this.updaters.push(new DestroyOutMode(this.container)); | ||
} | ||
else if (checkOutMode(outModes, "none")) { | ||
const { NoneOutMode } = await import("./NoneOutMode.js"); | ||
this.updaters.push(new NoneOutMode(this.container)); | ||
} | ||
} | ||
@@ -25,9 +41,9 @@ isEnabled(particle) { | ||
} | ||
update(particle, delta) { | ||
async update(particle, delta) { | ||
const outModes = particle.options.move.outModes; | ||
this._updateOutMode(particle, delta, outModes.bottom ?? outModes.default, "bottom"); | ||
this._updateOutMode(particle, delta, outModes.left ?? outModes.default, "left"); | ||
this._updateOutMode(particle, delta, outModes.right ?? outModes.default, "right"); | ||
this._updateOutMode(particle, delta, outModes.top ?? outModes.default, "top"); | ||
await this._updateOutMode(particle, delta, outModes.bottom ?? outModes.default, "bottom"); | ||
await this._updateOutMode(particle, delta, outModes.left ?? outModes.default, "left"); | ||
await this._updateOutMode(particle, delta, outModes.right ?? outModes.default, "right"); | ||
await this._updateOutMode(particle, delta, outModes.top ?? outModes.default, "top"); | ||
} | ||
} |
@@ -8,3 +8,3 @@ import { Vector, calculateBounds, getDistances, getRandom, isPointInside, randomInRange, } from "@tsparticles/engine"; | ||
} | ||
update(particle, direction, delta, outMode) { | ||
async update(particle, direction, delta, outMode) { | ||
if (!this.modes.includes(outMode)) { | ||
@@ -111,3 +111,4 @@ return; | ||
} | ||
await Promise.resolve(); | ||
} | ||
} |
import { getRangeValue } from "@tsparticles/engine"; | ||
const minVelocity = 0, boundsMin = 0; | ||
export function bounceHorizontal(data) { | ||
if ((data.outMode !== "bounce" && | ||
data.outMode !== "bounce-horizontal" && | ||
data.outMode !== "bounceHorizontal" && | ||
data.outMode !== "split") || | ||
if ((data.outMode !== "bounce" && data.outMode !== "split") || | ||
(data.direction !== "left" && data.direction !== "right")) { | ||
@@ -42,6 +39,3 @@ return; | ||
export function bounceVertical(data) { | ||
if ((data.outMode !== "bounce" && | ||
data.outMode !== "bounce-vertical" && | ||
data.outMode !== "bounceVertical" && | ||
data.outMode !== "split") || | ||
if ((data.outMode !== "bounce" && data.outMode !== "split") || | ||
(data.direction !== "bottom" && data.direction !== "top")) { | ||
@@ -48,0 +42,0 @@ return; |
{ | ||
"name": "@tsparticles/updater-out-modes", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "tsParticles particles out modes updater", | ||
@@ -90,3 +90,3 @@ "homepage": "https://particles.js.org", | ||
"dependencies": { | ||
"@tsparticles/engine": "^3.1.0" | ||
"@tsparticles/engine": "^3.2.0" | ||
}, | ||
@@ -93,0 +93,0 @@ "publishConfig": { |
@@ -7,4 +7,12 @@ /*! | ||
* How to use? : Check the GitHub README | ||
* v3.1.0 | ||
* v3.2.0 | ||
*/ | ||
/* | ||
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development"). | ||
* This devtool is neither made for production nor for readable output files. | ||
* It uses "eval()" calls to create a separate source file in the browser devtools. | ||
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/) | ||
* or disable the default devtool with "devtool: false". | ||
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/). | ||
*/ | ||
(function webpackUniversalModuleDefinition(root, factory) { | ||
@@ -19,3 +27,3 @@ if(typeof exports === 'object' && typeof module === 'object') | ||
} | ||
})(this, (__WEBPACK_EXTERNAL_MODULE__533__) => { | ||
})(this, (__WEBPACK_EXTERNAL_MODULE__tsparticles_engine__) => { | ||
return /******/ (() => { // webpackBootstrap | ||
@@ -25,6 +33,19 @@ /******/ "use strict"; | ||
/***/ 533: | ||
/***/ "./dist/browser/index.js": | ||
/*!*******************************!*\ | ||
!*** ./dist/browser/index.js ***! | ||
\*******************************/ | ||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { | ||
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadOutModesUpdater: () => (/* binding */ loadOutModesUpdater)\n/* harmony export */ });\nasync function loadOutModesUpdater(engine, refresh = true) {\n await engine.addParticleUpdater(\"outModes\", async container => {\n const {\n OutOfCanvasUpdater\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_OutOfCanvasUpdater_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./OutOfCanvasUpdater.js */ \"./dist/browser/OutOfCanvasUpdater.js\"));\n return new OutOfCanvasUpdater(container);\n }, refresh);\n}\n\n//# sourceURL=webpack://@tsparticles/updater-out-modes/./dist/browser/index.js?"); | ||
/***/ }), | ||
/***/ "@tsparticles/engine": | ||
/*!*********************************************************************************************************************************!*\ | ||
!*** external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"} ***! | ||
\*********************************************************************************************************************************/ | ||
/***/ ((module) => { | ||
module.exports = __WEBPACK_EXTERNAL_MODULE__533__; | ||
module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__; | ||
@@ -59,3 +80,18 @@ /***/ }) | ||
/******/ | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = __webpack_modules__; | ||
/******/ | ||
/************************************************************************/ | ||
/******/ /* webpack/runtime/compat get default export */ | ||
/******/ (() => { | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
/******/ __webpack_require__.n = (module) => { | ||
/******/ var getter = module && module.__esModule ? | ||
/******/ () => (module['default']) : | ||
/******/ () => (module); | ||
/******/ __webpack_require__.d(getter, { a: getter }); | ||
/******/ return getter; | ||
/******/ }; | ||
/******/ })(); | ||
/******/ | ||
/******/ /* webpack/runtime/define property getters */ | ||
@@ -73,2 +109,36 @@ /******/ (() => { | ||
/******/ | ||
/******/ /* webpack/runtime/ensure chunk */ | ||
/******/ (() => { | ||
/******/ __webpack_require__.f = {}; | ||
/******/ // This file contains only the entry chunk. | ||
/******/ // The chunk loading function for additional chunks | ||
/******/ __webpack_require__.e = (chunkId) => { | ||
/******/ return Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => { | ||
/******/ __webpack_require__.f[key](chunkId, promises); | ||
/******/ return promises; | ||
/******/ }, [])); | ||
/******/ }; | ||
/******/ })(); | ||
/******/ | ||
/******/ /* webpack/runtime/get javascript chunk filename */ | ||
/******/ (() => { | ||
/******/ // This function allow to reference async chunks | ||
/******/ __webpack_require__.u = (chunkId) => { | ||
/******/ // return url for filenames based on template | ||
/******/ return "" + chunkId + ".js"; | ||
/******/ }; | ||
/******/ })(); | ||
/******/ | ||
/******/ /* webpack/runtime/global */ | ||
/******/ (() => { | ||
/******/ __webpack_require__.g = (function() { | ||
/******/ if (typeof globalThis === 'object') return globalThis; | ||
/******/ try { | ||
/******/ return this || new Function('return this')(); | ||
/******/ } catch (e) { | ||
/******/ if (typeof window === 'object') return window; | ||
/******/ } | ||
/******/ })(); | ||
/******/ })(); | ||
/******/ | ||
/******/ /* webpack/runtime/hasOwnProperty shorthand */ | ||
@@ -79,2 +149,48 @@ /******/ (() => { | ||
/******/ | ||
/******/ /* webpack/runtime/load script */ | ||
/******/ (() => { | ||
/******/ var inProgress = {}; | ||
/******/ var dataWebpackPrefix = "@tsparticles/updater-out-modes:"; | ||
/******/ // loadScript function to load a script via script tag | ||
/******/ __webpack_require__.l = (url, done, key, chunkId) => { | ||
/******/ if(inProgress[url]) { inProgress[url].push(done); return; } | ||
/******/ var script, needAttach; | ||
/******/ if(key !== undefined) { | ||
/******/ var scripts = document.getElementsByTagName("script"); | ||
/******/ for(var i = 0; i < scripts.length; i++) { | ||
/******/ var s = scripts[i]; | ||
/******/ if(s.getAttribute("src") == url || s.getAttribute("data-webpack") == dataWebpackPrefix + key) { script = s; break; } | ||
/******/ } | ||
/******/ } | ||
/******/ if(!script) { | ||
/******/ needAttach = true; | ||
/******/ script = document.createElement('script'); | ||
/******/ | ||
/******/ script.charset = 'utf-8'; | ||
/******/ script.timeout = 120; | ||
/******/ if (__webpack_require__.nc) { | ||
/******/ script.setAttribute("nonce", __webpack_require__.nc); | ||
/******/ } | ||
/******/ script.setAttribute("data-webpack", dataWebpackPrefix + key); | ||
/******/ | ||
/******/ script.src = url; | ||
/******/ } | ||
/******/ inProgress[url] = [done]; | ||
/******/ var onScriptComplete = (prev, event) => { | ||
/******/ // avoid mem leaks in IE. | ||
/******/ script.onerror = script.onload = null; | ||
/******/ clearTimeout(timeout); | ||
/******/ var doneFns = inProgress[url]; | ||
/******/ delete inProgress[url]; | ||
/******/ script.parentNode && script.parentNode.removeChild(script); | ||
/******/ doneFns && doneFns.forEach((fn) => (fn(event))); | ||
/******/ if(prev) return prev(event); | ||
/******/ } | ||
/******/ var timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000); | ||
/******/ script.onerror = onScriptComplete.bind(null, script.onerror); | ||
/******/ script.onload = onScriptComplete.bind(null, script.onload); | ||
/******/ needAttach && document.head.appendChild(script); | ||
/******/ }; | ||
/******/ })(); | ||
/******/ | ||
/******/ /* webpack/runtime/make namespace object */ | ||
@@ -91,359 +207,124 @@ /******/ (() => { | ||
/******/ | ||
/******/ /* webpack/runtime/publicPath */ | ||
/******/ (() => { | ||
/******/ var scriptUrl; | ||
/******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + ""; | ||
/******/ var document = __webpack_require__.g.document; | ||
/******/ if (!scriptUrl && document) { | ||
/******/ if (document.currentScript) | ||
/******/ scriptUrl = document.currentScript.src; | ||
/******/ if (!scriptUrl) { | ||
/******/ var scripts = document.getElementsByTagName("script"); | ||
/******/ if(scripts.length) { | ||
/******/ var i = scripts.length - 1; | ||
/******/ while (i > -1 && !scriptUrl) scriptUrl = scripts[i--].src; | ||
/******/ } | ||
/******/ } | ||
/******/ } | ||
/******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration | ||
/******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic. | ||
/******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser"); | ||
/******/ scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/"); | ||
/******/ __webpack_require__.p = scriptUrl; | ||
/******/ })(); | ||
/******/ | ||
/******/ /* webpack/runtime/jsonp chunk loading */ | ||
/******/ (() => { | ||
/******/ // no baseURI | ||
/******/ | ||
/******/ // object to store loaded and loading chunks | ||
/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched | ||
/******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded | ||
/******/ var installedChunks = { | ||
/******/ "tsparticles.updater.out-modes": 0 | ||
/******/ }; | ||
/******/ | ||
/******/ __webpack_require__.f.j = (chunkId, promises) => { | ||
/******/ // JSONP chunk loading for javascript | ||
/******/ var installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined; | ||
/******/ if(installedChunkData !== 0) { // 0 means "already installed". | ||
/******/ | ||
/******/ // a Promise means "currently loading". | ||
/******/ if(installedChunkData) { | ||
/******/ promises.push(installedChunkData[2]); | ||
/******/ } else { | ||
/******/ if(true) { // all chunks have JS | ||
/******/ // setup Promise in chunk cache | ||
/******/ var promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject])); | ||
/******/ promises.push(installedChunkData[2] = promise); | ||
/******/ | ||
/******/ // start chunk loading | ||
/******/ var url = __webpack_require__.p + __webpack_require__.u(chunkId); | ||
/******/ // create error before stack unwound to get useful stacktrace later | ||
/******/ var error = new Error(); | ||
/******/ var loadingEnded = (event) => { | ||
/******/ if(__webpack_require__.o(installedChunks, chunkId)) { | ||
/******/ installedChunkData = installedChunks[chunkId]; | ||
/******/ if(installedChunkData !== 0) installedChunks[chunkId] = undefined; | ||
/******/ if(installedChunkData) { | ||
/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type); | ||
/******/ var realSrc = event && event.target && event.target.src; | ||
/******/ error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')'; | ||
/******/ error.name = 'ChunkLoadError'; | ||
/******/ error.type = errorType; | ||
/******/ error.request = realSrc; | ||
/******/ installedChunkData[1](error); | ||
/******/ } | ||
/******/ } | ||
/******/ }; | ||
/******/ __webpack_require__.l(url, loadingEnded, "chunk-" + chunkId, chunkId); | ||
/******/ } | ||
/******/ } | ||
/******/ } | ||
/******/ }; | ||
/******/ | ||
/******/ // no prefetching | ||
/******/ | ||
/******/ // no preloaded | ||
/******/ | ||
/******/ // no HMR | ||
/******/ | ||
/******/ // no HMR manifest | ||
/******/ | ||
/******/ // no on chunks loaded | ||
/******/ | ||
/******/ // install a JSONP callback for chunk loading | ||
/******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => { | ||
/******/ var chunkIds = data[0]; | ||
/******/ var moreModules = data[1]; | ||
/******/ var runtime = data[2]; | ||
/******/ // add "moreModules" to the modules object, | ||
/******/ // then flag all "chunkIds" as loaded and fire callback | ||
/******/ var moduleId, chunkId, i = 0; | ||
/******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) { | ||
/******/ for(moduleId in moreModules) { | ||
/******/ if(__webpack_require__.o(moreModules, moduleId)) { | ||
/******/ __webpack_require__.m[moduleId] = moreModules[moduleId]; | ||
/******/ } | ||
/******/ } | ||
/******/ if(runtime) var result = runtime(__webpack_require__); | ||
/******/ } | ||
/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data); | ||
/******/ for(;i < chunkIds.length; i++) { | ||
/******/ chunkId = chunkIds[i]; | ||
/******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) { | ||
/******/ installedChunks[chunkId][0](); | ||
/******/ } | ||
/******/ installedChunks[chunkId] = 0; | ||
/******/ } | ||
/******/ | ||
/******/ } | ||
/******/ | ||
/******/ var chunkLoadingGlobal = this["webpackChunk_tsparticles_updater_out_modes"] = this["webpackChunk_tsparticles_updater_out_modes"] || []; | ||
/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0)); | ||
/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal)); | ||
/******/ })(); | ||
/******/ | ||
/************************************************************************/ | ||
var __webpack_exports__ = {}; | ||
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. | ||
(() => { | ||
// ESM COMPAT FLAG | ||
__webpack_require__.r(__webpack_exports__); | ||
// EXPORTS | ||
__webpack_require__.d(__webpack_exports__, { | ||
loadOutModesUpdater: () => (/* binding */ loadOutModesUpdater) | ||
}); | ||
// EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"} | ||
var engine_root_window_ = __webpack_require__(533); | ||
;// CONCATENATED MODULE: ./dist/browser/Utils.js | ||
const minVelocity = 0, | ||
boundsMin = 0; | ||
function bounceHorizontal(data) { | ||
if (data.outMode !== "bounce" && data.outMode !== "bounce-horizontal" && data.outMode !== "bounceHorizontal" && data.outMode !== "split" || data.direction !== "left" && data.direction !== "right") { | ||
return; | ||
} | ||
if (data.bounds.right < boundsMin && data.direction === "left") { | ||
data.particle.position.x = data.size + data.offset.x; | ||
} else if (data.bounds.left > data.canvasSize.width && data.direction === "right") { | ||
data.particle.position.x = data.canvasSize.width - data.size - data.offset.x; | ||
} | ||
const velocity = data.particle.velocity.x; | ||
let bounced = false; | ||
if (data.direction === "right" && data.bounds.right >= data.canvasSize.width && velocity > minVelocity || data.direction === "left" && data.bounds.left <= boundsMin && velocity < minVelocity) { | ||
const newVelocity = (0,engine_root_window_.getRangeValue)(data.particle.options.bounce.horizontal.value); | ||
data.particle.velocity.x *= -newVelocity; | ||
bounced = true; | ||
} | ||
if (!bounced) { | ||
return; | ||
} | ||
const minPos = data.offset.x + data.size; | ||
if (data.bounds.right >= data.canvasSize.width && data.direction === "right") { | ||
data.particle.position.x = data.canvasSize.width - minPos; | ||
} else if (data.bounds.left <= boundsMin && data.direction === "left") { | ||
data.particle.position.x = minPos; | ||
} | ||
if (data.outMode === "split") { | ||
data.particle.destroy(); | ||
} | ||
} | ||
function bounceVertical(data) { | ||
if (data.outMode !== "bounce" && data.outMode !== "bounce-vertical" && data.outMode !== "bounceVertical" && data.outMode !== "split" || data.direction !== "bottom" && data.direction !== "top") { | ||
return; | ||
} | ||
if (data.bounds.bottom < boundsMin && data.direction === "top") { | ||
data.particle.position.y = data.size + data.offset.y; | ||
} else if (data.bounds.top > data.canvasSize.height && data.direction === "bottom") { | ||
data.particle.position.y = data.canvasSize.height - data.size - data.offset.y; | ||
} | ||
const velocity = data.particle.velocity.y; | ||
let bounced = false; | ||
if (data.direction === "bottom" && data.bounds.bottom >= data.canvasSize.height && velocity > minVelocity || data.direction === "top" && data.bounds.top <= boundsMin && velocity < minVelocity) { | ||
const newVelocity = (0,engine_root_window_.getRangeValue)(data.particle.options.bounce.vertical.value); | ||
data.particle.velocity.y *= -newVelocity; | ||
bounced = true; | ||
} | ||
if (!bounced) { | ||
return; | ||
} | ||
const minPos = data.offset.y + data.size; | ||
if (data.bounds.bottom >= data.canvasSize.height && data.direction === "bottom") { | ||
data.particle.position.y = data.canvasSize.height - minPos; | ||
} else if (data.bounds.top <= boundsMin && data.direction === "top") { | ||
data.particle.position.y = minPos; | ||
} | ||
if (data.outMode === "split") { | ||
data.particle.destroy(); | ||
} | ||
} | ||
;// CONCATENATED MODULE: ./dist/browser/BounceOutMode.js | ||
class BounceOutMode { | ||
constructor(container) { | ||
this.container = container; | ||
this.modes = ["bounce", "bounce-vertical", "bounce-horizontal", "bounceVertical", "bounceHorizontal", "split"]; | ||
} | ||
update(particle, direction, delta, outMode) { | ||
if (!this.modes.includes(outMode)) { | ||
return; | ||
} | ||
const container = this.container; | ||
let handled = false; | ||
for (const [, plugin] of container.plugins) { | ||
if (plugin.particleBounce !== undefined) { | ||
handled = plugin.particleBounce(particle, delta, direction); | ||
} | ||
if (handled) { | ||
break; | ||
} | ||
} | ||
if (handled) { | ||
return; | ||
} | ||
const pos = particle.getPosition(), | ||
offset = particle.offset, | ||
size = particle.getRadius(), | ||
bounds = (0,engine_root_window_.calculateBounds)(pos, size), | ||
canvasSize = container.canvas.size; | ||
bounceHorizontal({ | ||
particle, | ||
outMode, | ||
direction, | ||
bounds, | ||
canvasSize, | ||
offset, | ||
size | ||
}); | ||
bounceVertical({ | ||
particle, | ||
outMode, | ||
direction, | ||
bounds, | ||
canvasSize, | ||
offset, | ||
size | ||
}); | ||
} | ||
} | ||
;// CONCATENATED MODULE: ./dist/browser/DestroyOutMode.js | ||
const DestroyOutMode_minVelocity = 0; | ||
class DestroyOutMode { | ||
constructor(container) { | ||
this.container = container; | ||
this.modes = ["destroy"]; | ||
} | ||
update(particle, direction, _delta, outMode) { | ||
if (!this.modes.includes(outMode)) { | ||
return; | ||
} | ||
const container = this.container; | ||
switch (particle.outType) { | ||
case "normal": | ||
case "outside": | ||
if ((0,engine_root_window_.isPointInside)(particle.position, container.canvas.size, engine_root_window_.Vector.origin, particle.getRadius(), direction)) { | ||
return; | ||
} | ||
break; | ||
case "inside": | ||
{ | ||
const { | ||
dx, | ||
dy | ||
} = (0,engine_root_window_.getDistances)(particle.position, particle.moveCenter); | ||
const { | ||
x: vx, | ||
y: vy | ||
} = particle.velocity; | ||
if (vx < DestroyOutMode_minVelocity && dx > particle.moveCenter.radius || vy < DestroyOutMode_minVelocity && dy > particle.moveCenter.radius || vx >= DestroyOutMode_minVelocity && dx < -particle.moveCenter.radius || vy >= DestroyOutMode_minVelocity && dy < -particle.moveCenter.radius) { | ||
return; | ||
} | ||
break; | ||
} | ||
} | ||
container.particles.remove(particle, undefined, true); | ||
} | ||
} | ||
;// CONCATENATED MODULE: ./dist/browser/NoneOutMode.js | ||
const NoneOutMode_minVelocity = 0; | ||
class NoneOutMode { | ||
constructor(container) { | ||
this.container = container; | ||
this.modes = ["none"]; | ||
} | ||
update(particle, direction, delta, outMode) { | ||
if (!this.modes.includes(outMode)) { | ||
return; | ||
} | ||
if ((particle.options.move.distance.horizontal && (direction === "left" || direction === "right")) ?? (particle.options.move.distance.vertical && (direction === "top" || direction === "bottom"))) { | ||
return; | ||
} | ||
const gravityOptions = particle.options.move.gravity, | ||
container = this.container; | ||
const canvasSize = container.canvas.size; | ||
const pRadius = particle.getRadius(); | ||
if (!gravityOptions.enable) { | ||
if (particle.velocity.y > NoneOutMode_minVelocity && particle.position.y <= canvasSize.height + pRadius || particle.velocity.y < NoneOutMode_minVelocity && particle.position.y >= -pRadius || particle.velocity.x > NoneOutMode_minVelocity && particle.position.x <= canvasSize.width + pRadius || particle.velocity.x < NoneOutMode_minVelocity && particle.position.x >= -pRadius) { | ||
return; | ||
} | ||
if (!(0,engine_root_window_.isPointInside)(particle.position, container.canvas.size, engine_root_window_.Vector.origin, pRadius, direction)) { | ||
container.particles.remove(particle); | ||
} | ||
} else { | ||
const position = particle.position; | ||
if (!gravityOptions.inverse && position.y > canvasSize.height + pRadius && direction === "bottom" || gravityOptions.inverse && position.y < -pRadius && direction === "top") { | ||
container.particles.remove(particle); | ||
} | ||
} | ||
} | ||
} | ||
;// CONCATENATED MODULE: ./dist/browser/OutOutMode.js | ||
const OutOutMode_minVelocity = 0, | ||
minDistance = 0; | ||
class OutOutMode { | ||
constructor(container) { | ||
this.container = container; | ||
this.modes = ["out"]; | ||
} | ||
update(particle, direction, delta, outMode) { | ||
if (!this.modes.includes(outMode)) { | ||
return; | ||
} | ||
const container = this.container; | ||
switch (particle.outType) { | ||
case "inside": | ||
{ | ||
const { | ||
x: vx, | ||
y: vy | ||
} = particle.velocity; | ||
const circVec = engine_root_window_.Vector.origin; | ||
circVec.length = particle.moveCenter.radius; | ||
circVec.angle = particle.velocity.angle + Math.PI; | ||
circVec.addTo(engine_root_window_.Vector.create(particle.moveCenter)); | ||
const { | ||
dx, | ||
dy | ||
} = (0,engine_root_window_.getDistances)(particle.position, circVec); | ||
if (vx <= OutOutMode_minVelocity && dx >= minDistance || vy <= OutOutMode_minVelocity && dy >= minDistance || vx >= OutOutMode_minVelocity && dx <= minDistance || vy >= OutOutMode_minVelocity && dy <= minDistance) { | ||
return; | ||
} | ||
particle.position.x = Math.floor((0,engine_root_window_.randomInRange)({ | ||
min: 0, | ||
max: container.canvas.size.width | ||
})); | ||
particle.position.y = Math.floor((0,engine_root_window_.randomInRange)({ | ||
min: 0, | ||
max: container.canvas.size.height | ||
})); | ||
const { | ||
dx: newDx, | ||
dy: newDy | ||
} = (0,engine_root_window_.getDistances)(particle.position, particle.moveCenter); | ||
particle.direction = Math.atan2(-newDy, -newDx); | ||
particle.velocity.angle = particle.direction; | ||
break; | ||
} | ||
default: | ||
{ | ||
if ((0,engine_root_window_.isPointInside)(particle.position, container.canvas.size, engine_root_window_.Vector.origin, particle.getRadius(), direction)) { | ||
return; | ||
} | ||
switch (particle.outType) { | ||
case "outside": | ||
{ | ||
particle.position.x = Math.floor((0,engine_root_window_.randomInRange)({ | ||
min: -particle.moveCenter.radius, | ||
max: particle.moveCenter.radius | ||
})) + particle.moveCenter.x; | ||
particle.position.y = Math.floor((0,engine_root_window_.randomInRange)({ | ||
min: -particle.moveCenter.radius, | ||
max: particle.moveCenter.radius | ||
})) + particle.moveCenter.y; | ||
const { | ||
dx, | ||
dy | ||
} = (0,engine_root_window_.getDistances)(particle.position, particle.moveCenter); | ||
if (particle.moveCenter.radius) { | ||
particle.direction = Math.atan2(dy, dx); | ||
particle.velocity.angle = particle.direction; | ||
} | ||
break; | ||
} | ||
case "normal": | ||
{ | ||
const warp = particle.options.move.warp, | ||
canvasSize = container.canvas.size, | ||
newPos = { | ||
bottom: canvasSize.height + particle.getRadius() + particle.offset.y, | ||
left: -particle.getRadius() - particle.offset.x, | ||
right: canvasSize.width + particle.getRadius() + particle.offset.x, | ||
top: -particle.getRadius() - particle.offset.y | ||
}, | ||
sizeValue = particle.getRadius(), | ||
nextBounds = (0,engine_root_window_.calculateBounds)(particle.position, sizeValue); | ||
if (direction === "right" && nextBounds.left > canvasSize.width + particle.offset.x) { | ||
particle.position.x = newPos.left; | ||
particle.initialPosition.x = particle.position.x; | ||
if (!warp) { | ||
particle.position.y = (0,engine_root_window_.getRandom)() * canvasSize.height; | ||
particle.initialPosition.y = particle.position.y; | ||
} | ||
} else if (direction === "left" && nextBounds.right < -particle.offset.x) { | ||
particle.position.x = newPos.right; | ||
particle.initialPosition.x = particle.position.x; | ||
if (!warp) { | ||
particle.position.y = (0,engine_root_window_.getRandom)() * canvasSize.height; | ||
particle.initialPosition.y = particle.position.y; | ||
} | ||
} | ||
if (direction === "bottom" && nextBounds.top > canvasSize.height + particle.offset.y) { | ||
if (!warp) { | ||
particle.position.x = (0,engine_root_window_.getRandom)() * canvasSize.width; | ||
particle.initialPosition.x = particle.position.x; | ||
} | ||
particle.position.y = newPos.top; | ||
particle.initialPosition.y = particle.position.y; | ||
} else if (direction === "top" && nextBounds.bottom < -particle.offset.y) { | ||
if (!warp) { | ||
particle.position.x = (0,engine_root_window_.getRandom)() * canvasSize.width; | ||
particle.initialPosition.x = particle.position.x; | ||
} | ||
particle.position.y = newPos.bottom; | ||
particle.initialPosition.y = particle.position.y; | ||
} | ||
break; | ||
} | ||
} | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
;// CONCATENATED MODULE: ./dist/browser/OutOfCanvasUpdater.js | ||
class OutOfCanvasUpdater { | ||
constructor(container) { | ||
this._updateOutMode = (particle, delta, outMode, direction) => { | ||
for (const updater of this.updaters) { | ||
updater.update(particle, direction, delta, outMode); | ||
} | ||
}; | ||
this.container = container; | ||
this.updaters = [new BounceOutMode(container), new DestroyOutMode(container), new OutOutMode(container), new NoneOutMode(container)]; | ||
} | ||
init() {} | ||
isEnabled(particle) { | ||
return !particle.destroyed && !particle.spawning; | ||
} | ||
update(particle, delta) { | ||
const outModes = particle.options.move.outModes; | ||
this._updateOutMode(particle, delta, outModes.bottom ?? outModes.default, "bottom"); | ||
this._updateOutMode(particle, delta, outModes.left ?? outModes.default, "left"); | ||
this._updateOutMode(particle, delta, outModes.right ?? outModes.default, "right"); | ||
this._updateOutMode(particle, delta, outModes.top ?? outModes.default, "top"); | ||
} | ||
} | ||
;// CONCATENATED MODULE: ./dist/browser/index.js | ||
async function loadOutModesUpdater(engine, refresh = true) { | ||
await engine.addParticleUpdater("outModes", container => new OutOfCanvasUpdater(container), refresh); | ||
} | ||
})(); | ||
/******/ | ||
/******/ // startup | ||
/******/ // Load entry module and return exports | ||
/******/ // This entry module can't be inlined because the eval devtool is used. | ||
/******/ var __webpack_exports__ = __webpack_require__("./dist/browser/index.js"); | ||
/******/ | ||
/******/ return __webpack_exports__; | ||
@@ -450,0 +331,0 @@ /******/ })() |
/*! For license information please see tsparticles.updater.out-modes.min.js.LICENSE.txt */ | ||
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],e);else{var o="object"==typeof exports?e(require("@tsparticles/engine")):e(t.window);for(var i in o)("object"==typeof exports?exports:t)[i]=o[i]}}(this,(t=>(()=>{"use strict";var e={533:e=>{e.exports=t}},o={};function i(t){var n=o[t];if(void 0!==n)return n.exports;var s=o[t]={exports:{}};return e[t](s,s.exports,i),s.exports}i.d=(t,e)=>{for(var o in e)i.o(e,o)&&!i.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{i.r(n),i.d(n,{loadOutModesUpdater:()=>c});var t=i(533);class e{constructor(t){this.container=t,this.modes=["bounce","bounce-vertical","bounce-horizontal","bounceVertical","bounceHorizontal","split"]}update(e,o,i,n){if(!this.modes.includes(n))return;const s=this.container;let r=!1;for(const[,t]of s.plugins)if(void 0!==t.particleBounce&&(r=t.particleBounce(e,i,o)),r)break;if(r)return;const a=e.getPosition(),c=e.offset,d=e.getRadius(),u=(0,t.calculateBounds)(a,d),p=s.canvas.size;!function(e){if("bounce"!==e.outMode&&"bounce-horizontal"!==e.outMode&&"bounceHorizontal"!==e.outMode&&"split"!==e.outMode||"left"!==e.direction&&"right"!==e.direction)return;e.bounds.right<0&&"left"===e.direction?e.particle.position.x=e.size+e.offset.x:e.bounds.left>e.canvasSize.width&&"right"===e.direction&&(e.particle.position.x=e.canvasSize.width-e.size-e.offset.x);const o=e.particle.velocity.x;let i=!1;if("right"===e.direction&&e.bounds.right>=e.canvasSize.width&&o>0||"left"===e.direction&&e.bounds.left<=0&&o<0){const o=(0,t.getRangeValue)(e.particle.options.bounce.horizontal.value);e.particle.velocity.x*=-o,i=!0}if(!i)return;const n=e.offset.x+e.size;e.bounds.right>=e.canvasSize.width&&"right"===e.direction?e.particle.position.x=e.canvasSize.width-n:e.bounds.left<=0&&"left"===e.direction&&(e.particle.position.x=n),"split"===e.outMode&&e.particle.destroy()}({particle:e,outMode:n,direction:o,bounds:u,canvasSize:p,offset:c,size:d}),function(e){if("bounce"!==e.outMode&&"bounce-vertical"!==e.outMode&&"bounceVertical"!==e.outMode&&"split"!==e.outMode||"bottom"!==e.direction&&"top"!==e.direction)return;e.bounds.bottom<0&&"top"===e.direction?e.particle.position.y=e.size+e.offset.y:e.bounds.top>e.canvasSize.height&&"bottom"===e.direction&&(e.particle.position.y=e.canvasSize.height-e.size-e.offset.y);const o=e.particle.velocity.y;let i=!1;if("bottom"===e.direction&&e.bounds.bottom>=e.canvasSize.height&&o>0||"top"===e.direction&&e.bounds.top<=0&&o<0){const o=(0,t.getRangeValue)(e.particle.options.bounce.vertical.value);e.particle.velocity.y*=-o,i=!0}if(!i)return;const n=e.offset.y+e.size;e.bounds.bottom>=e.canvasSize.height&&"bottom"===e.direction?e.particle.position.y=e.canvasSize.height-n:e.bounds.top<=0&&"top"===e.direction&&(e.particle.position.y=n),"split"===e.outMode&&e.particle.destroy()}({particle:e,outMode:n,direction:o,bounds:u,canvasSize:p,offset:c,size:d})}}class o{constructor(t){this.container=t,this.modes=["destroy"]}update(e,o,i,n){if(!this.modes.includes(n))return;const s=this.container;switch(e.outType){case"normal":case"outside":if((0,t.isPointInside)(e.position,s.canvas.size,t.Vector.origin,e.getRadius(),o))return;break;case"inside":{const{dx:o,dy:i}=(0,t.getDistances)(e.position,e.moveCenter),{x:n,y:s}=e.velocity;if(n<0&&o>e.moveCenter.radius||s<0&&i>e.moveCenter.radius||n>=0&&o<-e.moveCenter.radius||s>=0&&i<-e.moveCenter.radius)return;break}}s.particles.remove(e,void 0,!0)}}class s{constructor(t){this.container=t,this.modes=["none"]}update(e,o,i,n){if(!this.modes.includes(n))return;if((e.options.move.distance.horizontal&&("left"===o||"right"===o))??(e.options.move.distance.vertical&&("top"===o||"bottom"===o)))return;const s=e.options.move.gravity,r=this.container,a=r.canvas.size,c=e.getRadius();if(s.enable){const t=e.position;(!s.inverse&&t.y>a.height+c&&"bottom"===o||s.inverse&&t.y<-c&&"top"===o)&&r.particles.remove(e)}else{if(e.velocity.y>0&&e.position.y<=a.height+c||e.velocity.y<0&&e.position.y>=-c||e.velocity.x>0&&e.position.x<=a.width+c||e.velocity.x<0&&e.position.x>=-c)return;(0,t.isPointInside)(e.position,r.canvas.size,t.Vector.origin,c,o)||r.particles.remove(e)}}}class r{constructor(t){this.container=t,this.modes=["out"]}update(e,o,i,n){if(!this.modes.includes(n))return;const s=this.container;switch(e.outType){case"inside":{const{x:o,y:i}=e.velocity,n=t.Vector.origin;n.length=e.moveCenter.radius,n.angle=e.velocity.angle+Math.PI,n.addTo(t.Vector.create(e.moveCenter));const{dx:r,dy:a}=(0,t.getDistances)(e.position,n);if(o<=0&&r>=0||i<=0&&a>=0||o>=0&&r<=0||i>=0&&a<=0)return;e.position.x=Math.floor((0,t.randomInRange)({min:0,max:s.canvas.size.width})),e.position.y=Math.floor((0,t.randomInRange)({min:0,max:s.canvas.size.height}));const{dx:c,dy:d}=(0,t.getDistances)(e.position,e.moveCenter);e.direction=Math.atan2(-d,-c),e.velocity.angle=e.direction;break}default:if((0,t.isPointInside)(e.position,s.canvas.size,t.Vector.origin,e.getRadius(),o))return;switch(e.outType){case"outside":{e.position.x=Math.floor((0,t.randomInRange)({min:-e.moveCenter.radius,max:e.moveCenter.radius}))+e.moveCenter.x,e.position.y=Math.floor((0,t.randomInRange)({min:-e.moveCenter.radius,max:e.moveCenter.radius}))+e.moveCenter.y;const{dx:o,dy:i}=(0,t.getDistances)(e.position,e.moveCenter);e.moveCenter.radius&&(e.direction=Math.atan2(i,o),e.velocity.angle=e.direction);break}case"normal":{const i=e.options.move.warp,n=s.canvas.size,r={bottom:n.height+e.getRadius()+e.offset.y,left:-e.getRadius()-e.offset.x,right:n.width+e.getRadius()+e.offset.x,top:-e.getRadius()-e.offset.y},a=e.getRadius(),c=(0,t.calculateBounds)(e.position,a);"right"===o&&c.left>n.width+e.offset.x?(e.position.x=r.left,e.initialPosition.x=e.position.x,i||(e.position.y=(0,t.getRandom)()*n.height,e.initialPosition.y=e.position.y)):"left"===o&&c.right<-e.offset.x&&(e.position.x=r.right,e.initialPosition.x=e.position.x,i||(e.position.y=(0,t.getRandom)()*n.height,e.initialPosition.y=e.position.y)),"bottom"===o&&c.top>n.height+e.offset.y?(i||(e.position.x=(0,t.getRandom)()*n.width,e.initialPosition.x=e.position.x),e.position.y=r.top,e.initialPosition.y=e.position.y):"top"===o&&c.bottom<-e.offset.y&&(i||(e.position.x=(0,t.getRandom)()*n.width,e.initialPosition.x=e.position.x),e.position.y=r.bottom,e.initialPosition.y=e.position.y);break}}}}}class a{constructor(t){this._updateOutMode=(t,e,o,i)=>{for(const n of this.updaters)n.update(t,i,e,o)},this.container=t,this.updaters=[new e(t),new o(t),new r(t),new s(t)]}init(){}isEnabled(t){return!t.destroyed&&!t.spawning}update(t,e){const o=t.options.move.outModes;this._updateOutMode(t,e,o.bottom??o.default,"bottom"),this._updateOutMode(t,e,o.left??o.default,"left"),this._updateOutMode(t,e,o.right??o.default,"right"),this._updateOutMode(t,e,o.top??o.default,"top")}}async function c(t,e=!0){await t.addParticleUpdater("outModes",(t=>new a(t)),e)}})(),n})())); | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var r="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(this,(e=>(()=>{var t,r,o={533:t=>{t.exports=e}},n={};function a(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}};return o[e](r,r.exports,a),r.exports}a.m=o,a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.f={},a.e=e=>Promise.all(Object.keys(a.f).reduce(((t,r)=>(a.f[r](e,t),t)),[])),a.u=e=>e+".min.js",a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),t={},r="@tsparticles/updater-out-modes:",a.l=(e,o,n,i)=>{if(t[e])t[e].push(o);else{var s,u;if(void 0!==n)for(var d=document.getElementsByTagName("script"),c=0;c<d.length;c++){var p=d[c];if(p.getAttribute("src")==e||p.getAttribute("data-webpack")==r+n){s=p;break}}s||(u=!0,(s=document.createElement("script")).charset="utf-8",s.timeout=120,a.nc&&s.setAttribute("nonce",a.nc),s.setAttribute("data-webpack",r+n),s.src=e),t[e]=[o];var l=(r,o)=>{s.onerror=s.onload=null,clearTimeout(f);var n=t[e];if(delete t[e],s.parentNode&&s.parentNode.removeChild(s),n&&n.forEach((e=>e(o))),r)return r(o)},f=setTimeout(l.bind(null,void 0,{type:"timeout",target:s}),12e4);s.onerror=l.bind(null,s.onerror),s.onload=l.bind(null,s.onload),u&&document.head.appendChild(s)}},a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;a.g.importScripts&&(e=a.g.location+"");var t=a.g.document;if(!e&&t&&(t.currentScript&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var o=r.length-1;o>-1&&!e;)e=r[o--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),a.p=e})(),(()=>{var e={847:0};a.f.j=(t,r)=>{var o=a.o(e,t)?e[t]:void 0;if(0!==o)if(o)r.push(o[2]);else{var n=new Promise(((r,n)=>o=e[t]=[r,n]));r.push(o[2]=n);var i=a.p+a.u(t),s=new Error;a.l(i,(r=>{if(a.o(e,t)&&(0!==(o=e[t])&&(e[t]=void 0),o)){var n=r&&("load"===r.type?"missing":r.type),i=r&&r.target&&r.target.src;s.message="Loading chunk "+t+" failed.\n("+n+": "+i+")",s.name="ChunkLoadError",s.type=n,s.request=i,o[1](s)}}),"chunk-"+t,t)}};var t=(t,r)=>{var o,n,i=r[0],s=r[1],u=r[2],d=0;if(i.some((t=>0!==e[t]))){for(o in s)a.o(s,o)&&(a.m[o]=s[o]);if(u)u(a)}for(t&&t(r);d<i.length;d++)n=i[d],a.o(e,n)&&e[n]&&e[n][0](),e[n]=0},r=this.webpackChunk_tsparticles_updater_out_modes=this.webpackChunk_tsparticles_updater_out_modes||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var i={};return(()=>{async function e(e,t=!0){await e.addParticleUpdater("outModes",(async e=>{const{OutOfCanvasUpdater:t}=await a.e(53).then(a.bind(a,53));return new t(e)}),t)}a.r(i),a.d(i,{loadOutModesUpdater:()=>e})})(),i})())); |
@@ -1,1 +0,1 @@ | ||
/*! tsParticles Out Modes Updater v3.1.0 by Matteo Bruni */ | ||
/*! tsParticles Out Modes Updater v3.2.0 by Matteo Bruni */ |
@@ -1,8 +0,8 @@ | ||
import { type Container, type IDelta, OutMode, type OutModeAlt, type OutModeDirection, type Particle } from "@tsparticles/engine"; | ||
import { type Container, type IDelta, OutMode, type OutModeDirection, type Particle } from "@tsparticles/engine"; | ||
import type { IOutModeManager } from "./IOutModeManager.js"; | ||
export declare class BounceOutMode implements IOutModeManager { | ||
private readonly container; | ||
modes: (OutMode | OutModeAlt | keyof typeof OutMode)[]; | ||
modes: (OutMode | keyof typeof OutMode)[]; | ||
constructor(container: Container); | ||
update(particle: Particle, direction: OutModeDirection, delta: IDelta, outMode: OutMode | OutModeAlt | keyof typeof OutMode): void; | ||
update(particle: Particle, direction: OutModeDirection, delta: IDelta, outMode: OutMode | keyof typeof OutMode): Promise<void>; | ||
} |
@@ -1,8 +0,8 @@ | ||
import { type Container, type IDelta, OutMode, type OutModeAlt, type OutModeDirection, type Particle } from "@tsparticles/engine"; | ||
import { type Container, type IDelta, OutMode, type OutModeDirection, type Particle } from "@tsparticles/engine"; | ||
import type { IOutModeManager } from "./IOutModeManager.js"; | ||
export declare class DestroyOutMode implements IOutModeManager { | ||
private readonly container; | ||
modes: (OutMode | OutModeAlt | keyof typeof OutMode)[]; | ||
modes: (OutMode | keyof typeof OutMode)[]; | ||
constructor(container: Container); | ||
update(particle: Particle, direction: OutModeDirection, _delta: IDelta, outMode: OutMode | OutModeAlt | keyof typeof OutMode): void; | ||
update(particle: Particle, direction: OutModeDirection, _delta: IDelta, outMode: OutMode | keyof typeof OutMode): Promise<void>; | ||
} |
@@ -1,2 +0,2 @@ | ||
import type { IBounds, ICoordinates, IDimension, OutMode, OutModeAlt, OutModeDirection, Particle } from "@tsparticles/engine"; | ||
import type { IBounds, ICoordinates, IDimension, OutMode, OutModeDirection, Particle } from "@tsparticles/engine"; | ||
export interface IBounceData { | ||
@@ -7,5 +7,5 @@ bounds: IBounds; | ||
offset: ICoordinates; | ||
outMode: OutMode | OutModeAlt | keyof typeof OutMode; | ||
outMode: OutMode | keyof typeof OutMode; | ||
particle: Particle; | ||
size: number; | ||
} |
@@ -1,5 +0,5 @@ | ||
import type { IDelta, OutMode, OutModeAlt, OutModeDirection, Particle } from "@tsparticles/engine"; | ||
import type { IDelta, OutMode, OutModeDirection, Particle } from "@tsparticles/engine"; | ||
export interface IOutModeManager { | ||
modes: (OutMode | OutModeAlt | keyof typeof OutMode)[]; | ||
update(particle: Particle, direction: OutModeDirection, delta: IDelta, outMode: OutMode | OutModeAlt | keyof typeof OutMode): void; | ||
modes: (OutMode | keyof typeof OutMode)[]; | ||
update(particle: Particle, direction: OutModeDirection, delta: IDelta, outMode: OutMode | keyof typeof OutMode): Promise<void>; | ||
} |
@@ -1,8 +0,8 @@ | ||
import { type Container, type IDelta, OutMode, type OutModeAlt, OutModeDirection, type Particle } from "@tsparticles/engine"; | ||
import { type Container, type IDelta, OutMode, OutModeDirection, type Particle } from "@tsparticles/engine"; | ||
import type { IOutModeManager } from "./IOutModeManager.js"; | ||
export declare class NoneOutMode implements IOutModeManager { | ||
private readonly container; | ||
modes: (OutMode | OutModeAlt | keyof typeof OutMode)[]; | ||
modes: (OutMode | keyof typeof OutMode)[]; | ||
constructor(container: Container); | ||
update(particle: Particle, direction: OutModeDirection, delta: IDelta, outMode: OutMode | OutModeAlt | keyof typeof OutMode): void; | ||
update(particle: Particle, direction: OutModeDirection, delta: IDelta, outMode: OutMode | keyof typeof OutMode): Promise<void>; | ||
} |
@@ -7,6 +7,6 @@ import { type Container, type IDelta, type IParticleUpdater, type Particle } from "@tsparticles/engine"; | ||
constructor(container: Container); | ||
init(): void; | ||
init(particle: Particle): Promise<void>; | ||
isEnabled(particle: Particle): boolean; | ||
update(particle: Particle, delta: IDelta): void; | ||
update(particle: Particle, delta: IDelta): Promise<void>; | ||
private readonly _updateOutMode; | ||
} |
@@ -1,8 +0,8 @@ | ||
import { type Container, type IDelta, OutMode, type OutModeAlt, OutModeDirection, type Particle } from "@tsparticles/engine"; | ||
import { type Container, type IDelta, OutMode, OutModeDirection, type Particle } from "@tsparticles/engine"; | ||
import type { IOutModeManager } from "./IOutModeManager.js"; | ||
export declare class OutOutMode implements IOutModeManager { | ||
private readonly container; | ||
modes: (OutMode | OutModeAlt | keyof typeof OutMode)[]; | ||
modes: (OutMode | keyof typeof OutMode)[]; | ||
constructor(container: Container); | ||
update(particle: Particle, direction: OutModeDirection, delta: IDelta, outMode: OutMode | OutModeAlt | keyof typeof OutMode): void; | ||
update(particle: Particle, direction: OutModeDirection, delta: IDelta, outMode: OutMode | keyof typeof OutMode): Promise<void>; | ||
} |
@@ -0,1 +1,24 @@ | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
(function (factory) { | ||
@@ -7,10 +30,10 @@ if (typeof module === "object" && typeof module.exports === "object") { | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports", "@tsparticles/engine", "./Utils.js"], factory); | ||
define(["require", "exports", "@tsparticles/engine"], factory); | ||
} | ||
})(function (require, exports) { | ||
"use strict"; | ||
var __syncRequire = typeof module === "object" && typeof module.exports === "object"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BounceOutMode = void 0; | ||
const engine_1 = require("@tsparticles/engine"); | ||
const Utils_js_1 = require("./Utils.js"); | ||
class BounceOutMode { | ||
@@ -21,10 +44,6 @@ constructor(container) { | ||
"bounce", | ||
"bounce-vertical", | ||
"bounce-horizontal", | ||
"bounceVertical", | ||
"bounceHorizontal", | ||
"split", | ||
]; | ||
} | ||
update(particle, direction, delta, outMode) { | ||
async update(particle, direction, delta, outMode) { | ||
if (!this.modes.includes(outMode)) { | ||
@@ -37,3 +56,3 @@ return; | ||
if (plugin.particleBounce !== undefined) { | ||
handled = plugin.particleBounce(particle, delta, direction); | ||
handled = await plugin.particleBounce(particle, delta, direction); | ||
} | ||
@@ -47,5 +66,5 @@ if (handled) { | ||
} | ||
const pos = particle.getPosition(), offset = particle.offset, size = particle.getRadius(), bounds = (0, engine_1.calculateBounds)(pos, size), canvasSize = container.canvas.size; | ||
(0, Utils_js_1.bounceHorizontal)({ particle, outMode, direction, bounds, canvasSize, offset, size }); | ||
(0, Utils_js_1.bounceVertical)({ particle, outMode, direction, bounds, canvasSize, offset, size }); | ||
const pos = particle.getPosition(), offset = particle.offset, size = particle.getRadius(), bounds = (0, engine_1.calculateBounds)(pos, size), canvasSize = container.canvas.size, { bounceHorizontal, bounceVertical } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./Utils.js"))) : new Promise((resolve_1, reject_1) => { require(["./Utils.js"], resolve_1, reject_1); }).then(__importStar)); | ||
bounceHorizontal({ particle, outMode, direction, bounds, canvasSize, offset, size }); | ||
bounceVertical({ particle, outMode, direction, bounds, canvasSize, offset, size }); | ||
} | ||
@@ -52,0 +71,0 @@ } |
@@ -20,3 +20,3 @@ (function (factory) { | ||
} | ||
update(particle, direction, _delta, outMode) { | ||
async update(particle, direction, _delta, outMode) { | ||
if (!this.modes.includes(outMode)) { | ||
@@ -34,4 +34,3 @@ return; | ||
case "inside": { | ||
const { dx, dy } = (0, engine_1.getDistances)(particle.position, particle.moveCenter); | ||
const { x: vx, y: vy } = particle.velocity; | ||
const { dx, dy } = (0, engine_1.getDistances)(particle.position, particle.moveCenter), { x: vx, y: vy } = particle.velocity; | ||
if ((vx < minVelocity && dx > particle.moveCenter.radius) || | ||
@@ -47,2 +46,3 @@ (vy < minVelocity && dy > particle.moveCenter.radius) || | ||
container.particles.remove(particle, undefined, true); | ||
await Promise.resolve(); | ||
} | ||
@@ -49,0 +49,0 @@ } |
@@ -0,1 +1,24 @@ | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
(function (factory) { | ||
@@ -7,13 +30,16 @@ if (typeof module === "object" && typeof module.exports === "object") { | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports", "./OutOfCanvasUpdater.js"], factory); | ||
define(["require", "exports"], factory); | ||
} | ||
})(function (require, exports) { | ||
"use strict"; | ||
var __syncRequire = typeof module === "object" && typeof module.exports === "object"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.loadOutModesUpdater = void 0; | ||
const OutOfCanvasUpdater_js_1 = require("./OutOfCanvasUpdater.js"); | ||
async function loadOutModesUpdater(engine, refresh = true) { | ||
await engine.addParticleUpdater("outModes", (container) => new OutOfCanvasUpdater_js_1.OutOfCanvasUpdater(container), refresh); | ||
await engine.addParticleUpdater("outModes", async (container) => { | ||
const { OutOfCanvasUpdater } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./OutOfCanvasUpdater.js"))) : new Promise((resolve_1, reject_1) => { require(["./OutOfCanvasUpdater.js"], resolve_1, reject_1); }).then(__importStar)); | ||
return new OutOfCanvasUpdater(container); | ||
}, refresh); | ||
} | ||
exports.loadOutModesUpdater = loadOutModesUpdater; | ||
}); |
@@ -20,3 +20,3 @@ (function (factory) { | ||
} | ||
update(particle, direction, delta, outMode) { | ||
async update(particle, direction, delta, outMode) { | ||
if (!this.modes.includes(outMode)) { | ||
@@ -31,5 +31,3 @@ return; | ||
} | ||
const gravityOptions = particle.options.move.gravity, container = this.container; | ||
const canvasSize = container.canvas.size; | ||
const pRadius = particle.getRadius(); | ||
const gravityOptions = particle.options.move.gravity, container = this.container, canvasSize = container.canvas.size, pRadius = particle.getRadius(); | ||
if (!gravityOptions.enable) { | ||
@@ -55,2 +53,3 @@ if ((particle.velocity.y > minVelocity && particle.position.y <= canvasSize.height + pRadius) || | ||
} | ||
await Promise.resolve(); | ||
} | ||
@@ -57,0 +56,0 @@ } |
@@ -0,1 +1,24 @@ | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
(function (factory) { | ||
@@ -7,28 +30,45 @@ if (typeof module === "object" && typeof module.exports === "object") { | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports", "./BounceOutMode.js", "./DestroyOutMode.js", "./NoneOutMode.js", "./OutOutMode.js"], factory); | ||
define(["require", "exports"], factory); | ||
} | ||
})(function (require, exports) { | ||
"use strict"; | ||
var __syncRequire = typeof module === "object" && typeof module.exports === "object"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.OutOfCanvasUpdater = void 0; | ||
const BounceOutMode_js_1 = require("./BounceOutMode.js"); | ||
const DestroyOutMode_js_1 = require("./DestroyOutMode.js"); | ||
const NoneOutMode_js_1 = require("./NoneOutMode.js"); | ||
const OutOutMode_js_1 = require("./OutOutMode.js"); | ||
const checkOutMode = (outModes, outMode) => { | ||
return (outModes.default === outMode || | ||
outModes.bottom === outMode || | ||
outModes.left === outMode || | ||
outModes.right === outMode || | ||
outModes.top === outMode); | ||
}; | ||
class OutOfCanvasUpdater { | ||
constructor(container) { | ||
this._updateOutMode = (particle, delta, outMode, direction) => { | ||
this._updateOutMode = async (particle, delta, outMode, direction) => { | ||
for (const updater of this.updaters) { | ||
updater.update(particle, direction, delta, outMode); | ||
await updater.update(particle, direction, delta, outMode); | ||
} | ||
}; | ||
this.container = container; | ||
this.updaters = [ | ||
new BounceOutMode_js_1.BounceOutMode(container), | ||
new DestroyOutMode_js_1.DestroyOutMode(container), | ||
new OutOutMode_js_1.OutOutMode(container), | ||
new NoneOutMode_js_1.NoneOutMode(container), | ||
]; | ||
this.updaters = []; | ||
} | ||
init() { | ||
async init(particle) { | ||
this.updaters = []; | ||
const outModes = particle.options.move.outModes; | ||
if (checkOutMode(outModes, "bounce")) { | ||
const { BounceOutMode } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./BounceOutMode.js"))) : new Promise((resolve_1, reject_1) => { require(["./BounceOutMode.js"], resolve_1, reject_1); }).then(__importStar)); | ||
this.updaters.push(new BounceOutMode(this.container)); | ||
} | ||
else if (checkOutMode(outModes, "out")) { | ||
const { OutOutMode } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./OutOutMode.js"))) : new Promise((resolve_2, reject_2) => { require(["./OutOutMode.js"], resolve_2, reject_2); }).then(__importStar)); | ||
this.updaters.push(new OutOutMode(this.container)); | ||
} | ||
else if (checkOutMode(outModes, "destroy")) { | ||
const { DestroyOutMode } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./DestroyOutMode.js"))) : new Promise((resolve_3, reject_3) => { require(["./DestroyOutMode.js"], resolve_3, reject_3); }).then(__importStar)); | ||
this.updaters.push(new DestroyOutMode(this.container)); | ||
} | ||
else if (checkOutMode(outModes, "none")) { | ||
const { NoneOutMode } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./NoneOutMode.js"))) : new Promise((resolve_4, reject_4) => { require(["./NoneOutMode.js"], resolve_4, reject_4); }).then(__importStar)); | ||
this.updaters.push(new NoneOutMode(this.container)); | ||
} | ||
} | ||
@@ -38,8 +78,8 @@ isEnabled(particle) { | ||
} | ||
update(particle, delta) { | ||
async update(particle, delta) { | ||
const outModes = particle.options.move.outModes; | ||
this._updateOutMode(particle, delta, outModes.bottom ?? outModes.default, "bottom"); | ||
this._updateOutMode(particle, delta, outModes.left ?? outModes.default, "left"); | ||
this._updateOutMode(particle, delta, outModes.right ?? outModes.default, "right"); | ||
this._updateOutMode(particle, delta, outModes.top ?? outModes.default, "top"); | ||
await this._updateOutMode(particle, delta, outModes.bottom ?? outModes.default, "bottom"); | ||
await this._updateOutMode(particle, delta, outModes.left ?? outModes.default, "left"); | ||
await this._updateOutMode(particle, delta, outModes.right ?? outModes.default, "right"); | ||
await this._updateOutMode(particle, delta, outModes.top ?? outModes.default, "top"); | ||
} | ||
@@ -46,0 +86,0 @@ } |
@@ -20,3 +20,3 @@ (function (factory) { | ||
} | ||
update(particle, direction, delta, outMode) { | ||
async update(particle, direction, delta, outMode) { | ||
if (!this.modes.includes(outMode)) { | ||
@@ -123,2 +123,3 @@ return; | ||
} | ||
await Promise.resolve(); | ||
} | ||
@@ -125,0 +126,0 @@ } |
@@ -16,6 +16,3 @@ (function (factory) { | ||
function bounceHorizontal(data) { | ||
if ((data.outMode !== "bounce" && | ||
data.outMode !== "bounce-horizontal" && | ||
data.outMode !== "bounceHorizontal" && | ||
data.outMode !== "split") || | ||
if ((data.outMode !== "bounce" && data.outMode !== "split") || | ||
(data.direction !== "left" && data.direction !== "right")) { | ||
@@ -56,6 +53,3 @@ return; | ||
function bounceVertical(data) { | ||
if ((data.outMode !== "bounce" && | ||
data.outMode !== "bounce-vertical" && | ||
data.outMode !== "bounceVertical" && | ||
data.outMode !== "split") || | ||
if ((data.outMode !== "bounce" && data.outMode !== "split") || | ||
(data.direction !== "bottom" && data.direction !== "top")) { | ||
@@ -62,0 +56,0 @@ return; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
415646
73
2278
1
6
3
Updated@tsparticles/engine@^3.2.0