@tsparticles/updater-out-modes
Advanced tools
Comparing version 3.3.0 to 3.4.0
@@ -1,2 +0,2 @@ | ||
import { calculateBounds, } from "@tsparticles/engine"; | ||
import { OutMode, calculateBounds, } from "@tsparticles/engine"; | ||
import { bounceHorizontal, bounceVertical } from "./Utils.js"; | ||
@@ -7,4 +7,4 @@ export class BounceOutMode { | ||
this.modes = [ | ||
"bounce", | ||
"split", | ||
OutMode.bounce, | ||
OutMode.split, | ||
]; | ||
@@ -11,0 +11,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { Vector, getDistances, isPointInside, } from "@tsparticles/engine"; | ||
import { OutMode, ParticleOutType, Vector, getDistances, isPointInside, } from "@tsparticles/engine"; | ||
const minVelocity = 0; | ||
@@ -6,3 +6,3 @@ export class DestroyOutMode { | ||
this.container = container; | ||
this.modes = ["destroy"]; | ||
this.modes = [OutMode.destroy]; | ||
} | ||
@@ -15,4 +15,4 @@ update(particle, direction, _delta, outMode) { | ||
switch (particle.outType) { | ||
case "normal": | ||
case "outside": | ||
case ParticleOutType.normal: | ||
case ParticleOutType.outside: | ||
if (isPointInside(particle.position, container.canvas.size, Vector.origin, particle.getRadius(), direction)) { | ||
@@ -22,3 +22,3 @@ return; | ||
break; | ||
case "inside": { | ||
case ParticleOutType.inside: { | ||
const { dx, dy } = getDistances(particle.position, particle.moveCenter), { x: vx, y: vy } = particle.velocity; | ||
@@ -25,0 +25,0 @@ if ((vx < minVelocity && dx > particle.moveCenter.radius) || |
@@ -0,6 +1,6 @@ | ||
import { OutOfCanvasUpdater } from "./OutOfCanvasUpdater.js"; | ||
export async function loadOutModesUpdater(engine, refresh = true) { | ||
await engine.addParticleUpdater("outModes", async (container) => { | ||
const { OutOfCanvasUpdater } = await import("./OutOfCanvasUpdater.js"); | ||
return new OutOfCanvasUpdater(container); | ||
await engine.addParticleUpdater("outModes", container => { | ||
return Promise.resolve(new OutOfCanvasUpdater(container)); | ||
}, refresh); | ||
} |
@@ -1,2 +0,2 @@ | ||
import { Vector, isPointInside, } from "@tsparticles/engine"; | ||
import { OutMode, OutModeDirection, Vector, isPointInside, } from "@tsparticles/engine"; | ||
const minVelocity = 0; | ||
@@ -6,3 +6,3 @@ export class NoneOutMode { | ||
this.container = container; | ||
this.modes = ["none"]; | ||
this.modes = [OutMode.none]; | ||
} | ||
@@ -14,5 +14,5 @@ update(particle, direction, delta, outMode) { | ||
if ((particle.options.move.distance.horizontal && | ||
(direction === "left" || direction === "right")) ?? | ||
(direction === OutModeDirection.left || direction === OutModeDirection.right)) ?? | ||
(particle.options.move.distance.vertical && | ||
(direction === "top" || direction === "bottom"))) { | ||
(direction === OutModeDirection.top || direction === OutModeDirection.bottom))) { | ||
return; | ||
@@ -36,4 +36,4 @@ } | ||
position.y > canvasSize.height + pRadius && | ||
direction === "bottom") || | ||
(gravityOptions.inverse && position.y < -pRadius && direction === "top")) { | ||
direction === OutModeDirection.bottom) || | ||
(gravityOptions.inverse && position.y < -pRadius && direction === OutModeDirection.top)) { | ||
container.particles.remove(particle); | ||
@@ -40,0 +40,0 @@ } |
@@ -0,1 +1,2 @@ | ||
import { OutMode, OutModeDirection, } from "@tsparticles/engine"; | ||
import { BounceOutMode } from "./BounceOutMode.js"; | ||
@@ -25,12 +26,12 @@ import { DestroyOutMode } from "./DestroyOutMode.js"; | ||
const outModes = particle.options.move.outModes; | ||
if (checkOutMode(outModes, "bounce")) { | ||
if (checkOutMode(outModes, OutMode.bounce)) { | ||
this.updaters.push(new BounceOutMode(this.container)); | ||
} | ||
else if (checkOutMode(outModes, "out")) { | ||
else if (checkOutMode(outModes, OutMode.out)) { | ||
this.updaters.push(new OutOutMode(this.container)); | ||
} | ||
else if (checkOutMode(outModes, "destroy")) { | ||
else if (checkOutMode(outModes, OutMode.destroy)) { | ||
this.updaters.push(new DestroyOutMode(this.container)); | ||
} | ||
else if (checkOutMode(outModes, "none")) { | ||
else if (checkOutMode(outModes, OutMode.none)) { | ||
this.updaters.push(new NoneOutMode(this.container)); | ||
@@ -44,7 +45,7 @@ } | ||
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"); | ||
this._updateOutMode(particle, delta, outModes.bottom ?? outModes.default, OutModeDirection.bottom); | ||
this._updateOutMode(particle, delta, outModes.left ?? outModes.default, OutModeDirection.left); | ||
this._updateOutMode(particle, delta, outModes.right ?? outModes.default, OutModeDirection.right); | ||
this._updateOutMode(particle, delta, outModes.top ?? outModes.default, OutModeDirection.top); | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import { Vector, calculateBounds, getDistances, getRandom, isPointInside, randomInRange, } from "@tsparticles/engine"; | ||
import { OutMode, OutModeDirection, ParticleOutType, Vector, calculateBounds, getDistances, getRandom, isPointInside, randomInRange, } from "@tsparticles/engine"; | ||
const minVelocity = 0, minDistance = 0; | ||
@@ -6,3 +6,3 @@ export class OutOutMode { | ||
this.container = container; | ||
this.modes = ["out"]; | ||
this.modes = [OutMode.out]; | ||
} | ||
@@ -15,3 +15,3 @@ update(particle, direction, delta, outMode) { | ||
switch (particle.outType) { | ||
case "inside": { | ||
case ParticleOutType.inside: { | ||
const { x: vx, y: vy } = particle.velocity; | ||
@@ -47,3 +47,3 @@ const circVec = Vector.origin; | ||
switch (particle.outType) { | ||
case "outside": { | ||
case ParticleOutType.outside: { | ||
particle.position.x = | ||
@@ -66,3 +66,3 @@ Math.floor(randomInRange({ | ||
} | ||
case "normal": { | ||
case ParticleOutType.normal: { | ||
const warp = particle.options.move.warp, canvasSize = container.canvas.size, newPos = { | ||
@@ -74,3 +74,3 @@ bottom: canvasSize.height + particle.getRadius() + particle.offset.y, | ||
}, sizeValue = particle.getRadius(), nextBounds = calculateBounds(particle.position, sizeValue); | ||
if (direction === "right" && | ||
if (direction === OutModeDirection.right && | ||
nextBounds.left > canvasSize.width + particle.offset.x) { | ||
@@ -84,3 +84,3 @@ particle.position.x = newPos.left; | ||
} | ||
else if (direction === "left" && nextBounds.right < -particle.offset.x) { | ||
else if (direction === OutModeDirection.left && nextBounds.right < -particle.offset.x) { | ||
particle.position.x = newPos.right; | ||
@@ -93,3 +93,3 @@ particle.initialPosition.x = particle.position.x; | ||
} | ||
if (direction === "bottom" && | ||
if (direction === OutModeDirection.bottom && | ||
nextBounds.top > canvasSize.height + particle.offset.y) { | ||
@@ -103,3 +103,3 @@ if (!warp) { | ||
} | ||
else if (direction === "top" && nextBounds.bottom < -particle.offset.y) { | ||
else if (direction === OutModeDirection.top && nextBounds.bottom < -particle.offset.y) { | ||
if (!warp) { | ||
@@ -106,0 +106,0 @@ particle.position.x = getRandom() * canvasSize.width; |
@@ -1,12 +0,12 @@ | ||
import { getRangeValue } from "@tsparticles/engine"; | ||
import { OutMode, OutModeDirection, getRangeValue } from "@tsparticles/engine"; | ||
const minVelocity = 0, boundsMin = 0; | ||
export function bounceHorizontal(data) { | ||
if ((data.outMode !== "bounce" && data.outMode !== "split") || | ||
(data.direction !== "left" && data.direction !== "right")) { | ||
if ((data.outMode !== OutMode.bounce && data.outMode !== OutMode.split) || | ||
(data.direction !== OutModeDirection.left && data.direction !== OutModeDirection.right)) { | ||
return; | ||
} | ||
if (data.bounds.right < boundsMin && data.direction === "left") { | ||
if (data.bounds.right < boundsMin && data.direction === OutModeDirection.left) { | ||
data.particle.position.x = data.size + data.offset.x; | ||
} | ||
else if (data.bounds.left > data.canvasSize.width && data.direction === "right") { | ||
else if (data.bounds.left > data.canvasSize.width && data.direction === OutModeDirection.right) { | ||
data.particle.position.x = data.canvasSize.width - data.size - data.offset.x; | ||
@@ -16,6 +16,6 @@ } | ||
let bounced = false; | ||
if ((data.direction === "right" && | ||
if ((data.direction === OutModeDirection.right && | ||
data.bounds.right >= data.canvasSize.width && | ||
velocity > minVelocity) || | ||
(data.direction === "left" && data.bounds.left <= boundsMin && velocity < minVelocity)) { | ||
(data.direction === OutModeDirection.left && data.bounds.left <= boundsMin && velocity < minVelocity)) { | ||
const newVelocity = getRangeValue(data.particle.options.bounce.horizontal.value); | ||
@@ -29,9 +29,9 @@ data.particle.velocity.x *= -newVelocity; | ||
const minPos = data.offset.x + data.size; | ||
if (data.bounds.right >= data.canvasSize.width && data.direction === "right") { | ||
if (data.bounds.right >= data.canvasSize.width && data.direction === OutModeDirection.right) { | ||
data.particle.position.x = data.canvasSize.width - minPos; | ||
} | ||
else if (data.bounds.left <= boundsMin && data.direction === "left") { | ||
else if (data.bounds.left <= boundsMin && data.direction === OutModeDirection.left) { | ||
data.particle.position.x = minPos; | ||
} | ||
if (data.outMode === "split") { | ||
if (data.outMode === OutMode.split) { | ||
data.particle.destroy(); | ||
@@ -41,10 +41,10 @@ } | ||
export function bounceVertical(data) { | ||
if ((data.outMode !== "bounce" && data.outMode !== "split") || | ||
(data.direction !== "bottom" && data.direction !== "top")) { | ||
if ((data.outMode !== OutMode.bounce && data.outMode !== OutMode.split) || | ||
(data.direction !== OutModeDirection.bottom && data.direction !== OutModeDirection.top)) { | ||
return; | ||
} | ||
if (data.bounds.bottom < boundsMin && data.direction === "top") { | ||
if (data.bounds.bottom < boundsMin && data.direction === OutModeDirection.top) { | ||
data.particle.position.y = data.size + data.offset.y; | ||
} | ||
else if (data.bounds.top > data.canvasSize.height && data.direction === "bottom") { | ||
else if (data.bounds.top > data.canvasSize.height && data.direction === OutModeDirection.bottom) { | ||
data.particle.position.y = data.canvasSize.height - data.size - data.offset.y; | ||
@@ -54,6 +54,6 @@ } | ||
let bounced = false; | ||
if ((data.direction === "bottom" && | ||
if ((data.direction === OutModeDirection.bottom && | ||
data.bounds.bottom >= data.canvasSize.height && | ||
velocity > minVelocity) || | ||
(data.direction === "top" && data.bounds.top <= boundsMin && velocity < minVelocity)) { | ||
(data.direction === OutModeDirection.top && data.bounds.top <= boundsMin && velocity < minVelocity)) { | ||
const newVelocity = getRangeValue(data.particle.options.bounce.vertical.value); | ||
@@ -67,11 +67,11 @@ data.particle.velocity.y *= -newVelocity; | ||
const minPos = data.offset.y + data.size; | ||
if (data.bounds.bottom >= data.canvasSize.height && data.direction === "bottom") { | ||
if (data.bounds.bottom >= data.canvasSize.height && data.direction === OutModeDirection.bottom) { | ||
data.particle.position.y = data.canvasSize.height - minPos; | ||
} | ||
else if (data.bounds.top <= boundsMin && data.direction === "top") { | ||
else if (data.bounds.top <= boundsMin && data.direction === OutModeDirection.top) { | ||
data.particle.position.y = minPos; | ||
} | ||
if (data.outMode === "split") { | ||
if (data.outMode === OutMode.split) { | ||
data.particle.destroy(); | ||
} | ||
} |
@@ -10,4 +10,4 @@ "use strict"; | ||
this.modes = [ | ||
"bounce", | ||
"split", | ||
engine_1.OutMode.bounce, | ||
engine_1.OutMode.split, | ||
]; | ||
@@ -14,0 +14,0 @@ } |
@@ -9,3 +9,3 @@ "use strict"; | ||
this.container = container; | ||
this.modes = ["destroy"]; | ||
this.modes = [engine_1.OutMode.destroy]; | ||
} | ||
@@ -18,4 +18,4 @@ update(particle, direction, _delta, outMode) { | ||
switch (particle.outType) { | ||
case "normal": | ||
case "outside": | ||
case engine_1.ParticleOutType.normal: | ||
case engine_1.ParticleOutType.outside: | ||
if ((0, engine_1.isPointInside)(particle.position, container.canvas.size, engine_1.Vector.origin, particle.getRadius(), direction)) { | ||
@@ -25,3 +25,3 @@ return; | ||
break; | ||
case "inside": { | ||
case engine_1.ParticleOutType.inside: { | ||
const { dx, dy } = (0, engine_1.getDistances)(particle.position, particle.moveCenter), { x: vx, y: vy } = particle.velocity; | ||
@@ -28,0 +28,0 @@ if ((vx < minVelocity && dx > particle.moveCenter.radius) || |
"use strict"; | ||
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", async (container) => { | ||
const { OutOfCanvasUpdater } = await import("./OutOfCanvasUpdater.js"); | ||
return new OutOfCanvasUpdater(container); | ||
await engine.addParticleUpdater("outModes", container => { | ||
return Promise.resolve(new OutOfCanvasUpdater_js_1.OutOfCanvasUpdater(container)); | ||
}, refresh); | ||
} | ||
exports.loadOutModesUpdater = loadOutModesUpdater; |
@@ -9,3 +9,3 @@ "use strict"; | ||
this.container = container; | ||
this.modes = ["none"]; | ||
this.modes = [engine_1.OutMode.none]; | ||
} | ||
@@ -17,5 +17,5 @@ update(particle, direction, delta, outMode) { | ||
if ((particle.options.move.distance.horizontal && | ||
(direction === "left" || direction === "right")) ?? | ||
(direction === engine_1.OutModeDirection.left || direction === engine_1.OutModeDirection.right)) ?? | ||
(particle.options.move.distance.vertical && | ||
(direction === "top" || direction === "bottom"))) { | ||
(direction === engine_1.OutModeDirection.top || direction === engine_1.OutModeDirection.bottom))) { | ||
return; | ||
@@ -39,4 +39,4 @@ } | ||
position.y > canvasSize.height + pRadius && | ||
direction === "bottom") || | ||
(gravityOptions.inverse && position.y < -pRadius && direction === "top")) { | ||
direction === engine_1.OutModeDirection.bottom) || | ||
(gravityOptions.inverse && position.y < -pRadius && direction === engine_1.OutModeDirection.top)) { | ||
container.particles.remove(particle); | ||
@@ -43,0 +43,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.OutOfCanvasUpdater = void 0; | ||
const engine_1 = require("@tsparticles/engine"); | ||
const BounceOutMode_js_1 = require("./BounceOutMode.js"); | ||
@@ -28,12 +29,12 @@ const DestroyOutMode_js_1 = require("./DestroyOutMode.js"); | ||
const outModes = particle.options.move.outModes; | ||
if (checkOutMode(outModes, "bounce")) { | ||
if (checkOutMode(outModes, engine_1.OutMode.bounce)) { | ||
this.updaters.push(new BounceOutMode_js_1.BounceOutMode(this.container)); | ||
} | ||
else if (checkOutMode(outModes, "out")) { | ||
else if (checkOutMode(outModes, engine_1.OutMode.out)) { | ||
this.updaters.push(new OutOutMode_js_1.OutOutMode(this.container)); | ||
} | ||
else if (checkOutMode(outModes, "destroy")) { | ||
else if (checkOutMode(outModes, engine_1.OutMode.destroy)) { | ||
this.updaters.push(new DestroyOutMode_js_1.DestroyOutMode(this.container)); | ||
} | ||
else if (checkOutMode(outModes, "none")) { | ||
else if (checkOutMode(outModes, engine_1.OutMode.none)) { | ||
this.updaters.push(new NoneOutMode_js_1.NoneOutMode(this.container)); | ||
@@ -47,8 +48,8 @@ } | ||
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"); | ||
this._updateOutMode(particle, delta, outModes.bottom ?? outModes.default, engine_1.OutModeDirection.bottom); | ||
this._updateOutMode(particle, delta, outModes.left ?? outModes.default, engine_1.OutModeDirection.left); | ||
this._updateOutMode(particle, delta, outModes.right ?? outModes.default, engine_1.OutModeDirection.right); | ||
this._updateOutMode(particle, delta, outModes.top ?? outModes.default, engine_1.OutModeDirection.top); | ||
} | ||
} | ||
exports.OutOfCanvasUpdater = OutOfCanvasUpdater; |
@@ -9,3 +9,3 @@ "use strict"; | ||
this.container = container; | ||
this.modes = ["out"]; | ||
this.modes = [engine_1.OutMode.out]; | ||
} | ||
@@ -18,3 +18,3 @@ update(particle, direction, delta, outMode) { | ||
switch (particle.outType) { | ||
case "inside": { | ||
case engine_1.ParticleOutType.inside: { | ||
const { x: vx, y: vy } = particle.velocity; | ||
@@ -50,3 +50,3 @@ const circVec = engine_1.Vector.origin; | ||
switch (particle.outType) { | ||
case "outside": { | ||
case engine_1.ParticleOutType.outside: { | ||
particle.position.x = | ||
@@ -69,3 +69,3 @@ Math.floor((0, engine_1.randomInRange)({ | ||
} | ||
case "normal": { | ||
case engine_1.ParticleOutType.normal: { | ||
const warp = particle.options.move.warp, canvasSize = container.canvas.size, newPos = { | ||
@@ -77,3 +77,3 @@ bottom: canvasSize.height + particle.getRadius() + particle.offset.y, | ||
}, sizeValue = particle.getRadius(), nextBounds = (0, engine_1.calculateBounds)(particle.position, sizeValue); | ||
if (direction === "right" && | ||
if (direction === engine_1.OutModeDirection.right && | ||
nextBounds.left > canvasSize.width + particle.offset.x) { | ||
@@ -87,3 +87,3 @@ particle.position.x = newPos.left; | ||
} | ||
else if (direction === "left" && nextBounds.right < -particle.offset.x) { | ||
else if (direction === engine_1.OutModeDirection.left && nextBounds.right < -particle.offset.x) { | ||
particle.position.x = newPos.right; | ||
@@ -96,3 +96,3 @@ particle.initialPosition.x = particle.position.x; | ||
} | ||
if (direction === "bottom" && | ||
if (direction === engine_1.OutModeDirection.bottom && | ||
nextBounds.top > canvasSize.height + particle.offset.y) { | ||
@@ -106,3 +106,3 @@ if (!warp) { | ||
} | ||
else if (direction === "top" && nextBounds.bottom < -particle.offset.y) { | ||
else if (direction === engine_1.OutModeDirection.top && nextBounds.bottom < -particle.offset.y) { | ||
if (!warp) { | ||
@@ -109,0 +109,0 @@ particle.position.x = (0, engine_1.getRandom)() * canvasSize.width; |
@@ -7,10 +7,10 @@ "use strict"; | ||
function bounceHorizontal(data) { | ||
if ((data.outMode !== "bounce" && data.outMode !== "split") || | ||
(data.direction !== "left" && data.direction !== "right")) { | ||
if ((data.outMode !== engine_1.OutMode.bounce && data.outMode !== engine_1.OutMode.split) || | ||
(data.direction !== engine_1.OutModeDirection.left && data.direction !== engine_1.OutModeDirection.right)) { | ||
return; | ||
} | ||
if (data.bounds.right < boundsMin && data.direction === "left") { | ||
if (data.bounds.right < boundsMin && data.direction === engine_1.OutModeDirection.left) { | ||
data.particle.position.x = data.size + data.offset.x; | ||
} | ||
else if (data.bounds.left > data.canvasSize.width && data.direction === "right") { | ||
else if (data.bounds.left > data.canvasSize.width && data.direction === engine_1.OutModeDirection.right) { | ||
data.particle.position.x = data.canvasSize.width - data.size - data.offset.x; | ||
@@ -20,6 +20,6 @@ } | ||
let bounced = false; | ||
if ((data.direction === "right" && | ||
if ((data.direction === engine_1.OutModeDirection.right && | ||
data.bounds.right >= data.canvasSize.width && | ||
velocity > minVelocity) || | ||
(data.direction === "left" && data.bounds.left <= boundsMin && velocity < minVelocity)) { | ||
(data.direction === engine_1.OutModeDirection.left && data.bounds.left <= boundsMin && velocity < minVelocity)) { | ||
const newVelocity = (0, engine_1.getRangeValue)(data.particle.options.bounce.horizontal.value); | ||
@@ -33,9 +33,9 @@ data.particle.velocity.x *= -newVelocity; | ||
const minPos = data.offset.x + data.size; | ||
if (data.bounds.right >= data.canvasSize.width && data.direction === "right") { | ||
if (data.bounds.right >= data.canvasSize.width && data.direction === engine_1.OutModeDirection.right) { | ||
data.particle.position.x = data.canvasSize.width - minPos; | ||
} | ||
else if (data.bounds.left <= boundsMin && data.direction === "left") { | ||
else if (data.bounds.left <= boundsMin && data.direction === engine_1.OutModeDirection.left) { | ||
data.particle.position.x = minPos; | ||
} | ||
if (data.outMode === "split") { | ||
if (data.outMode === engine_1.OutMode.split) { | ||
data.particle.destroy(); | ||
@@ -46,10 +46,10 @@ } | ||
function bounceVertical(data) { | ||
if ((data.outMode !== "bounce" && data.outMode !== "split") || | ||
(data.direction !== "bottom" && data.direction !== "top")) { | ||
if ((data.outMode !== engine_1.OutMode.bounce && data.outMode !== engine_1.OutMode.split) || | ||
(data.direction !== engine_1.OutModeDirection.bottom && data.direction !== engine_1.OutModeDirection.top)) { | ||
return; | ||
} | ||
if (data.bounds.bottom < boundsMin && data.direction === "top") { | ||
if (data.bounds.bottom < boundsMin && data.direction === engine_1.OutModeDirection.top) { | ||
data.particle.position.y = data.size + data.offset.y; | ||
} | ||
else if (data.bounds.top > data.canvasSize.height && data.direction === "bottom") { | ||
else if (data.bounds.top > data.canvasSize.height && data.direction === engine_1.OutModeDirection.bottom) { | ||
data.particle.position.y = data.canvasSize.height - data.size - data.offset.y; | ||
@@ -59,6 +59,6 @@ } | ||
let bounced = false; | ||
if ((data.direction === "bottom" && | ||
if ((data.direction === engine_1.OutModeDirection.bottom && | ||
data.bounds.bottom >= data.canvasSize.height && | ||
velocity > minVelocity) || | ||
(data.direction === "top" && data.bounds.top <= boundsMin && velocity < minVelocity)) { | ||
(data.direction === engine_1.OutModeDirection.top && data.bounds.top <= boundsMin && velocity < minVelocity)) { | ||
const newVelocity = (0, engine_1.getRangeValue)(data.particle.options.bounce.vertical.value); | ||
@@ -72,9 +72,9 @@ data.particle.velocity.y *= -newVelocity; | ||
const minPos = data.offset.y + data.size; | ||
if (data.bounds.bottom >= data.canvasSize.height && data.direction === "bottom") { | ||
if (data.bounds.bottom >= data.canvasSize.height && data.direction === engine_1.OutModeDirection.bottom) { | ||
data.particle.position.y = data.canvasSize.height - minPos; | ||
} | ||
else if (data.bounds.top <= boundsMin && data.direction === "top") { | ||
else if (data.bounds.top <= boundsMin && data.direction === engine_1.OutModeDirection.top) { | ||
data.particle.position.y = minPos; | ||
} | ||
if (data.outMode === "split") { | ||
if (data.outMode === engine_1.OutMode.split) { | ||
data.particle.destroy(); | ||
@@ -81,0 +81,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { calculateBounds, } from "@tsparticles/engine"; | ||
import { OutMode, calculateBounds, } from "@tsparticles/engine"; | ||
import { bounceHorizontal, bounceVertical } from "./Utils.js"; | ||
@@ -7,4 +7,4 @@ export class BounceOutMode { | ||
this.modes = [ | ||
"bounce", | ||
"split", | ||
OutMode.bounce, | ||
OutMode.split, | ||
]; | ||
@@ -11,0 +11,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { Vector, getDistances, isPointInside, } from "@tsparticles/engine"; | ||
import { OutMode, ParticleOutType, Vector, getDistances, isPointInside, } from "@tsparticles/engine"; | ||
const minVelocity = 0; | ||
@@ -6,3 +6,3 @@ export class DestroyOutMode { | ||
this.container = container; | ||
this.modes = ["destroy"]; | ||
this.modes = [OutMode.destroy]; | ||
} | ||
@@ -15,4 +15,4 @@ update(particle, direction, _delta, outMode) { | ||
switch (particle.outType) { | ||
case "normal": | ||
case "outside": | ||
case ParticleOutType.normal: | ||
case ParticleOutType.outside: | ||
if (isPointInside(particle.position, container.canvas.size, Vector.origin, particle.getRadius(), direction)) { | ||
@@ -22,3 +22,3 @@ return; | ||
break; | ||
case "inside": { | ||
case ParticleOutType.inside: { | ||
const { dx, dy } = getDistances(particle.position, particle.moveCenter), { x: vx, y: vy } = particle.velocity; | ||
@@ -25,0 +25,0 @@ if ((vx < minVelocity && dx > particle.moveCenter.radius) || |
@@ -0,6 +1,6 @@ | ||
import { OutOfCanvasUpdater } from "./OutOfCanvasUpdater.js"; | ||
export async function loadOutModesUpdater(engine, refresh = true) { | ||
await engine.addParticleUpdater("outModes", async (container) => { | ||
const { OutOfCanvasUpdater } = await import("./OutOfCanvasUpdater.js"); | ||
return new OutOfCanvasUpdater(container); | ||
await engine.addParticleUpdater("outModes", container => { | ||
return Promise.resolve(new OutOfCanvasUpdater(container)); | ||
}, refresh); | ||
} |
@@ -1,2 +0,2 @@ | ||
import { Vector, isPointInside, } from "@tsparticles/engine"; | ||
import { OutMode, OutModeDirection, Vector, isPointInside, } from "@tsparticles/engine"; | ||
const minVelocity = 0; | ||
@@ -6,3 +6,3 @@ export class NoneOutMode { | ||
this.container = container; | ||
this.modes = ["none"]; | ||
this.modes = [OutMode.none]; | ||
} | ||
@@ -14,5 +14,5 @@ update(particle, direction, delta, outMode) { | ||
if ((particle.options.move.distance.horizontal && | ||
(direction === "left" || direction === "right")) ?? | ||
(direction === OutModeDirection.left || direction === OutModeDirection.right)) ?? | ||
(particle.options.move.distance.vertical && | ||
(direction === "top" || direction === "bottom"))) { | ||
(direction === OutModeDirection.top || direction === OutModeDirection.bottom))) { | ||
return; | ||
@@ -36,4 +36,4 @@ } | ||
position.y > canvasSize.height + pRadius && | ||
direction === "bottom") || | ||
(gravityOptions.inverse && position.y < -pRadius && direction === "top")) { | ||
direction === OutModeDirection.bottom) || | ||
(gravityOptions.inverse && position.y < -pRadius && direction === OutModeDirection.top)) { | ||
container.particles.remove(particle); | ||
@@ -40,0 +40,0 @@ } |
@@ -0,1 +1,2 @@ | ||
import { OutMode, OutModeDirection, } from "@tsparticles/engine"; | ||
import { BounceOutMode } from "./BounceOutMode.js"; | ||
@@ -25,12 +26,12 @@ import { DestroyOutMode } from "./DestroyOutMode.js"; | ||
const outModes = particle.options.move.outModes; | ||
if (checkOutMode(outModes, "bounce")) { | ||
if (checkOutMode(outModes, OutMode.bounce)) { | ||
this.updaters.push(new BounceOutMode(this.container)); | ||
} | ||
else if (checkOutMode(outModes, "out")) { | ||
else if (checkOutMode(outModes, OutMode.out)) { | ||
this.updaters.push(new OutOutMode(this.container)); | ||
} | ||
else if (checkOutMode(outModes, "destroy")) { | ||
else if (checkOutMode(outModes, OutMode.destroy)) { | ||
this.updaters.push(new DestroyOutMode(this.container)); | ||
} | ||
else if (checkOutMode(outModes, "none")) { | ||
else if (checkOutMode(outModes, OutMode.none)) { | ||
this.updaters.push(new NoneOutMode(this.container)); | ||
@@ -44,7 +45,7 @@ } | ||
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"); | ||
this._updateOutMode(particle, delta, outModes.bottom ?? outModes.default, OutModeDirection.bottom); | ||
this._updateOutMode(particle, delta, outModes.left ?? outModes.default, OutModeDirection.left); | ||
this._updateOutMode(particle, delta, outModes.right ?? outModes.default, OutModeDirection.right); | ||
this._updateOutMode(particle, delta, outModes.top ?? outModes.default, OutModeDirection.top); | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import { Vector, calculateBounds, getDistances, getRandom, isPointInside, randomInRange, } from "@tsparticles/engine"; | ||
import { OutMode, OutModeDirection, ParticleOutType, Vector, calculateBounds, getDistances, getRandom, isPointInside, randomInRange, } from "@tsparticles/engine"; | ||
const minVelocity = 0, minDistance = 0; | ||
@@ -6,3 +6,3 @@ export class OutOutMode { | ||
this.container = container; | ||
this.modes = ["out"]; | ||
this.modes = [OutMode.out]; | ||
} | ||
@@ -15,3 +15,3 @@ update(particle, direction, delta, outMode) { | ||
switch (particle.outType) { | ||
case "inside": { | ||
case ParticleOutType.inside: { | ||
const { x: vx, y: vy } = particle.velocity; | ||
@@ -47,3 +47,3 @@ const circVec = Vector.origin; | ||
switch (particle.outType) { | ||
case "outside": { | ||
case ParticleOutType.outside: { | ||
particle.position.x = | ||
@@ -66,3 +66,3 @@ Math.floor(randomInRange({ | ||
} | ||
case "normal": { | ||
case ParticleOutType.normal: { | ||
const warp = particle.options.move.warp, canvasSize = container.canvas.size, newPos = { | ||
@@ -74,3 +74,3 @@ bottom: canvasSize.height + particle.getRadius() + particle.offset.y, | ||
}, sizeValue = particle.getRadius(), nextBounds = calculateBounds(particle.position, sizeValue); | ||
if (direction === "right" && | ||
if (direction === OutModeDirection.right && | ||
nextBounds.left > canvasSize.width + particle.offset.x) { | ||
@@ -84,3 +84,3 @@ particle.position.x = newPos.left; | ||
} | ||
else if (direction === "left" && nextBounds.right < -particle.offset.x) { | ||
else if (direction === OutModeDirection.left && nextBounds.right < -particle.offset.x) { | ||
particle.position.x = newPos.right; | ||
@@ -93,3 +93,3 @@ particle.initialPosition.x = particle.position.x; | ||
} | ||
if (direction === "bottom" && | ||
if (direction === OutModeDirection.bottom && | ||
nextBounds.top > canvasSize.height + particle.offset.y) { | ||
@@ -103,3 +103,3 @@ if (!warp) { | ||
} | ||
else if (direction === "top" && nextBounds.bottom < -particle.offset.y) { | ||
else if (direction === OutModeDirection.top && nextBounds.bottom < -particle.offset.y) { | ||
if (!warp) { | ||
@@ -106,0 +106,0 @@ particle.position.x = getRandom() * canvasSize.width; |
@@ -1,12 +0,12 @@ | ||
import { getRangeValue } from "@tsparticles/engine"; | ||
import { OutMode, OutModeDirection, getRangeValue } from "@tsparticles/engine"; | ||
const minVelocity = 0, boundsMin = 0; | ||
export function bounceHorizontal(data) { | ||
if ((data.outMode !== "bounce" && data.outMode !== "split") || | ||
(data.direction !== "left" && data.direction !== "right")) { | ||
if ((data.outMode !== OutMode.bounce && data.outMode !== OutMode.split) || | ||
(data.direction !== OutModeDirection.left && data.direction !== OutModeDirection.right)) { | ||
return; | ||
} | ||
if (data.bounds.right < boundsMin && data.direction === "left") { | ||
if (data.bounds.right < boundsMin && data.direction === OutModeDirection.left) { | ||
data.particle.position.x = data.size + data.offset.x; | ||
} | ||
else if (data.bounds.left > data.canvasSize.width && data.direction === "right") { | ||
else if (data.bounds.left > data.canvasSize.width && data.direction === OutModeDirection.right) { | ||
data.particle.position.x = data.canvasSize.width - data.size - data.offset.x; | ||
@@ -16,6 +16,6 @@ } | ||
let bounced = false; | ||
if ((data.direction === "right" && | ||
if ((data.direction === OutModeDirection.right && | ||
data.bounds.right >= data.canvasSize.width && | ||
velocity > minVelocity) || | ||
(data.direction === "left" && data.bounds.left <= boundsMin && velocity < minVelocity)) { | ||
(data.direction === OutModeDirection.left && data.bounds.left <= boundsMin && velocity < minVelocity)) { | ||
const newVelocity = getRangeValue(data.particle.options.bounce.horizontal.value); | ||
@@ -29,9 +29,9 @@ data.particle.velocity.x *= -newVelocity; | ||
const minPos = data.offset.x + data.size; | ||
if (data.bounds.right >= data.canvasSize.width && data.direction === "right") { | ||
if (data.bounds.right >= data.canvasSize.width && data.direction === OutModeDirection.right) { | ||
data.particle.position.x = data.canvasSize.width - minPos; | ||
} | ||
else if (data.bounds.left <= boundsMin && data.direction === "left") { | ||
else if (data.bounds.left <= boundsMin && data.direction === OutModeDirection.left) { | ||
data.particle.position.x = minPos; | ||
} | ||
if (data.outMode === "split") { | ||
if (data.outMode === OutMode.split) { | ||
data.particle.destroy(); | ||
@@ -41,10 +41,10 @@ } | ||
export function bounceVertical(data) { | ||
if ((data.outMode !== "bounce" && data.outMode !== "split") || | ||
(data.direction !== "bottom" && data.direction !== "top")) { | ||
if ((data.outMode !== OutMode.bounce && data.outMode !== OutMode.split) || | ||
(data.direction !== OutModeDirection.bottom && data.direction !== OutModeDirection.top)) { | ||
return; | ||
} | ||
if (data.bounds.bottom < boundsMin && data.direction === "top") { | ||
if (data.bounds.bottom < boundsMin && data.direction === OutModeDirection.top) { | ||
data.particle.position.y = data.size + data.offset.y; | ||
} | ||
else if (data.bounds.top > data.canvasSize.height && data.direction === "bottom") { | ||
else if (data.bounds.top > data.canvasSize.height && data.direction === OutModeDirection.bottom) { | ||
data.particle.position.y = data.canvasSize.height - data.size - data.offset.y; | ||
@@ -54,6 +54,6 @@ } | ||
let bounced = false; | ||
if ((data.direction === "bottom" && | ||
if ((data.direction === OutModeDirection.bottom && | ||
data.bounds.bottom >= data.canvasSize.height && | ||
velocity > minVelocity) || | ||
(data.direction === "top" && data.bounds.top <= boundsMin && velocity < minVelocity)) { | ||
(data.direction === OutModeDirection.top && data.bounds.top <= boundsMin && velocity < minVelocity)) { | ||
const newVelocity = getRangeValue(data.particle.options.bounce.vertical.value); | ||
@@ -67,11 +67,11 @@ data.particle.velocity.y *= -newVelocity; | ||
const minPos = data.offset.y + data.size; | ||
if (data.bounds.bottom >= data.canvasSize.height && data.direction === "bottom") { | ||
if (data.bounds.bottom >= data.canvasSize.height && data.direction === OutModeDirection.bottom) { | ||
data.particle.position.y = data.canvasSize.height - minPos; | ||
} | ||
else if (data.bounds.top <= boundsMin && data.direction === "top") { | ||
else if (data.bounds.top <= boundsMin && data.direction === OutModeDirection.top) { | ||
data.particle.position.y = minPos; | ||
} | ||
if (data.outMode === "split") { | ||
if (data.outMode === OutMode.split) { | ||
data.particle.destroy(); | ||
} | ||
} |
{ | ||
"name": "@tsparticles/updater-out-modes", | ||
"version": "3.3.0", | ||
"version": "3.4.0", | ||
"description": "tsParticles particles out modes updater", | ||
@@ -90,3 +90,3 @@ "homepage": "https://particles.js.org", | ||
"dependencies": { | ||
"@tsparticles/engine": "^3.3.0" | ||
"@tsparticles/engine": "^3.4.0" | ||
}, | ||
@@ -93,0 +93,0 @@ "publishConfig": { |
@@ -7,3 +7,3 @@ /*! | ||
* How to use? : Check the GitHub README | ||
* v3.3.0 | ||
* v3.4.0 | ||
*/ | ||
@@ -32,2 +32,62 @@ /* | ||
/***/ "./dist/browser/BounceOutMode.js": | ||
/*!***************************************!*\ | ||
!*** ./dist/browser/BounceOutMode.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 */ BounceOutMode: () => (/* binding */ BounceOutMode)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Utils.js */ \"./dist/browser/Utils.js\");\n\n\nclass BounceOutMode {\n constructor(container) {\n this.container = container;\n this.modes = [_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutMode.bounce, _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutMode.split];\n }\n update(particle, direction, delta, outMode) {\n if (!this.modes.includes(outMode)) {\n return;\n }\n const container = this.container;\n let handled = false;\n for (const [, plugin] of container.plugins) {\n if (plugin.particleBounce !== undefined) {\n handled = plugin.particleBounce(particle, delta, direction);\n }\n if (handled) {\n break;\n }\n }\n if (handled) {\n return;\n }\n const pos = particle.getPosition(),\n offset = particle.offset,\n size = particle.getRadius(),\n bounds = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.calculateBounds)(pos, size),\n canvasSize = container.canvas.size;\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.bounceHorizontal)({\n particle,\n outMode,\n direction,\n bounds,\n canvasSize,\n offset,\n size\n });\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.bounceVertical)({\n particle,\n outMode,\n direction,\n bounds,\n canvasSize,\n offset,\n size\n });\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-out-modes/./dist/browser/BounceOutMode.js?"); | ||
/***/ }), | ||
/***/ "./dist/browser/DestroyOutMode.js": | ||
/*!****************************************!*\ | ||
!*** ./dist/browser/DestroyOutMode.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 */ DestroyOutMode: () => (/* binding */ DestroyOutMode)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n\nconst minVelocity = 0;\nclass DestroyOutMode {\n constructor(container) {\n this.container = container;\n this.modes = [_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutMode.destroy];\n }\n update(particle, direction, _delta, outMode) {\n if (!this.modes.includes(outMode)) {\n return;\n }\n const container = this.container;\n switch (particle.outType) {\n case _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.ParticleOutType.normal:\n case _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.ParticleOutType.outside:\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isPointInside)(particle.position, container.canvas.size, _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.origin, particle.getRadius(), direction)) {\n return;\n }\n break;\n case _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.ParticleOutType.inside:\n {\n const {\n dx,\n dy\n } = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistances)(particle.position, particle.moveCenter),\n {\n x: vx,\n y: vy\n } = particle.velocity;\n if (vx < minVelocity && dx > particle.moveCenter.radius || vy < minVelocity && dy > particle.moveCenter.radius || vx >= minVelocity && dx < -particle.moveCenter.radius || vy >= minVelocity && dy < -particle.moveCenter.radius) {\n return;\n }\n break;\n }\n }\n container.particles.remove(particle, undefined, true);\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-out-modes/./dist/browser/DestroyOutMode.js?"); | ||
/***/ }), | ||
/***/ "./dist/browser/NoneOutMode.js": | ||
/*!*************************************!*\ | ||
!*** ./dist/browser/NoneOutMode.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 */ NoneOutMode: () => (/* binding */ NoneOutMode)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n\nconst minVelocity = 0;\nclass NoneOutMode {\n constructor(container) {\n this.container = container;\n this.modes = [_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutMode.none];\n }\n update(particle, direction, delta, outMode) {\n if (!this.modes.includes(outMode)) {\n return;\n }\n if ((particle.options.move.distance.horizontal && (direction === _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutModeDirection.left || direction === _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutModeDirection.right)) ?? (particle.options.move.distance.vertical && (direction === _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutModeDirection.top || direction === _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutModeDirection.bottom))) {\n return;\n }\n const gravityOptions = particle.options.move.gravity,\n container = this.container,\n canvasSize = container.canvas.size,\n pRadius = particle.getRadius();\n if (!gravityOptions.enable) {\n if (particle.velocity.y > minVelocity && particle.position.y <= canvasSize.height + pRadius || particle.velocity.y < minVelocity && particle.position.y >= -pRadius || particle.velocity.x > minVelocity && particle.position.x <= canvasSize.width + pRadius || particle.velocity.x < minVelocity && particle.position.x >= -pRadius) {\n return;\n }\n if (!(0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isPointInside)(particle.position, container.canvas.size, _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.origin, pRadius, direction)) {\n container.particles.remove(particle);\n }\n } else {\n const position = particle.position;\n if (!gravityOptions.inverse && position.y > canvasSize.height + pRadius && direction === _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutModeDirection.bottom || gravityOptions.inverse && position.y < -pRadius && direction === _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutModeDirection.top) {\n container.particles.remove(particle);\n }\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-out-modes/./dist/browser/NoneOutMode.js?"); | ||
/***/ }), | ||
/***/ "./dist/browser/OutOfCanvasUpdater.js": | ||
/*!********************************************!*\ | ||
!*** ./dist/browser/OutOfCanvasUpdater.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 */ OutOfCanvasUpdater: () => (/* binding */ OutOfCanvasUpdater)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _BounceOutMode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./BounceOutMode.js */ \"./dist/browser/BounceOutMode.js\");\n/* harmony import */ var _DestroyOutMode_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./DestroyOutMode.js */ \"./dist/browser/DestroyOutMode.js\");\n/* harmony import */ var _NoneOutMode_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./NoneOutMode.js */ \"./dist/browser/NoneOutMode.js\");\n/* harmony import */ var _OutOutMode_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./OutOutMode.js */ \"./dist/browser/OutOutMode.js\");\n\n\n\n\n\nconst checkOutMode = (outModes, outMode) => {\n return outModes.default === outMode || outModes.bottom === outMode || outModes.left === outMode || outModes.right === outMode || outModes.top === outMode;\n};\nclass OutOfCanvasUpdater {\n constructor(container) {\n this._updateOutMode = (particle, delta, outMode, direction) => {\n for (const updater of this.updaters) {\n updater.update(particle, direction, delta, outMode);\n }\n };\n this.container = container;\n this.updaters = [];\n }\n init(particle) {\n this.updaters = [];\n const outModes = particle.options.move.outModes;\n if (checkOutMode(outModes, _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutMode.bounce)) {\n this.updaters.push(new _BounceOutMode_js__WEBPACK_IMPORTED_MODULE_1__.BounceOutMode(this.container));\n } else if (checkOutMode(outModes, _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutMode.out)) {\n this.updaters.push(new _OutOutMode_js__WEBPACK_IMPORTED_MODULE_2__.OutOutMode(this.container));\n } else if (checkOutMode(outModes, _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutMode.destroy)) {\n this.updaters.push(new _DestroyOutMode_js__WEBPACK_IMPORTED_MODULE_3__.DestroyOutMode(this.container));\n } else if (checkOutMode(outModes, _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutMode.none)) {\n this.updaters.push(new _NoneOutMode_js__WEBPACK_IMPORTED_MODULE_4__.NoneOutMode(this.container));\n }\n }\n isEnabled(particle) {\n return !particle.destroyed && !particle.spawning;\n }\n update(particle, delta) {\n const outModes = particle.options.move.outModes;\n this._updateOutMode(particle, delta, outModes.bottom ?? outModes.default, _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutModeDirection.bottom);\n this._updateOutMode(particle, delta, outModes.left ?? outModes.default, _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutModeDirection.left);\n this._updateOutMode(particle, delta, outModes.right ?? outModes.default, _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutModeDirection.right);\n this._updateOutMode(particle, delta, outModes.top ?? outModes.default, _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutModeDirection.top);\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-out-modes/./dist/browser/OutOfCanvasUpdater.js?"); | ||
/***/ }), | ||
/***/ "./dist/browser/OutOutMode.js": | ||
/*!************************************!*\ | ||
!*** ./dist/browser/OutOutMode.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 */ OutOutMode: () => (/* binding */ OutOutMode)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n\nconst minVelocity = 0,\n minDistance = 0;\nclass OutOutMode {\n constructor(container) {\n this.container = container;\n this.modes = [_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutMode.out];\n }\n update(particle, direction, delta, outMode) {\n if (!this.modes.includes(outMode)) {\n return;\n }\n const container = this.container;\n switch (particle.outType) {\n case _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.ParticleOutType.inside:\n {\n const {\n x: vx,\n y: vy\n } = particle.velocity;\n const circVec = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.origin;\n circVec.length = particle.moveCenter.radius;\n circVec.angle = particle.velocity.angle + Math.PI;\n circVec.addTo(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.create(particle.moveCenter));\n const {\n dx,\n dy\n } = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistances)(particle.position, circVec);\n if (vx <= minVelocity && dx >= minDistance || vy <= minVelocity && dy >= minDistance || vx >= minVelocity && dx <= minDistance || vy >= minVelocity && dy <= minDistance) {\n return;\n }\n particle.position.x = Math.floor((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.randomInRange)({\n min: 0,\n max: container.canvas.size.width\n }));\n particle.position.y = Math.floor((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.randomInRange)({\n min: 0,\n max: container.canvas.size.height\n }));\n const {\n dx: newDx,\n dy: newDy\n } = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistances)(particle.position, particle.moveCenter);\n particle.direction = Math.atan2(-newDy, -newDx);\n particle.velocity.angle = particle.direction;\n break;\n }\n default:\n {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isPointInside)(particle.position, container.canvas.size, _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.origin, particle.getRadius(), direction)) {\n return;\n }\n switch (particle.outType) {\n case _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.ParticleOutType.outside:\n {\n particle.position.x = Math.floor((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.randomInRange)({\n min: -particle.moveCenter.radius,\n max: particle.moveCenter.radius\n })) + particle.moveCenter.x;\n particle.position.y = Math.floor((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.randomInRange)({\n min: -particle.moveCenter.radius,\n max: particle.moveCenter.radius\n })) + particle.moveCenter.y;\n const {\n dx,\n dy\n } = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistances)(particle.position, particle.moveCenter);\n if (particle.moveCenter.radius) {\n particle.direction = Math.atan2(dy, dx);\n particle.velocity.angle = particle.direction;\n }\n break;\n }\n case _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.ParticleOutType.normal:\n {\n const warp = particle.options.move.warp,\n canvasSize = container.canvas.size,\n newPos = {\n bottom: canvasSize.height + particle.getRadius() + particle.offset.y,\n left: -particle.getRadius() - particle.offset.x,\n right: canvasSize.width + particle.getRadius() + particle.offset.x,\n top: -particle.getRadius() - particle.offset.y\n },\n sizeValue = particle.getRadius(),\n nextBounds = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.calculateBounds)(particle.position, sizeValue);\n if (direction === _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutModeDirection.right && nextBounds.left > canvasSize.width + particle.offset.x) {\n particle.position.x = newPos.left;\n particle.initialPosition.x = particle.position.x;\n if (!warp) {\n particle.position.y = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * canvasSize.height;\n particle.initialPosition.y = particle.position.y;\n }\n } else if (direction === _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutModeDirection.left && nextBounds.right < -particle.offset.x) {\n particle.position.x = newPos.right;\n particle.initialPosition.x = particle.position.x;\n if (!warp) {\n particle.position.y = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * canvasSize.height;\n particle.initialPosition.y = particle.position.y;\n }\n }\n if (direction === _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutModeDirection.bottom && nextBounds.top > canvasSize.height + particle.offset.y) {\n if (!warp) {\n particle.position.x = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * canvasSize.width;\n particle.initialPosition.x = particle.position.x;\n }\n particle.position.y = newPos.top;\n particle.initialPosition.y = particle.position.y;\n } else if (direction === _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutModeDirection.top && nextBounds.bottom < -particle.offset.y) {\n if (!warp) {\n particle.position.x = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * canvasSize.width;\n particle.initialPosition.x = particle.position.x;\n }\n particle.position.y = newPos.bottom;\n particle.initialPosition.y = particle.position.y;\n }\n break;\n }\n }\n break;\n }\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-out-modes/./dist/browser/OutOutMode.js?"); | ||
/***/ }), | ||
/***/ "./dist/browser/Utils.js": | ||
/*!*******************************!*\ | ||
!*** ./dist/browser/Utils.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 */ bounceHorizontal: () => (/* binding */ bounceHorizontal),\n/* harmony export */ bounceVertical: () => (/* binding */ bounceVertical)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n\nconst minVelocity = 0,\n boundsMin = 0;\nfunction bounceHorizontal(data) {\n if (data.outMode !== _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutMode.bounce && data.outMode !== _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutMode.split || data.direction !== _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutModeDirection.left && data.direction !== _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutModeDirection.right) {\n return;\n }\n if (data.bounds.right < boundsMin && data.direction === _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutModeDirection.left) {\n data.particle.position.x = data.size + data.offset.x;\n } else if (data.bounds.left > data.canvasSize.width && data.direction === _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutModeDirection.right) {\n data.particle.position.x = data.canvasSize.width - data.size - data.offset.x;\n }\n const velocity = data.particle.velocity.x;\n let bounced = false;\n if (data.direction === _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutModeDirection.right && data.bounds.right >= data.canvasSize.width && velocity > minVelocity || data.direction === _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutModeDirection.left && data.bounds.left <= boundsMin && velocity < minVelocity) {\n const newVelocity = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(data.particle.options.bounce.horizontal.value);\n data.particle.velocity.x *= -newVelocity;\n bounced = true;\n }\n if (!bounced) {\n return;\n }\n const minPos = data.offset.x + data.size;\n if (data.bounds.right >= data.canvasSize.width && data.direction === _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutModeDirection.right) {\n data.particle.position.x = data.canvasSize.width - minPos;\n } else if (data.bounds.left <= boundsMin && data.direction === _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutModeDirection.left) {\n data.particle.position.x = minPos;\n }\n if (data.outMode === _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutMode.split) {\n data.particle.destroy();\n }\n}\nfunction bounceVertical(data) {\n if (data.outMode !== _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutMode.bounce && data.outMode !== _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutMode.split || data.direction !== _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutModeDirection.bottom && data.direction !== _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutModeDirection.top) {\n return;\n }\n if (data.bounds.bottom < boundsMin && data.direction === _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutModeDirection.top) {\n data.particle.position.y = data.size + data.offset.y;\n } else if (data.bounds.top > data.canvasSize.height && data.direction === _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutModeDirection.bottom) {\n data.particle.position.y = data.canvasSize.height - data.size - data.offset.y;\n }\n const velocity = data.particle.velocity.y;\n let bounced = false;\n if (data.direction === _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutModeDirection.bottom && data.bounds.bottom >= data.canvasSize.height && velocity > minVelocity || data.direction === _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutModeDirection.top && data.bounds.top <= boundsMin && velocity < minVelocity) {\n const newVelocity = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(data.particle.options.bounce.vertical.value);\n data.particle.velocity.y *= -newVelocity;\n bounced = true;\n }\n if (!bounced) {\n return;\n }\n const minPos = data.offset.y + data.size;\n if (data.bounds.bottom >= data.canvasSize.height && data.direction === _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutModeDirection.bottom) {\n data.particle.position.y = data.canvasSize.height - minPos;\n } else if (data.bounds.top <= boundsMin && data.direction === _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutModeDirection.top) {\n data.particle.position.y = minPos;\n }\n if (data.outMode === _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OutMode.split) {\n data.particle.destroy();\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-out-modes/./dist/browser/Utils.js?"); | ||
/***/ }), | ||
/***/ "./dist/browser/index.js": | ||
@@ -39,3 +99,3 @@ /*!*******************************!*\ | ||
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?"); | ||
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadOutModesUpdater: () => (/* binding */ loadOutModesUpdater)\n/* harmony export */ });\n/* harmony import */ var _OutOfCanvasUpdater_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./OutOfCanvasUpdater.js */ \"./dist/browser/OutOfCanvasUpdater.js\");\n\nasync function loadOutModesUpdater(engine, refresh = true) {\n await engine.addParticleUpdater(\"outModes\", container => {\n return Promise.resolve(new _OutOfCanvasUpdater_js__WEBPACK_IMPORTED_MODULE_0__.OutOfCanvasUpdater(container));\n }, refresh);\n}\n\n//# sourceURL=webpack://@tsparticles/updater-out-modes/./dist/browser/index.js?"); | ||
@@ -80,5 +140,2 @@ /***/ }), | ||
/******/ | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = __webpack_modules__; | ||
/******/ | ||
/************************************************************************/ | ||
@@ -109,36 +166,2 @@ /******/ /* webpack/runtime/compat get default export */ | ||
/******/ | ||
/******/ /* 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 */ | ||
@@ -149,48 +172,2 @@ /******/ (() => { | ||
/******/ | ||
/******/ /* 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 */ | ||
@@ -207,117 +184,2 @@ /******/ (() => { | ||
/******/ | ||
/******/ /* 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 || !/^http(s?):/.test(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)); | ||
/******/ })(); | ||
/******/ | ||
/************************************************************************/ | ||
@@ -324,0 +186,0 @@ /******/ |
/*! For license information please see tsparticles.updater.out-modes.min.js.LICENSE.txt */ | ||
!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={303:t=>{t.exports=e}},n={};function i(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}};return o[e](r,r.exports,i),r.exports}i.m=o,i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.f={},i.e=e=>Promise.all(Object.keys(i.f).reduce(((t,r)=>(i.f[r](e,t),t)),[])),i.u=e=>e+".min.js",i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),t={},r="@tsparticles/updater-out-modes:",i.l=(e,o,n,a)=>{if(t[e])t[e].push(o);else{var s,u;if(void 0!==n)for(var p=document.getElementsByTagName("script"),c=0;c<p.length;c++){var d=p[c];if(d.getAttribute("src")==e||d.getAttribute("data-webpack")==r+n){s=d;break}}s||(u=!0,(s=document.createElement("script")).charset="utf-8",s.timeout=120,i.nc&&s.setAttribute("nonce",i.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)}},i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;i.g.importScripts&&(e=i.g.location+"");var t=i.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||!/^http(s?):/.test(e));)e=r[o--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),i.p=e})(),(()=>{var e={427:0};i.f.j=(t,r)=>{var o=i.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 a=i.p+i.u(t),s=new Error;i.l(a,(r=>{if(i.o(e,t)&&(0!==(o=e[t])&&(e[t]=void 0),o)){var n=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;s.message="Loading chunk "+t+" failed.\n("+n+": "+a+")",s.name="ChunkLoadError",s.type=n,s.request=a,o[1](s)}}),"chunk-"+t,t)}};var t=(t,r)=>{var o,n,a=r[0],s=r[1],u=r[2],p=0;if(a.some((t=>0!==e[t]))){for(o in s)i.o(s,o)&&(i.m[o]=s[o]);if(u)u(i)}for(t&&t(r);p<a.length;p++)n=a[p],i.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 a={};return(()=>{async function e(e,t=!0){await e.addParticleUpdater("outModes",(async e=>{const{OutOfCanvasUpdater:t}=await i.e(128).then(i.bind(i,128));return new t(e)}),t)}i.r(a),i.d(a,{loadOutModesUpdater:()=>e})})(),a})())); | ||
!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=>(()=>{var e={303: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:()=>d});var t=i(303);class e{constructor(e){this.container=e,this.modes=[t.OutMode.bounce,t.OutMode.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(e.outMode!==t.OutMode.bounce&&e.outMode!==t.OutMode.split||e.direction!==t.OutModeDirection.left&&e.direction!==t.OutModeDirection.right)return;e.bounds.right<0&&e.direction===t.OutModeDirection.left?e.particle.position.x=e.size+e.offset.x:e.bounds.left>e.canvasSize.width&&e.direction===t.OutModeDirection.right&&(e.particle.position.x=e.canvasSize.width-e.size-e.offset.x);const o=e.particle.velocity.x;let i=!1;if(e.direction===t.OutModeDirection.right&&e.bounds.right>=e.canvasSize.width&&o>0||e.direction===t.OutModeDirection.left&&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&&e.direction===t.OutModeDirection.right?e.particle.position.x=e.canvasSize.width-n:e.bounds.left<=0&&e.direction===t.OutModeDirection.left&&(e.particle.position.x=n),e.outMode===t.OutMode.split&&e.particle.destroy()}({particle:e,outMode:n,direction:o,bounds:u,canvasSize:p,offset:c,size:d}),function(e){if(e.outMode!==t.OutMode.bounce&&e.outMode!==t.OutMode.split||e.direction!==t.OutModeDirection.bottom&&e.direction!==t.OutModeDirection.top)return;e.bounds.bottom<0&&e.direction===t.OutModeDirection.top?e.particle.position.y=e.size+e.offset.y:e.bounds.top>e.canvasSize.height&&e.direction===t.OutModeDirection.bottom&&(e.particle.position.y=e.canvasSize.height-e.size-e.offset.y);const o=e.particle.velocity.y;let i=!1;if(e.direction===t.OutModeDirection.bottom&&e.bounds.bottom>=e.canvasSize.height&&o>0||e.direction===t.OutModeDirection.top&&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&&e.direction===t.OutModeDirection.bottom?e.particle.position.y=e.canvasSize.height-n:e.bounds.top<=0&&e.direction===t.OutModeDirection.top&&(e.particle.position.y=n),e.outMode===t.OutMode.split&&e.particle.destroy()}({particle:e,outMode:n,direction:o,bounds:u,canvasSize:p,offset:c,size:d})}}class o{constructor(e){this.container=e,this.modes=[t.OutMode.destroy]}update(e,o,i,n){if(!this.modes.includes(n))return;const s=this.container;switch(e.outType){case t.ParticleOutType.normal:case t.ParticleOutType.outside:if((0,t.isPointInside)(e.position,s.canvas.size,t.Vector.origin,e.getRadius(),o))return;break;case t.ParticleOutType.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(e){this.container=e,this.modes=[t.OutMode.none]}update(e,o,i,n){if(!this.modes.includes(n))return;if((e.options.move.distance.horizontal&&(o===t.OutModeDirection.left||o===t.OutModeDirection.right))??(e.options.move.distance.vertical&&(o===t.OutModeDirection.top||o===t.OutModeDirection.bottom)))return;const s=e.options.move.gravity,r=this.container,a=r.canvas.size,c=e.getRadius();if(s.enable){const i=e.position;(!s.inverse&&i.y>a.height+c&&o===t.OutModeDirection.bottom||s.inverse&&i.y<-c&&o===t.OutModeDirection.top)&&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(e){this.container=e,this.modes=[t.OutMode.out]}update(e,o,i,n){if(!this.modes.includes(n))return;const s=this.container;switch(e.outType){case t.ParticleOutType.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 t.ParticleOutType.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 t.ParticleOutType.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);o===t.OutModeDirection.right&&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)):o===t.OutModeDirection.left&&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)),o===t.OutModeDirection.bottom&&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):o===t.OutModeDirection.top&&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}}}}}const a=(t,e)=>t.default===e||t.bottom===e||t.left===e||t.right===e||t.top===e;class c{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=[]}init(i){this.updaters=[];const n=i.options.move.outModes;a(n,t.OutMode.bounce)?this.updaters.push(new e(this.container)):a(n,t.OutMode.out)?this.updaters.push(new r(this.container)):a(n,t.OutMode.destroy)?this.updaters.push(new o(this.container)):a(n,t.OutMode.none)&&this.updaters.push(new s(this.container))}isEnabled(t){return!t.destroyed&&!t.spawning}update(e,o){const i=e.options.move.outModes;this._updateOutMode(e,o,i.bottom??i.default,t.OutModeDirection.bottom),this._updateOutMode(e,o,i.left??i.default,t.OutModeDirection.left),this._updateOutMode(e,o,i.right??i.default,t.OutModeDirection.right),this._updateOutMode(e,o,i.top??i.default,t.OutModeDirection.top)}}async function d(t,e=!0){await t.addParticleUpdater("outModes",(t=>Promise.resolve(new c(t))),e)}})(),n})())); |
@@ -1,1 +0,1 @@ | ||
/*! tsParticles Out Modes Updater v3.3.0 by Matteo Bruni */ | ||
/*! tsParticles Out Modes Updater v3.4.0 by Matteo Bruni */ |
@@ -19,4 +19,4 @@ (function (factory) { | ||
this.modes = [ | ||
"bounce", | ||
"split", | ||
engine_1.OutMode.bounce, | ||
engine_1.OutMode.split, | ||
]; | ||
@@ -23,0 +23,0 @@ } |
@@ -18,3 +18,3 @@ (function (factory) { | ||
this.container = container; | ||
this.modes = ["destroy"]; | ||
this.modes = [engine_1.OutMode.destroy]; | ||
} | ||
@@ -27,4 +27,4 @@ update(particle, direction, _delta, outMode) { | ||
switch (particle.outType) { | ||
case "normal": | ||
case "outside": | ||
case engine_1.ParticleOutType.normal: | ||
case engine_1.ParticleOutType.outside: | ||
if ((0, engine_1.isPointInside)(particle.position, container.canvas.size, engine_1.Vector.origin, particle.getRadius(), direction)) { | ||
@@ -34,3 +34,3 @@ return; | ||
break; | ||
case "inside": { | ||
case engine_1.ParticleOutType.inside: { | ||
const { dx, dy } = (0, engine_1.getDistances)(particle.position, particle.moveCenter), { x: vx, y: vy } = particle.velocity; | ||
@@ -37,0 +37,0 @@ if ((vx < minVelocity && dx > particle.moveCenter.radius) || |
@@ -1,24 +0,1 @@ | ||
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) { | ||
@@ -30,13 +7,12 @@ if (typeof module === "object" && typeof module.exports === "object") { | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports"], factory); | ||
define(["require", "exports", "./OutOfCanvasUpdater.js"], 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", 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); | ||
await engine.addParticleUpdater("outModes", container => { | ||
return Promise.resolve(new OutOfCanvasUpdater_js_1.OutOfCanvasUpdater(container)); | ||
}, refresh); | ||
@@ -43,0 +19,0 @@ } |
@@ -18,3 +18,3 @@ (function (factory) { | ||
this.container = container; | ||
this.modes = ["none"]; | ||
this.modes = [engine_1.OutMode.none]; | ||
} | ||
@@ -26,5 +26,5 @@ update(particle, direction, delta, outMode) { | ||
if ((particle.options.move.distance.horizontal && | ||
(direction === "left" || direction === "right")) ?? | ||
(direction === engine_1.OutModeDirection.left || direction === engine_1.OutModeDirection.right)) ?? | ||
(particle.options.move.distance.vertical && | ||
(direction === "top" || direction === "bottom"))) { | ||
(direction === engine_1.OutModeDirection.top || direction === engine_1.OutModeDirection.bottom))) { | ||
return; | ||
@@ -48,4 +48,4 @@ } | ||
position.y > canvasSize.height + pRadius && | ||
direction === "bottom") || | ||
(gravityOptions.inverse && position.y < -pRadius && direction === "top")) { | ||
direction === engine_1.OutModeDirection.bottom) || | ||
(gravityOptions.inverse && position.y < -pRadius && direction === engine_1.OutModeDirection.top)) { | ||
container.particles.remove(particle); | ||
@@ -52,0 +52,0 @@ } |
@@ -7,3 +7,3 @@ (function (factory) { | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports", "./BounceOutMode.js", "./DestroyOutMode.js", "./NoneOutMode.js", "./OutOutMode.js"], factory); | ||
define(["require", "exports", "@tsparticles/engine", "./BounceOutMode.js", "./DestroyOutMode.js", "./NoneOutMode.js", "./OutOutMode.js"], factory); | ||
} | ||
@@ -14,2 +14,3 @@ })(function (require, exports) { | ||
exports.OutOfCanvasUpdater = void 0; | ||
const engine_1 = require("@tsparticles/engine"); | ||
const BounceOutMode_js_1 = require("./BounceOutMode.js"); | ||
@@ -39,12 +40,12 @@ const DestroyOutMode_js_1 = require("./DestroyOutMode.js"); | ||
const outModes = particle.options.move.outModes; | ||
if (checkOutMode(outModes, "bounce")) { | ||
if (checkOutMode(outModes, engine_1.OutMode.bounce)) { | ||
this.updaters.push(new BounceOutMode_js_1.BounceOutMode(this.container)); | ||
} | ||
else if (checkOutMode(outModes, "out")) { | ||
else if (checkOutMode(outModes, engine_1.OutMode.out)) { | ||
this.updaters.push(new OutOutMode_js_1.OutOutMode(this.container)); | ||
} | ||
else if (checkOutMode(outModes, "destroy")) { | ||
else if (checkOutMode(outModes, engine_1.OutMode.destroy)) { | ||
this.updaters.push(new DestroyOutMode_js_1.DestroyOutMode(this.container)); | ||
} | ||
else if (checkOutMode(outModes, "none")) { | ||
else if (checkOutMode(outModes, engine_1.OutMode.none)) { | ||
this.updaters.push(new NoneOutMode_js_1.NoneOutMode(this.container)); | ||
@@ -58,6 +59,6 @@ } | ||
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"); | ||
this._updateOutMode(particle, delta, outModes.bottom ?? outModes.default, engine_1.OutModeDirection.bottom); | ||
this._updateOutMode(particle, delta, outModes.left ?? outModes.default, engine_1.OutModeDirection.left); | ||
this._updateOutMode(particle, delta, outModes.right ?? outModes.default, engine_1.OutModeDirection.right); | ||
this._updateOutMode(particle, delta, outModes.top ?? outModes.default, engine_1.OutModeDirection.top); | ||
} | ||
@@ -64,0 +65,0 @@ } |
@@ -18,3 +18,3 @@ (function (factory) { | ||
this.container = container; | ||
this.modes = ["out"]; | ||
this.modes = [engine_1.OutMode.out]; | ||
} | ||
@@ -27,3 +27,3 @@ update(particle, direction, delta, outMode) { | ||
switch (particle.outType) { | ||
case "inside": { | ||
case engine_1.ParticleOutType.inside: { | ||
const { x: vx, y: vy } = particle.velocity; | ||
@@ -59,3 +59,3 @@ const circVec = engine_1.Vector.origin; | ||
switch (particle.outType) { | ||
case "outside": { | ||
case engine_1.ParticleOutType.outside: { | ||
particle.position.x = | ||
@@ -78,3 +78,3 @@ Math.floor((0, engine_1.randomInRange)({ | ||
} | ||
case "normal": { | ||
case engine_1.ParticleOutType.normal: { | ||
const warp = particle.options.move.warp, canvasSize = container.canvas.size, newPos = { | ||
@@ -86,3 +86,3 @@ bottom: canvasSize.height + particle.getRadius() + particle.offset.y, | ||
}, sizeValue = particle.getRadius(), nextBounds = (0, engine_1.calculateBounds)(particle.position, sizeValue); | ||
if (direction === "right" && | ||
if (direction === engine_1.OutModeDirection.right && | ||
nextBounds.left > canvasSize.width + particle.offset.x) { | ||
@@ -96,3 +96,3 @@ particle.position.x = newPos.left; | ||
} | ||
else if (direction === "left" && nextBounds.right < -particle.offset.x) { | ||
else if (direction === engine_1.OutModeDirection.left && nextBounds.right < -particle.offset.x) { | ||
particle.position.x = newPos.right; | ||
@@ -105,3 +105,3 @@ particle.initialPosition.x = particle.position.x; | ||
} | ||
if (direction === "bottom" && | ||
if (direction === engine_1.OutModeDirection.bottom && | ||
nextBounds.top > canvasSize.height + particle.offset.y) { | ||
@@ -115,3 +115,3 @@ if (!warp) { | ||
} | ||
else if (direction === "top" && nextBounds.bottom < -particle.offset.y) { | ||
else if (direction === engine_1.OutModeDirection.top && nextBounds.bottom < -particle.offset.y) { | ||
if (!warp) { | ||
@@ -118,0 +118,0 @@ particle.position.x = (0, engine_1.getRandom)() * canvasSize.width; |
@@ -16,10 +16,10 @@ (function (factory) { | ||
function bounceHorizontal(data) { | ||
if ((data.outMode !== "bounce" && data.outMode !== "split") || | ||
(data.direction !== "left" && data.direction !== "right")) { | ||
if ((data.outMode !== engine_1.OutMode.bounce && data.outMode !== engine_1.OutMode.split) || | ||
(data.direction !== engine_1.OutModeDirection.left && data.direction !== engine_1.OutModeDirection.right)) { | ||
return; | ||
} | ||
if (data.bounds.right < boundsMin && data.direction === "left") { | ||
if (data.bounds.right < boundsMin && data.direction === engine_1.OutModeDirection.left) { | ||
data.particle.position.x = data.size + data.offset.x; | ||
} | ||
else if (data.bounds.left > data.canvasSize.width && data.direction === "right") { | ||
else if (data.bounds.left > data.canvasSize.width && data.direction === engine_1.OutModeDirection.right) { | ||
data.particle.position.x = data.canvasSize.width - data.size - data.offset.x; | ||
@@ -29,6 +29,6 @@ } | ||
let bounced = false; | ||
if ((data.direction === "right" && | ||
if ((data.direction === engine_1.OutModeDirection.right && | ||
data.bounds.right >= data.canvasSize.width && | ||
velocity > minVelocity) || | ||
(data.direction === "left" && data.bounds.left <= boundsMin && velocity < minVelocity)) { | ||
(data.direction === engine_1.OutModeDirection.left && data.bounds.left <= boundsMin && velocity < minVelocity)) { | ||
const newVelocity = (0, engine_1.getRangeValue)(data.particle.options.bounce.horizontal.value); | ||
@@ -42,9 +42,9 @@ data.particle.velocity.x *= -newVelocity; | ||
const minPos = data.offset.x + data.size; | ||
if (data.bounds.right >= data.canvasSize.width && data.direction === "right") { | ||
if (data.bounds.right >= data.canvasSize.width && data.direction === engine_1.OutModeDirection.right) { | ||
data.particle.position.x = data.canvasSize.width - minPos; | ||
} | ||
else if (data.bounds.left <= boundsMin && data.direction === "left") { | ||
else if (data.bounds.left <= boundsMin && data.direction === engine_1.OutModeDirection.left) { | ||
data.particle.position.x = minPos; | ||
} | ||
if (data.outMode === "split") { | ||
if (data.outMode === engine_1.OutMode.split) { | ||
data.particle.destroy(); | ||
@@ -55,10 +55,10 @@ } | ||
function bounceVertical(data) { | ||
if ((data.outMode !== "bounce" && data.outMode !== "split") || | ||
(data.direction !== "bottom" && data.direction !== "top")) { | ||
if ((data.outMode !== engine_1.OutMode.bounce && data.outMode !== engine_1.OutMode.split) || | ||
(data.direction !== engine_1.OutModeDirection.bottom && data.direction !== engine_1.OutModeDirection.top)) { | ||
return; | ||
} | ||
if (data.bounds.bottom < boundsMin && data.direction === "top") { | ||
if (data.bounds.bottom < boundsMin && data.direction === engine_1.OutModeDirection.top) { | ||
data.particle.position.y = data.size + data.offset.y; | ||
} | ||
else if (data.bounds.top > data.canvasSize.height && data.direction === "bottom") { | ||
else if (data.bounds.top > data.canvasSize.height && data.direction === engine_1.OutModeDirection.bottom) { | ||
data.particle.position.y = data.canvasSize.height - data.size - data.offset.y; | ||
@@ -68,6 +68,6 @@ } | ||
let bounced = false; | ||
if ((data.direction === "bottom" && | ||
if ((data.direction === engine_1.OutModeDirection.bottom && | ||
data.bounds.bottom >= data.canvasSize.height && | ||
velocity > minVelocity) || | ||
(data.direction === "top" && data.bounds.top <= boundsMin && velocity < minVelocity)) { | ||
(data.direction === engine_1.OutModeDirection.top && data.bounds.top <= boundsMin && velocity < minVelocity)) { | ||
const newVelocity = (0, engine_1.getRangeValue)(data.particle.options.bounce.vertical.value); | ||
@@ -81,9 +81,9 @@ data.particle.velocity.y *= -newVelocity; | ||
const minPos = data.offset.y + data.size; | ||
if (data.bounds.bottom >= data.canvasSize.height && data.direction === "bottom") { | ||
if (data.bounds.bottom >= data.canvasSize.height && data.direction === engine_1.OutModeDirection.bottom) { | ||
data.particle.position.y = data.canvasSize.height - minPos; | ||
} | ||
else if (data.bounds.top <= boundsMin && data.direction === "top") { | ||
else if (data.bounds.top <= boundsMin && data.direction === engine_1.OutModeDirection.top) { | ||
data.particle.position.y = minPos; | ||
} | ||
if (data.outMode === "split") { | ||
if (data.outMode === engine_1.OutMode.split) { | ||
data.particle.destroy(); | ||
@@ -90,0 +90,0 @@ } |
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
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
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
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 1 instance 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
395372
55
1831
6
7
Updated@tsparticles/engine@^3.4.0