tsparticles-updater-out-modes
Advanced tools
Comparing version 2.0.0-alpha.7 to 2.0.0-beta.0
@@ -1,3 +0,4 @@ | ||
import type { IBounds, ICoordinates, IDimension, Particle } from "tsparticles-engine"; | ||
import type { Particle } from "tsparticles-engine"; | ||
import type { OutMode, OutModeAlt, OutModeDirection } from "tsparticles-engine"; | ||
import type { IBounds, ICoordinates, IDimension } from "tsparticles-engine"; | ||
export interface IBounceData { | ||
@@ -4,0 +5,0 @@ particle: Particle; |
@@ -5,2 +5,3 @@ import type { Container, IDelta, IParticleUpdater, Particle } from "tsparticles-engine"; | ||
constructor(container: Container); | ||
init(): void; | ||
isEnabled(particle: Particle): boolean; | ||
@@ -7,0 +8,0 @@ update(particle: Particle, delta: IDelta): void; |
@@ -7,2 +7,4 @@ import { calculateBounds, isPointInside, OutMode, OutModeDirection } from "tsparticles-engine"; | ||
} | ||
init() { | ||
} | ||
isEnabled(particle) { | ||
@@ -36,2 +38,3 @@ return !particle.destroyed && !particle.spawning; | ||
case OutMode.none: | ||
default: | ||
this.none(particle, direction); | ||
@@ -54,3 +57,3 @@ break; | ||
const wrap = particle.options.move.warp, canvasSize = container.canvas.size, newPos = { | ||
bottom: canvasSize.height + particle.getRadius() - particle.offset.y, | ||
bottom: canvasSize.height + particle.getRadius() + particle.offset.y, | ||
left: -particle.getRadius() - particle.offset.x, | ||
@@ -60,3 +63,3 @@ right: canvasSize.width + particle.getRadius() + particle.offset.x, | ||
}, sizeValue = particle.getRadius(), nextBounds = calculateBounds(particle.position, sizeValue); | ||
if (direction === OutModeDirection.right && nextBounds.left > canvasSize.width - particle.offset.x) { | ||
if (direction === OutModeDirection.right && nextBounds.left > canvasSize.width + particle.offset.x) { | ||
particle.position.x = newPos.left; | ||
@@ -77,3 +80,3 @@ particle.initialPosition.x = particle.position.x; | ||
} | ||
if (direction === OutModeDirection.bottom && nextBounds.top > canvasSize.height - particle.offset.y) { | ||
if (direction === OutModeDirection.bottom && nextBounds.top > canvasSize.height + particle.offset.y) { | ||
if (!wrap) { | ||
@@ -114,8 +117,19 @@ particle.position.x = Math.random() * canvasSize.width; | ||
none(particle, direction) { | ||
if (particle.options.move.distance) { | ||
if ((particle.options.move.distance.horizontal && | ||
(direction === OutModeDirection.left || direction === OutModeDirection.right)) || | ||
(particle.options.move.distance.vertical && | ||
(direction === OutModeDirection.top || direction === OutModeDirection.bottom))) { | ||
return; | ||
} | ||
const gravityOptions = particle.options.move.gravity, container = this.container; | ||
const canvasSize = container.canvas.size; | ||
const pRadius = particle.getRadius(); | ||
if (!gravityOptions.enable) { | ||
if (!isPointInside(particle.position, container.canvas.size, particle.getRadius(), direction)) { | ||
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 (!isPointInside(particle.position, container.canvas.size, pRadius, direction)) { | ||
container.particles.remove(particle); | ||
@@ -126,6 +140,6 @@ } | ||
const position = particle.position; | ||
if ((gravityOptions.acceleration >= 0 && | ||
position.y > container.canvas.size.height && | ||
if ((!gravityOptions.inverse && | ||
position.y > canvasSize.height + pRadius && | ||
direction === OutModeDirection.bottom) || | ||
(gravityOptions.acceleration < 0 && position.y < 0 && direction === OutModeDirection.top)) { | ||
(gravityOptions.inverse && position.y < -pRadius && direction === OutModeDirection.top)) { | ||
container.particles.remove(particle); | ||
@@ -132,0 +146,0 @@ } |
{ | ||
"name": "tsparticles-updater-out-modes", | ||
"version": "2.0.0-alpha.7", | ||
"version": "2.0.0-beta.0", | ||
"description": "tsParticles particles out modes updater", | ||
@@ -42,27 +42,10 @@ "homepage": "https://particles.js.org/", | ||
"main": "index.js", | ||
"jsdelivr": "tsparticles.updater.out.modes.min.js", | ||
"unpkg": "tsparticles.updater.out.modes.min.js", | ||
"jsdelivr": "tsparticles.updater.out-modes.min.js", | ||
"unpkg": "tsparticles.updater.out-modes.min.js", | ||
"browser": "index.js", | ||
"module": "index.js", | ||
"types": "index.d.ts", | ||
"typesVersions": { | ||
">=4.0 <4.1": { | ||
"*": [ | ||
"dist/ts4.0" | ||
] | ||
}, | ||
">=3.8 <4.0": { | ||
"*": [ | ||
"dist/ts3.8" | ||
] | ||
}, | ||
"<3.8": { | ||
"*": [ | ||
"dist/ts3.4" | ||
] | ||
} | ||
}, | ||
"dependencies": { | ||
"tsparticles-engine": "^2.0.0-alpha.7" | ||
"tsparticles-engine": "^2.0.0-beta.0" | ||
} | ||
} |
@@ -1,5 +0,5 @@ | ||
[![banner](https://cdn.matteobruni.it/images/particles/banner2.png)](https://particles.js.org) | ||
[![banner](https://particles.js.org/images/banner2.png)](https://particles.js.org) | ||
# tsparticles-shape-bubble | ||
# tsparticles-updater-outModes | ||
tsParticles bubble shape | ||
tsParticles updater outModes |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
313028
25
636
1