56 lines
2.5 KiB
JavaScript
56 lines
2.5 KiB
JavaScript
(function (factory) {
|
|
if (typeof module === "object" && typeof module.exports === "object") {
|
|
var v = factory(require, exports);
|
|
if (v !== undefined) module.exports = v;
|
|
}
|
|
else if (typeof define === "function" && define.amd) {
|
|
define(["require", "exports", "tsparticles-engine"], factory);
|
|
}
|
|
})(function (require, exports) {
|
|
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.NoneOutMode = void 0;
|
|
const tsparticles_engine_1 = require("tsparticles-engine");
|
|
class NoneOutMode {
|
|
constructor(container) {
|
|
this.container = container;
|
|
this.modes = ["none"];
|
|
}
|
|
update(particle, direction, delta, outMode) {
|
|
if (!this.modes.includes(outMode)) {
|
|
return;
|
|
}
|
|
if ((particle.options.move.distance.horizontal &&
|
|
(direction === "left" || direction === "right")) ||
|
|
(particle.options.move.distance.vertical &&
|
|
(direction === "top" || direction === "bottom"))) {
|
|
return;
|
|
}
|
|
const gravityOptions = particle.options.move.gravity, container = this.container;
|
|
const canvasSize = container.canvas.size;
|
|
const pRadius = particle.getRadius();
|
|
if (!gravityOptions.enable) {
|
|
if ((particle.velocity.y > 0 && particle.position.y <= canvasSize.height + pRadius) ||
|
|
(particle.velocity.y < 0 && particle.position.y >= -pRadius) ||
|
|
(particle.velocity.x > 0 && particle.position.x <= canvasSize.width + pRadius) ||
|
|
(particle.velocity.x < 0 && particle.position.x >= -pRadius)) {
|
|
return;
|
|
}
|
|
if (!(0, tsparticles_engine_1.isPointInside)(particle.position, container.canvas.size, tsparticles_engine_1.Vector.origin, pRadius, direction)) {
|
|
container.particles.remove(particle);
|
|
}
|
|
}
|
|
else {
|
|
const position = particle.position;
|
|
if ((!gravityOptions.inverse &&
|
|
position.y > canvasSize.height + pRadius &&
|
|
direction === "bottom") ||
|
|
(gravityOptions.inverse && position.y < -pRadius && direction === "top")) {
|
|
container.particles.remove(particle);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
exports.NoneOutMode = NoneOutMode;
|
|
});
|