tsparticles-move-base
Advanced tools
Comparing version 2.2.4 to 2.3.0
@@ -43,25 +43,2 @@ import { getDistance, getRangeMax, getRangeValue } from "tsparticles-engine"; | ||
container.retina.reduceFactor, moveDrift = ((_b = (_e = particle.retina).moveDrift) !== null && _b !== void 0 ? _b : (_e.moveDrift = getRangeValue(particle.options.move.drift) * container.retina.pixelRatio)), maxSize = getRangeMax(particleOptions.size.value) * container.retina.pixelRatio, sizeFactor = moveOptions.size ? particle.getRadius() / maxSize : 1, speedFactor = sizeFactor * slowFactor * (delta.factor || 1), diffFactor = 2, moveSpeed = (baseSpeed * speedFactor) / diffFactor; | ||
applyPath(particle, delta); | ||
const gravityOptions = particle.gravity, gravityFactor = (gravityOptions === null || gravityOptions === void 0 ? void 0 : gravityOptions.enable) && gravityOptions.inverse ? -1 : 1; | ||
if ((gravityOptions === null || gravityOptions === void 0 ? void 0 : gravityOptions.enable) && moveSpeed) { | ||
particle.velocity.y += (gravityFactor * (gravityOptions.acceleration * delta.factor)) / (60 * moveSpeed); | ||
} | ||
if (moveDrift && moveSpeed) { | ||
particle.velocity.x += (moveDrift * delta.factor) / (60 * moveSpeed); | ||
} | ||
const decay = particle.moveDecay; | ||
if (decay != 1) { | ||
particle.velocity.multTo(decay); | ||
} | ||
const velocity = particle.velocity.mult(moveSpeed), maxSpeed = (_c = particle.retina.maxSpeed) !== null && _c !== void 0 ? _c : container.retina.maxSpeed; | ||
if ((gravityOptions === null || gravityOptions === void 0 ? void 0 : gravityOptions.enable) && | ||
maxSpeed > 0 && | ||
((!gravityOptions.inverse && velocity.y >= 0 && velocity.y >= maxSpeed) || | ||
(gravityOptions.inverse && velocity.y <= 0 && velocity.y <= -maxSpeed))) { | ||
velocity.y = gravityFactor * maxSpeed; | ||
if (moveSpeed) { | ||
particle.velocity.y = velocity.y / moveSpeed; | ||
} | ||
} | ||
const zIndexOptions = particle.options.zIndex, zVelocityFactor = (1 - particle.zIndexFactor) ** zIndexOptions.velocityRate; | ||
if (moveOptions.spin.enable) { | ||
@@ -71,2 +48,26 @@ spin(particle, moveSpeed); | ||
else { | ||
applyPath(particle, delta); | ||
const gravityOptions = particle.gravity, gravityFactor = (gravityOptions === null || gravityOptions === void 0 ? void 0 : gravityOptions.enable) && gravityOptions.inverse ? -1 : 1; | ||
if ((gravityOptions === null || gravityOptions === void 0 ? void 0 : gravityOptions.enable) && moveSpeed) { | ||
particle.velocity.y += | ||
(gravityFactor * (gravityOptions.acceleration * delta.factor)) / (60 * moveSpeed); | ||
} | ||
if (moveDrift && moveSpeed) { | ||
particle.velocity.x += (moveDrift * delta.factor) / (60 * moveSpeed); | ||
} | ||
const decay = particle.moveDecay; | ||
if (decay != 1) { | ||
particle.velocity.multTo(decay); | ||
} | ||
const velocity = particle.velocity.mult(moveSpeed), maxSpeed = (_c = particle.retina.maxSpeed) !== null && _c !== void 0 ? _c : container.retina.maxSpeed; | ||
if ((gravityOptions === null || gravityOptions === void 0 ? void 0 : gravityOptions.enable) && | ||
maxSpeed > 0 && | ||
((!gravityOptions.inverse && velocity.y >= 0 && velocity.y >= maxSpeed) || | ||
(gravityOptions.inverse && velocity.y <= 0 && velocity.y <= -maxSpeed))) { | ||
velocity.y = gravityFactor * maxSpeed; | ||
if (moveSpeed) { | ||
particle.velocity.y = velocity.y / moveSpeed; | ||
} | ||
} | ||
const zIndexOptions = particle.options.zIndex, zVelocityFactor = (1 - particle.zIndexFactor) ** zIndexOptions.velocityRate; | ||
if (zVelocityFactor != 1) { | ||
@@ -73,0 +74,0 @@ velocity.multTo(zVelocityFactor); |
@@ -1,2 +0,2 @@ | ||
import { clamp, getDistance, getDistances, getRandom, isInArray } from "tsparticles-engine"; | ||
import { clamp, getDistances, getRandom } from "tsparticles-engine"; | ||
export function applyDistance(particle) { | ||
@@ -75,21 +75,3 @@ const initialPosition = particle.initialPosition, { dx, dy } = getDistances(initialPosition, particle.position), dxFixed = Math.abs(dx), dyFixed = Math.abs(dy), hDistance = particle.retina.maxDistance.horizontal, vDistance = particle.retina.maxDistance.vertical; | ||
export function getProximitySpeedFactor(particle) { | ||
const container = particle.container; | ||
const options = container.actualOptions; | ||
const active = isInArray("slow" /* HoverMode.slow */, options.interactivity.events.onHover.mode); | ||
if (!active) { | ||
return 1; | ||
} | ||
const mousePos = particle.container.interactivity.mouse.position; | ||
if (!mousePos) { | ||
return 1; | ||
} | ||
const particlePos = particle.getPosition(); | ||
const dist = getDistance(mousePos, particlePos); | ||
const radius = container.retina.slowModeRadius; | ||
if (dist > radius) { | ||
return 1; | ||
} | ||
const proximityFactor = dist / radius || 0; | ||
const slowFactor = options.interactivity.modes.slow.factor; | ||
return proximityFactor / slowFactor; | ||
return particle.slow.inRange ? particle.slow.factor : 1; | ||
} |
@@ -46,25 +46,2 @@ "use strict"; | ||
container.retina.reduceFactor, moveDrift = ((_b = (_e = particle.retina).moveDrift) !== null && _b !== void 0 ? _b : (_e.moveDrift = (0, tsparticles_engine_1.getRangeValue)(particle.options.move.drift) * container.retina.pixelRatio)), maxSize = (0, tsparticles_engine_1.getRangeMax)(particleOptions.size.value) * container.retina.pixelRatio, sizeFactor = moveOptions.size ? particle.getRadius() / maxSize : 1, speedFactor = sizeFactor * slowFactor * (delta.factor || 1), diffFactor = 2, moveSpeed = (baseSpeed * speedFactor) / diffFactor; | ||
(0, Utils_1.applyPath)(particle, delta); | ||
const gravityOptions = particle.gravity, gravityFactor = (gravityOptions === null || gravityOptions === void 0 ? void 0 : gravityOptions.enable) && gravityOptions.inverse ? -1 : 1; | ||
if ((gravityOptions === null || gravityOptions === void 0 ? void 0 : gravityOptions.enable) && moveSpeed) { | ||
particle.velocity.y += (gravityFactor * (gravityOptions.acceleration * delta.factor)) / (60 * moveSpeed); | ||
} | ||
if (moveDrift && moveSpeed) { | ||
particle.velocity.x += (moveDrift * delta.factor) / (60 * moveSpeed); | ||
} | ||
const decay = particle.moveDecay; | ||
if (decay != 1) { | ||
particle.velocity.multTo(decay); | ||
} | ||
const velocity = particle.velocity.mult(moveSpeed), maxSpeed = (_c = particle.retina.maxSpeed) !== null && _c !== void 0 ? _c : container.retina.maxSpeed; | ||
if ((gravityOptions === null || gravityOptions === void 0 ? void 0 : gravityOptions.enable) && | ||
maxSpeed > 0 && | ||
((!gravityOptions.inverse && velocity.y >= 0 && velocity.y >= maxSpeed) || | ||
(gravityOptions.inverse && velocity.y <= 0 && velocity.y <= -maxSpeed))) { | ||
velocity.y = gravityFactor * maxSpeed; | ||
if (moveSpeed) { | ||
particle.velocity.y = velocity.y / moveSpeed; | ||
} | ||
} | ||
const zIndexOptions = particle.options.zIndex, zVelocityFactor = (1 - particle.zIndexFactor) ** zIndexOptions.velocityRate; | ||
if (moveOptions.spin.enable) { | ||
@@ -74,2 +51,26 @@ (0, Utils_1.spin)(particle, moveSpeed); | ||
else { | ||
(0, Utils_1.applyPath)(particle, delta); | ||
const gravityOptions = particle.gravity, gravityFactor = (gravityOptions === null || gravityOptions === void 0 ? void 0 : gravityOptions.enable) && gravityOptions.inverse ? -1 : 1; | ||
if ((gravityOptions === null || gravityOptions === void 0 ? void 0 : gravityOptions.enable) && moveSpeed) { | ||
particle.velocity.y += | ||
(gravityFactor * (gravityOptions.acceleration * delta.factor)) / (60 * moveSpeed); | ||
} | ||
if (moveDrift && moveSpeed) { | ||
particle.velocity.x += (moveDrift * delta.factor) / (60 * moveSpeed); | ||
} | ||
const decay = particle.moveDecay; | ||
if (decay != 1) { | ||
particle.velocity.multTo(decay); | ||
} | ||
const velocity = particle.velocity.mult(moveSpeed), maxSpeed = (_c = particle.retina.maxSpeed) !== null && _c !== void 0 ? _c : container.retina.maxSpeed; | ||
if ((gravityOptions === null || gravityOptions === void 0 ? void 0 : gravityOptions.enable) && | ||
maxSpeed > 0 && | ||
((!gravityOptions.inverse && velocity.y >= 0 && velocity.y >= maxSpeed) || | ||
(gravityOptions.inverse && velocity.y <= 0 && velocity.y <= -maxSpeed))) { | ||
velocity.y = gravityFactor * maxSpeed; | ||
if (moveSpeed) { | ||
particle.velocity.y = velocity.y / moveSpeed; | ||
} | ||
} | ||
const zIndexOptions = particle.options.zIndex, zVelocityFactor = (1 - particle.zIndexFactor) ** zIndexOptions.velocityRate; | ||
if (zVelocityFactor != 1) { | ||
@@ -76,0 +77,0 @@ velocity.multTo(zVelocityFactor); |
@@ -81,22 +81,4 @@ "use strict"; | ||
function getProximitySpeedFactor(particle) { | ||
const container = particle.container; | ||
const options = container.actualOptions; | ||
const active = (0, tsparticles_engine_1.isInArray)("slow", options.interactivity.events.onHover.mode); | ||
if (!active) { | ||
return 1; | ||
} | ||
const mousePos = particle.container.interactivity.mouse.position; | ||
if (!mousePos) { | ||
return 1; | ||
} | ||
const particlePos = particle.getPosition(); | ||
const dist = (0, tsparticles_engine_1.getDistance)(mousePos, particlePos); | ||
const radius = container.retina.slowModeRadius; | ||
if (dist > radius) { | ||
return 1; | ||
} | ||
const proximityFactor = dist / radius || 0; | ||
const slowFactor = options.interactivity.modes.slow.factor; | ||
return proximityFactor / slowFactor; | ||
return particle.slow.inRange ? particle.slow.factor : 1; | ||
} | ||
exports.getProximitySpeedFactor = getProximitySpeedFactor; |
@@ -43,25 +43,2 @@ import { getDistance, getRangeMax, getRangeValue } from "tsparticles-engine"; | ||
container.retina.reduceFactor, moveDrift = ((_b = (_e = particle.retina).moveDrift) !== null && _b !== void 0 ? _b : (_e.moveDrift = getRangeValue(particle.options.move.drift) * container.retina.pixelRatio)), maxSize = getRangeMax(particleOptions.size.value) * container.retina.pixelRatio, sizeFactor = moveOptions.size ? particle.getRadius() / maxSize : 1, speedFactor = sizeFactor * slowFactor * (delta.factor || 1), diffFactor = 2, moveSpeed = (baseSpeed * speedFactor) / diffFactor; | ||
applyPath(particle, delta); | ||
const gravityOptions = particle.gravity, gravityFactor = (gravityOptions === null || gravityOptions === void 0 ? void 0 : gravityOptions.enable) && gravityOptions.inverse ? -1 : 1; | ||
if ((gravityOptions === null || gravityOptions === void 0 ? void 0 : gravityOptions.enable) && moveSpeed) { | ||
particle.velocity.y += (gravityFactor * (gravityOptions.acceleration * delta.factor)) / (60 * moveSpeed); | ||
} | ||
if (moveDrift && moveSpeed) { | ||
particle.velocity.x += (moveDrift * delta.factor) / (60 * moveSpeed); | ||
} | ||
const decay = particle.moveDecay; | ||
if (decay != 1) { | ||
particle.velocity.multTo(decay); | ||
} | ||
const velocity = particle.velocity.mult(moveSpeed), maxSpeed = (_c = particle.retina.maxSpeed) !== null && _c !== void 0 ? _c : container.retina.maxSpeed; | ||
if ((gravityOptions === null || gravityOptions === void 0 ? void 0 : gravityOptions.enable) && | ||
maxSpeed > 0 && | ||
((!gravityOptions.inverse && velocity.y >= 0 && velocity.y >= maxSpeed) || | ||
(gravityOptions.inverse && velocity.y <= 0 && velocity.y <= -maxSpeed))) { | ||
velocity.y = gravityFactor * maxSpeed; | ||
if (moveSpeed) { | ||
particle.velocity.y = velocity.y / moveSpeed; | ||
} | ||
} | ||
const zIndexOptions = particle.options.zIndex, zVelocityFactor = (1 - particle.zIndexFactor) ** zIndexOptions.velocityRate; | ||
if (moveOptions.spin.enable) { | ||
@@ -71,2 +48,26 @@ spin(particle, moveSpeed); | ||
else { | ||
applyPath(particle, delta); | ||
const gravityOptions = particle.gravity, gravityFactor = (gravityOptions === null || gravityOptions === void 0 ? void 0 : gravityOptions.enable) && gravityOptions.inverse ? -1 : 1; | ||
if ((gravityOptions === null || gravityOptions === void 0 ? void 0 : gravityOptions.enable) && moveSpeed) { | ||
particle.velocity.y += | ||
(gravityFactor * (gravityOptions.acceleration * delta.factor)) / (60 * moveSpeed); | ||
} | ||
if (moveDrift && moveSpeed) { | ||
particle.velocity.x += (moveDrift * delta.factor) / (60 * moveSpeed); | ||
} | ||
const decay = particle.moveDecay; | ||
if (decay != 1) { | ||
particle.velocity.multTo(decay); | ||
} | ||
const velocity = particle.velocity.mult(moveSpeed), maxSpeed = (_c = particle.retina.maxSpeed) !== null && _c !== void 0 ? _c : container.retina.maxSpeed; | ||
if ((gravityOptions === null || gravityOptions === void 0 ? void 0 : gravityOptions.enable) && | ||
maxSpeed > 0 && | ||
((!gravityOptions.inverse && velocity.y >= 0 && velocity.y >= maxSpeed) || | ||
(gravityOptions.inverse && velocity.y <= 0 && velocity.y <= -maxSpeed))) { | ||
velocity.y = gravityFactor * maxSpeed; | ||
if (moveSpeed) { | ||
particle.velocity.y = velocity.y / moveSpeed; | ||
} | ||
} | ||
const zIndexOptions = particle.options.zIndex, zVelocityFactor = (1 - particle.zIndexFactor) ** zIndexOptions.velocityRate; | ||
if (zVelocityFactor != 1) { | ||
@@ -73,0 +74,0 @@ velocity.multTo(zVelocityFactor); |
@@ -1,2 +0,2 @@ | ||
import { clamp, getDistance, getDistances, getRandom, isInArray } from "tsparticles-engine"; | ||
import { clamp, getDistances, getRandom } from "tsparticles-engine"; | ||
export function applyDistance(particle) { | ||
@@ -75,21 +75,3 @@ const initialPosition = particle.initialPosition, { dx, dy } = getDistances(initialPosition, particle.position), dxFixed = Math.abs(dx), dyFixed = Math.abs(dy), hDistance = particle.retina.maxDistance.horizontal, vDistance = particle.retina.maxDistance.vertical; | ||
export function getProximitySpeedFactor(particle) { | ||
const container = particle.container; | ||
const options = container.actualOptions; | ||
const active = isInArray("slow", options.interactivity.events.onHover.mode); | ||
if (!active) { | ||
return 1; | ||
} | ||
const mousePos = particle.container.interactivity.mouse.position; | ||
if (!mousePos) { | ||
return 1; | ||
} | ||
const particlePos = particle.getPosition(); | ||
const dist = getDistance(mousePos, particlePos); | ||
const radius = container.retina.slowModeRadius; | ||
if (dist > radius) { | ||
return 1; | ||
} | ||
const proximityFactor = dist / radius || 0; | ||
const slowFactor = options.interactivity.modes.slow.factor; | ||
return proximityFactor / slowFactor; | ||
return particle.slow.inRange ? particle.slow.factor : 1; | ||
} |
{ | ||
"name": "tsparticles-move-base", | ||
"version": "2.2.4", | ||
"version": "2.3.0", | ||
"description": "tsParticles Base movement", | ||
@@ -77,4 +77,4 @@ "homepage": "https://particles.js.org", | ||
"dependencies": { | ||
"tsparticles-engine": "^2.2.4" | ||
"tsparticles-engine": "^2.3.0" | ||
} | ||
} |
@@ -7,3 +7,3 @@ /*! | ||
* How to use? : Check the GitHub README | ||
* v2.2.4 | ||
* v2.3.0 | ||
*/ | ||
@@ -19,3 +19,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
} | ||
})(this, function(__WEBPACK_EXTERNAL_MODULE__818__) { | ||
})(this, function(__WEBPACK_EXTERNAL_MODULE__961__) { | ||
return /******/ (function() { // webpackBootstrap | ||
@@ -25,6 +25,6 @@ /******/ "use strict"; | ||
/***/ 818: | ||
/***/ 961: | ||
/***/ (function(module) { | ||
module.exports = __WEBPACK_EXTERNAL_MODULE__818__; | ||
module.exports = __WEBPACK_EXTERNAL_MODULE__961__; | ||
@@ -101,3 +101,3 @@ /***/ }) | ||
// EXTERNAL MODULE: external {"commonjs":"tsparticles-engine","commonjs2":"tsparticles-engine","amd":"tsparticles-engine","root":"window"} | ||
var external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_ = __webpack_require__(818); | ||
var external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_ = __webpack_require__(961); | ||
;// CONCATENATED MODULE: ./dist/browser/Utils.js | ||
@@ -205,29 +205,3 @@ | ||
function getProximitySpeedFactor(particle) { | ||
const container = particle.container; | ||
const options = container.actualOptions; | ||
const active = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.isInArray)("slow" | ||
/* HoverMode.slow */ | ||
, options.interactivity.events.onHover.mode); | ||
if (!active) { | ||
return 1; | ||
} | ||
const mousePos = particle.container.interactivity.mouse.position; | ||
if (!mousePos) { | ||
return 1; | ||
} | ||
const particlePos = particle.getPosition(); | ||
const dist = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getDistance)(mousePos, particlePos); | ||
const radius = container.retina.slowModeRadius; | ||
if (dist > radius) { | ||
return 1; | ||
} | ||
const proximityFactor = dist / radius || 0; | ||
const slowFactor = options.interactivity.modes.slow.factor; | ||
return proximityFactor / slowFactor; | ||
return particle.slow.inRange ? particle.slow.factor : 1; | ||
} | ||
@@ -303,37 +277,38 @@ ;// CONCATENATED MODULE: ./dist/browser/BaseMover.js | ||
moveSpeed = baseSpeed * speedFactor / diffFactor; | ||
applyPath(particle, delta); | ||
const gravityOptions = particle.gravity, | ||
gravityFactor = (gravityOptions === null || gravityOptions === void 0 ? void 0 : gravityOptions.enable) && gravityOptions.inverse ? -1 : 1; | ||
if ((gravityOptions === null || gravityOptions === void 0 ? void 0 : gravityOptions.enable) && moveSpeed) { | ||
particle.velocity.y += gravityFactor * (gravityOptions.acceleration * delta.factor) / (60 * moveSpeed); | ||
} | ||
if (moveOptions.spin.enable) { | ||
spin(particle, moveSpeed); | ||
} else { | ||
applyPath(particle, delta); | ||
const gravityOptions = particle.gravity, | ||
gravityFactor = (gravityOptions === null || gravityOptions === void 0 ? void 0 : gravityOptions.enable) && gravityOptions.inverse ? -1 : 1; | ||
if (moveDrift && moveSpeed) { | ||
particle.velocity.x += moveDrift * delta.factor / (60 * moveSpeed); | ||
} | ||
if ((gravityOptions === null || gravityOptions === void 0 ? void 0 : gravityOptions.enable) && moveSpeed) { | ||
particle.velocity.y += gravityFactor * (gravityOptions.acceleration * delta.factor) / (60 * moveSpeed); | ||
} | ||
const decay = particle.moveDecay; | ||
if (moveDrift && moveSpeed) { | ||
particle.velocity.x += moveDrift * delta.factor / (60 * moveSpeed); | ||
} | ||
if (decay != 1) { | ||
particle.velocity.multTo(decay); | ||
} | ||
const decay = particle.moveDecay; | ||
const velocity = particle.velocity.mult(moveSpeed), | ||
maxSpeed = (_c = particle.retina.maxSpeed) !== null && _c !== void 0 ? _c : container.retina.maxSpeed; | ||
if (decay != 1) { | ||
particle.velocity.multTo(decay); | ||
} | ||
if ((gravityOptions === null || gravityOptions === void 0 ? void 0 : gravityOptions.enable) && maxSpeed > 0 && (!gravityOptions.inverse && velocity.y >= 0 && velocity.y >= maxSpeed || gravityOptions.inverse && velocity.y <= 0 && velocity.y <= -maxSpeed)) { | ||
velocity.y = gravityFactor * maxSpeed; | ||
const velocity = particle.velocity.mult(moveSpeed), | ||
maxSpeed = (_c = particle.retina.maxSpeed) !== null && _c !== void 0 ? _c : container.retina.maxSpeed; | ||
if (moveSpeed) { | ||
particle.velocity.y = velocity.y / moveSpeed; | ||
if ((gravityOptions === null || gravityOptions === void 0 ? void 0 : gravityOptions.enable) && maxSpeed > 0 && (!gravityOptions.inverse && velocity.y >= 0 && velocity.y >= maxSpeed || gravityOptions.inverse && velocity.y <= 0 && velocity.y <= -maxSpeed)) { | ||
velocity.y = gravityFactor * maxSpeed; | ||
if (moveSpeed) { | ||
particle.velocity.y = velocity.y / moveSpeed; | ||
} | ||
} | ||
} | ||
const zIndexOptions = particle.options.zIndex, | ||
zVelocityFactor = (1 - particle.zIndexFactor) ** zIndexOptions.velocityRate; | ||
const zIndexOptions = particle.options.zIndex, | ||
zVelocityFactor = (1 - particle.zIndexFactor) ** zIndexOptions.velocityRate; | ||
if (moveOptions.spin.enable) { | ||
spin(particle, moveSpeed); | ||
} else { | ||
if (zVelocityFactor != 1) { | ||
@@ -340,0 +315,0 @@ velocity.multTo(zVelocityFactor); |
/*! For license information please see tsparticles.move.base.min.js.LICENSE.txt */ | ||
!function(e,i){if("object"==typeof exports&&"object"==typeof module)module.exports=i(require("tsparticles-engine"));else if("function"==typeof define&&define.amd)define(["tsparticles-engine"],i);else{var t="object"==typeof exports?i(require("tsparticles-engine")):i(e.window);for(var n in t)("object"==typeof exports?exports:e)[n]=t[n]}}(this,(function(e){return function(){"use strict";var i={818:function(i){i.exports=e}},t={};function n(e){var o=t[e];if(void 0!==o)return o.exports;var a=t[e]={exports:{}};return i[e](a,a.exports,n),a.exports}n.d=function(e,i){for(var t in i)n.o(i,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:i[t]})},n.o=function(e,i){return Object.prototype.hasOwnProperty.call(e,i)},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return function(){n.r(o),n.d(o,{loadBaseMover:function(){return t}});var e=n(818);class i{init(i){var t;const n=i.container,o=i.options,a=o.move.gravity,s=o.move.spin;if(i.gravity={enable:a.enable,acceleration:(0,e.getRangeValue)(a.acceleration),inverse:a.inverse},s.enable){const o=null!==(t=s.position)&&void 0!==t?t:{x:50,y:50},a={x:o.x/100*n.canvas.size.width,y:o.y/100*n.canvas.size.height},r=i.getPosition(),c=(0,e.getDistance)(r,a),l=(0,e.getRangeValue)(s.acceleration);i.retina.spinAcceleration=l*n.retina.pixelRatio,i.spin={center:a,direction:i.velocity.x>=0?"clockwise":"counter-clockwise",angle:i.velocity.angle,radius:c,acceleration:i.retina.spinAcceleration}}}isEnabled(e){return!e.destroyed&&e.options.move.enable}move(i,t){var n,o,a,s,r;const c=i.options,l=c.move;if(!l.enable)return;const p=i.container,v=function(i){const t=i.container,n=t.actualOptions;if(!(0,e.isInArray)("slow",n.interactivity.events.onHover.mode))return 1;const o=i.container.interactivity.mouse.position;if(!o)return 1;const a=i.getPosition(),s=(0,e.getDistance)(o,a),r=t.retina.slowModeRadius;return s>r?1:(s/r||0)/n.interactivity.modes.slow.factor}(i),y=(null!==(n=(s=i.retina).moveSpeed)&&void 0!==n?n:s.moveSpeed=(0,e.getRangeValue)(l.speed)*p.retina.pixelRatio)*p.retina.reduceFactor,d=null!==(o=(r=i.retina).moveDrift)&&void 0!==o?o:r.moveDrift=(0,e.getRangeValue)(i.options.move.drift)*p.retina.pixelRatio,u=(0,e.getRangeMax)(c.size.value)*p.retina.pixelRatio,f=y*((l.size?i.getRadius()/u:1)*v*(t.factor||1))/2;!function(i,t){var n;const o=i.options.move.path;if(!o.enable)return;if(i.lastPathTime<=i.pathDelay)return void(i.lastPathTime+=t.value);const a=null===(n=i.pathGenerator)||void 0===n?void 0:n.generate(i);a&&i.velocity.addTo(a),o.clamp&&(i.velocity.x=(0,e.clamp)(i.velocity.x,-1,1),i.velocity.y=(0,e.clamp)(i.velocity.y,-1,1)),i.lastPathTime-=i.pathDelay}(i,t);const x=i.gravity,m=(null==x?void 0:x.enable)&&x.inverse?-1:1;(null==x?void 0:x.enable)&&f&&(i.velocity.y+=m*(x.acceleration*t.factor)/(60*f)),d&&f&&(i.velocity.x+=d*t.factor/(60*f));const g=i.moveDecay;1!=g&&i.velocity.multTo(g);const b=i.velocity.mult(f),h=null!==(a=i.retina.maxSpeed)&&void 0!==a?a:p.retina.maxSpeed;(null==x?void 0:x.enable)&&h>0&&(!x.inverse&&b.y>=0&&b.y>=h||x.inverse&&b.y<=0&&b.y<=-h)&&(b.y=m*h,f&&(i.velocity.y=b.y/f));const M=i.options.zIndex,R=(1-i.zIndexFactor)**M.velocityRate;l.spin.enable?function(e,i){const t=e.container;if(!e.spin)return;const n={x:"clockwise"===e.spin.direction?Math.cos:Math.sin,y:"clockwise"===e.spin.direction?Math.sin:Math.cos};e.position.x=e.spin.center.x+e.spin.radius*n.x(e.spin.angle),e.position.y=e.spin.center.y+e.spin.radius*n.y(e.spin.angle),e.spin.radius+=e.spin.acceleration;const o=Math.max(t.canvas.size.width,t.canvas.size.height);e.spin.radius>o/2?(e.spin.radius=o/2,e.spin.acceleration*=-1):e.spin.radius<0&&(e.spin.radius=0,e.spin.acceleration*=-1),e.spin.angle+=i/100*(1-e.spin.radius/o)}(i,f):(1!=R&&b.multTo(R),i.position.addTo(b),l.vibrate&&(i.position.x+=Math.sin(i.position.x*Math.cos(i.position.y)),i.position.y+=Math.cos(i.position.y*Math.sin(i.position.x)))),function(i){const t=i.initialPosition,{dx:n,dy:o}=(0,e.getDistances)(t,i.position),a=Math.abs(n),s=Math.abs(o),r=i.retina.maxDistance.horizontal,c=i.retina.maxDistance.vertical;if(r||c)if((r&&a>=r||c&&s>=c)&&!i.misplaced)i.misplaced=!!r&&a>r||!!c&&s>c,r&&(i.velocity.x=i.velocity.y/2-i.velocity.x),c&&(i.velocity.y=i.velocity.x/2-i.velocity.y);else if((!r||a<r)&&(!c||s<c)&&i.misplaced)i.misplaced=!1;else if(i.misplaced){const n=i.position,o=i.velocity;r&&(n.x<t.x&&o.x<0||n.x>t.x&&o.x>0)&&(o.x*=-(0,e.getRandom)()),c&&(n.y<t.y&&o.y<0||n.y>t.y&&o.y>0)&&(o.y*=-(0,e.getRandom)())}}(i)}}async function t(e){e.addMover("base",(()=>new i))}}(),o}()})); | ||
!function(e,i){if("object"==typeof exports&&"object"==typeof module)module.exports=i(require("tsparticles-engine"));else if("function"==typeof define&&define.amd)define(["tsparticles-engine"],i);else{var t="object"==typeof exports?i(require("tsparticles-engine")):i(e.window);for(var n in t)("object"==typeof exports?exports:e)[n]=t[n]}}(this,(function(e){return function(){"use strict";var i={961:function(i){i.exports=e}},t={};function n(e){var o=t[e];if(void 0!==o)return o.exports;var a=t[e]={exports:{}};return i[e](a,a.exports,n),a.exports}n.d=function(e,i){for(var t in i)n.o(i,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:i[t]})},n.o=function(e,i){return Object.prototype.hasOwnProperty.call(e,i)},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return function(){n.r(o),n.d(o,{loadBaseMover:function(){return t}});var e=n(961);class i{init(i){var t;const n=i.container,o=i.options,a=o.move.gravity,s=o.move.spin;if(i.gravity={enable:a.enable,acceleration:(0,e.getRangeValue)(a.acceleration),inverse:a.inverse},s.enable){const o=null!==(t=s.position)&&void 0!==t?t:{x:50,y:50},a={x:o.x/100*n.canvas.size.width,y:o.y/100*n.canvas.size.height},r=i.getPosition(),c=(0,e.getDistance)(r,a),l=(0,e.getRangeValue)(s.acceleration);i.retina.spinAcceleration=l*n.retina.pixelRatio,i.spin={center:a,direction:i.velocity.x>=0?"clockwise":"counter-clockwise",angle:i.velocity.angle,radius:c,acceleration:i.retina.spinAcceleration}}}isEnabled(e){return!e.destroyed&&e.options.move.enable}move(i,t){var n,o,a,s,r;const c=i.options,l=c.move;if(!l.enable)return;const p=i.container,v=function(e){return e.slow.inRange?e.slow.factor:1}(i),y=(null!==(n=(s=i.retina).moveSpeed)&&void 0!==n?n:s.moveSpeed=(0,e.getRangeValue)(l.speed)*p.retina.pixelRatio)*p.retina.reduceFactor,d=null!==(o=(r=i.retina).moveDrift)&&void 0!==o?o:r.moveDrift=(0,e.getRangeValue)(i.options.move.drift)*p.retina.pixelRatio,u=(0,e.getRangeMax)(c.size.value)*p.retina.pixelRatio,f=y*((l.size?i.getRadius()/u:1)*v*(t.factor||1))/2;if(l.spin.enable)!function(e,i){const t=e.container;if(!e.spin)return;const n={x:"clockwise"===e.spin.direction?Math.cos:Math.sin,y:"clockwise"===e.spin.direction?Math.sin:Math.cos};e.position.x=e.spin.center.x+e.spin.radius*n.x(e.spin.angle),e.position.y=e.spin.center.y+e.spin.radius*n.y(e.spin.angle),e.spin.radius+=e.spin.acceleration;const o=Math.max(t.canvas.size.width,t.canvas.size.height);e.spin.radius>o/2?(e.spin.radius=o/2,e.spin.acceleration*=-1):e.spin.radius<0&&(e.spin.radius=0,e.spin.acceleration*=-1),e.spin.angle+=i/100*(1-e.spin.radius/o)}(i,f);else{!function(i,t){var n;const o=i.options.move.path;if(!o.enable)return;if(i.lastPathTime<=i.pathDelay)return void(i.lastPathTime+=t.value);const a=null===(n=i.pathGenerator)||void 0===n?void 0:n.generate(i);a&&i.velocity.addTo(a),o.clamp&&(i.velocity.x=(0,e.clamp)(i.velocity.x,-1,1),i.velocity.y=(0,e.clamp)(i.velocity.y,-1,1)),i.lastPathTime-=i.pathDelay}(i,t);const n=i.gravity,o=(null==n?void 0:n.enable)&&n.inverse?-1:1;(null==n?void 0:n.enable)&&f&&(i.velocity.y+=o*(n.acceleration*t.factor)/(60*f)),d&&f&&(i.velocity.x+=d*t.factor/(60*f));const s=i.moveDecay;1!=s&&i.velocity.multTo(s);const r=i.velocity.mult(f),c=null!==(a=i.retina.maxSpeed)&&void 0!==a?a:p.retina.maxSpeed;(null==n?void 0:n.enable)&&c>0&&(!n.inverse&&r.y>=0&&r.y>=c||n.inverse&&r.y<=0&&r.y<=-c)&&(r.y=o*c,f&&(i.velocity.y=r.y/f));const v=i.options.zIndex,y=(1-i.zIndexFactor)**v.velocityRate;1!=y&&r.multTo(y),i.position.addTo(r),l.vibrate&&(i.position.x+=Math.sin(i.position.x*Math.cos(i.position.y)),i.position.y+=Math.cos(i.position.y*Math.sin(i.position.x)))}!function(i){const t=i.initialPosition,{dx:n,dy:o}=(0,e.getDistances)(t,i.position),a=Math.abs(n),s=Math.abs(o),r=i.retina.maxDistance.horizontal,c=i.retina.maxDistance.vertical;if(r||c)if((r&&a>=r||c&&s>=c)&&!i.misplaced)i.misplaced=!!r&&a>r||!!c&&s>c,r&&(i.velocity.x=i.velocity.y/2-i.velocity.x),c&&(i.velocity.y=i.velocity.x/2-i.velocity.y);else if((!r||a<r)&&(!c||s<c)&&i.misplaced)i.misplaced=!1;else if(i.misplaced){const n=i.position,o=i.velocity;r&&(n.x<t.x&&o.x<0||n.x>t.x&&o.x>0)&&(o.x*=-(0,e.getRandom)()),c&&(n.y<t.y&&o.y<0||n.y>t.y&&o.y>0)&&(o.y*=-(0,e.getRandom)())}}(i)}}async function t(e){e.addMover("base",(()=>new i))}}(),o}()})); |
@@ -7,3 +7,3 @@ /*! | ||
* How to use? : Check the GitHub README | ||
* v2.2.4 | ||
* v2.3.0 | ||
*/ |
@@ -55,25 +55,2 @@ (function (factory) { | ||
container.retina.reduceFactor, moveDrift = ((_b = (_e = particle.retina).moveDrift) !== null && _b !== void 0 ? _b : (_e.moveDrift = (0, tsparticles_engine_1.getRangeValue)(particle.options.move.drift) * container.retina.pixelRatio)), maxSize = (0, tsparticles_engine_1.getRangeMax)(particleOptions.size.value) * container.retina.pixelRatio, sizeFactor = moveOptions.size ? particle.getRadius() / maxSize : 1, speedFactor = sizeFactor * slowFactor * (delta.factor || 1), diffFactor = 2, moveSpeed = (baseSpeed * speedFactor) / diffFactor; | ||
(0, Utils_1.applyPath)(particle, delta); | ||
const gravityOptions = particle.gravity, gravityFactor = (gravityOptions === null || gravityOptions === void 0 ? void 0 : gravityOptions.enable) && gravityOptions.inverse ? -1 : 1; | ||
if ((gravityOptions === null || gravityOptions === void 0 ? void 0 : gravityOptions.enable) && moveSpeed) { | ||
particle.velocity.y += (gravityFactor * (gravityOptions.acceleration * delta.factor)) / (60 * moveSpeed); | ||
} | ||
if (moveDrift && moveSpeed) { | ||
particle.velocity.x += (moveDrift * delta.factor) / (60 * moveSpeed); | ||
} | ||
const decay = particle.moveDecay; | ||
if (decay != 1) { | ||
particle.velocity.multTo(decay); | ||
} | ||
const velocity = particle.velocity.mult(moveSpeed), maxSpeed = (_c = particle.retina.maxSpeed) !== null && _c !== void 0 ? _c : container.retina.maxSpeed; | ||
if ((gravityOptions === null || gravityOptions === void 0 ? void 0 : gravityOptions.enable) && | ||
maxSpeed > 0 && | ||
((!gravityOptions.inverse && velocity.y >= 0 && velocity.y >= maxSpeed) || | ||
(gravityOptions.inverse && velocity.y <= 0 && velocity.y <= -maxSpeed))) { | ||
velocity.y = gravityFactor * maxSpeed; | ||
if (moveSpeed) { | ||
particle.velocity.y = velocity.y / moveSpeed; | ||
} | ||
} | ||
const zIndexOptions = particle.options.zIndex, zVelocityFactor = (1 - particle.zIndexFactor) ** zIndexOptions.velocityRate; | ||
if (moveOptions.spin.enable) { | ||
@@ -83,2 +60,26 @@ (0, Utils_1.spin)(particle, moveSpeed); | ||
else { | ||
(0, Utils_1.applyPath)(particle, delta); | ||
const gravityOptions = particle.gravity, gravityFactor = (gravityOptions === null || gravityOptions === void 0 ? void 0 : gravityOptions.enable) && gravityOptions.inverse ? -1 : 1; | ||
if ((gravityOptions === null || gravityOptions === void 0 ? void 0 : gravityOptions.enable) && moveSpeed) { | ||
particle.velocity.y += | ||
(gravityFactor * (gravityOptions.acceleration * delta.factor)) / (60 * moveSpeed); | ||
} | ||
if (moveDrift && moveSpeed) { | ||
particle.velocity.x += (moveDrift * delta.factor) / (60 * moveSpeed); | ||
} | ||
const decay = particle.moveDecay; | ||
if (decay != 1) { | ||
particle.velocity.multTo(decay); | ||
} | ||
const velocity = particle.velocity.mult(moveSpeed), maxSpeed = (_c = particle.retina.maxSpeed) !== null && _c !== void 0 ? _c : container.retina.maxSpeed; | ||
if ((gravityOptions === null || gravityOptions === void 0 ? void 0 : gravityOptions.enable) && | ||
maxSpeed > 0 && | ||
((!gravityOptions.inverse && velocity.y >= 0 && velocity.y >= maxSpeed) || | ||
(gravityOptions.inverse && velocity.y <= 0 && velocity.y <= -maxSpeed))) { | ||
velocity.y = gravityFactor * maxSpeed; | ||
if (moveSpeed) { | ||
particle.velocity.y = velocity.y / moveSpeed; | ||
} | ||
} | ||
const zIndexOptions = particle.options.zIndex, zVelocityFactor = (1 - particle.zIndexFactor) ** zIndexOptions.velocityRate; | ||
if (zVelocityFactor != 1) { | ||
@@ -85,0 +86,0 @@ velocity.multTo(zVelocityFactor); |
@@ -90,23 +90,5 @@ (function (factory) { | ||
function getProximitySpeedFactor(particle) { | ||
const container = particle.container; | ||
const options = container.actualOptions; | ||
const active = (0, tsparticles_engine_1.isInArray)("slow", options.interactivity.events.onHover.mode); | ||
if (!active) { | ||
return 1; | ||
} | ||
const mousePos = particle.container.interactivity.mouse.position; | ||
if (!mousePos) { | ||
return 1; | ||
} | ||
const particlePos = particle.getPosition(); | ||
const dist = (0, tsparticles_engine_1.getDistance)(mousePos, particlePos); | ||
const radius = container.retina.slowModeRadius; | ||
if (dist > radius) { | ||
return 1; | ||
} | ||
const proximityFactor = dist / radius || 0; | ||
const slowFactor = options.interactivity.modes.slow.factor; | ||
return proximityFactor / slowFactor; | ||
return particle.slow.inRange ? particle.slow.factor : 1; | ||
} | ||
exports.getProximitySpeedFactor = getProximitySpeedFactor; | ||
}); |
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
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
339329
1088
Updatedtsparticles-engine@^2.3.0