tsparticles-move-base
Advanced tools
Comparing version 2.3.3 to 2.4.0
@@ -13,14 +13,10 @@ import { getDistance, getRangeMax, getRangeValue } from "tsparticles-engine"; | ||
if (spinOptions.enable) { | ||
const spinPos = (_a = spinOptions.position) !== null && _a !== void 0 ? _a : { x: 50, y: 50 }; | ||
const spinCenter = { | ||
const spinPos = (_a = spinOptions.position) !== null && _a !== void 0 ? _a : { x: 50, y: 50 }, spinCenter = { | ||
x: (spinPos.x / 100) * container.canvas.size.width, | ||
y: (spinPos.y / 100) * container.canvas.size.height, | ||
}; | ||
const pos = particle.getPosition(); | ||
const distance = getDistance(pos, spinCenter); | ||
const spinAcceleration = getRangeValue(spinOptions.acceleration); | ||
}, pos = particle.getPosition(), distance = getDistance(pos, spinCenter), spinAcceleration = getRangeValue(spinOptions.acceleration); | ||
particle.retina.spinAcceleration = spinAcceleration * container.retina.pixelRatio; | ||
particle.spin = { | ||
center: spinCenter, | ||
direction: particle.velocity.x >= 0 ? "clockwise" /* RotateDirection.clockwise */ : "counter-clockwise" /* RotateDirection.counterClockwise */, | ||
direction: particle.velocity.x >= 0 ? "clockwise" : "counter-clockwise", | ||
angle: particle.velocity.angle, | ||
@@ -27,0 +23,0 @@ radius: distance, |
@@ -35,4 +35,4 @@ import { clamp, getDistances, getRandom } from "tsparticles-engine"; | ||
const updateFunc = { | ||
x: particle.spin.direction === "clockwise" /* RotateDirection.clockwise */ ? Math.cos : Math.sin, | ||
y: particle.spin.direction === "clockwise" /* RotateDirection.clockwise */ ? Math.sin : Math.cos, | ||
x: particle.spin.direction === "clockwise" ? Math.cos : Math.sin, | ||
y: particle.spin.direction === "clockwise" ? Math.sin : Math.cos, | ||
}; | ||
@@ -55,5 +55,3 @@ particle.position.x = particle.spin.center.x + particle.spin.radius * updateFunc.x(particle.spin.angle); | ||
var _a; | ||
const particlesOptions = particle.options; | ||
const pathOptions = particlesOptions.move.path; | ||
const pathEnabled = pathOptions.enable; | ||
const particlesOptions = particle.options, pathOptions = particlesOptions.move.path, pathEnabled = pathOptions.enable; | ||
if (!pathEnabled) { | ||
@@ -60,0 +58,0 @@ return; |
@@ -16,10 +16,6 @@ "use strict"; | ||
if (spinOptions.enable) { | ||
const spinPos = (_a = spinOptions.position) !== null && _a !== void 0 ? _a : { x: 50, y: 50 }; | ||
const spinCenter = { | ||
const spinPos = (_a = spinOptions.position) !== null && _a !== void 0 ? _a : { x: 50, y: 50 }, spinCenter = { | ||
x: (spinPos.x / 100) * container.canvas.size.width, | ||
y: (spinPos.y / 100) * container.canvas.size.height, | ||
}; | ||
const pos = particle.getPosition(); | ||
const distance = (0, tsparticles_engine_1.getDistance)(pos, spinCenter); | ||
const spinAcceleration = (0, tsparticles_engine_1.getRangeValue)(spinOptions.acceleration); | ||
}, pos = particle.getPosition(), distance = (0, tsparticles_engine_1.getDistance)(pos, spinCenter), spinAcceleration = (0, tsparticles_engine_1.getRangeValue)(spinOptions.acceleration); | ||
particle.retina.spinAcceleration = spinAcceleration * container.retina.pixelRatio; | ||
@@ -74,3 +70,3 @@ particle.spin = { | ||
} | ||
const zIndexOptions = particle.options.zIndex, zVelocityFactor = (1 - particle.zIndexFactor) ** zIndexOptions.velocityRate; | ||
const zIndexOptions = particle.options.zIndex, zVelocityFactor = Math.pow((1 - particle.zIndexFactor), zIndexOptions.velocityRate); | ||
if (zVelocityFactor != 1) { | ||
@@ -77,0 +73,0 @@ velocity.multTo(zVelocityFactor); |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.loadBaseMover = void 0; | ||
const BaseMover_1 = require("./BaseMover"); | ||
async function loadBaseMover(engine) { | ||
engine.addMover("base", () => new BaseMover_1.BaseMover()); | ||
function loadBaseMover(engine) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
engine.addMover("base", () => new BaseMover_1.BaseMover()); | ||
}); | ||
} | ||
exports.loadBaseMover = loadBaseMover; |
@@ -59,5 +59,3 @@ "use strict"; | ||
var _a; | ||
const particlesOptions = particle.options; | ||
const pathOptions = particlesOptions.move.path; | ||
const pathEnabled = pathOptions.enable; | ||
const particlesOptions = particle.options, pathOptions = particlesOptions.move.path, pathEnabled = pathOptions.enable; | ||
if (!pathEnabled) { | ||
@@ -64,0 +62,0 @@ return; |
@@ -13,10 +13,6 @@ import { getDistance, getRangeMax, getRangeValue } from "tsparticles-engine"; | ||
if (spinOptions.enable) { | ||
const spinPos = (_a = spinOptions.position) !== null && _a !== void 0 ? _a : { x: 50, y: 50 }; | ||
const spinCenter = { | ||
const spinPos = (_a = spinOptions.position) !== null && _a !== void 0 ? _a : { x: 50, y: 50 }, spinCenter = { | ||
x: (spinPos.x / 100) * container.canvas.size.width, | ||
y: (spinPos.y / 100) * container.canvas.size.height, | ||
}; | ||
const pos = particle.getPosition(); | ||
const distance = getDistance(pos, spinCenter); | ||
const spinAcceleration = getRangeValue(spinOptions.acceleration); | ||
}, pos = particle.getPosition(), distance = getDistance(pos, spinCenter), spinAcceleration = getRangeValue(spinOptions.acceleration); | ||
particle.retina.spinAcceleration = spinAcceleration * container.retina.pixelRatio; | ||
@@ -23,0 +19,0 @@ particle.spin = { |
@@ -54,5 +54,3 @@ import { clamp, getDistances, getRandom } from "tsparticles-engine"; | ||
var _a; | ||
const particlesOptions = particle.options; | ||
const pathOptions = particlesOptions.move.path; | ||
const pathEnabled = pathOptions.enable; | ||
const particlesOptions = particle.options, pathOptions = particlesOptions.move.path, pathEnabled = pathOptions.enable; | ||
if (!pathEnabled) { | ||
@@ -59,0 +57,0 @@ return; |
{ | ||
"name": "tsparticles-move-base", | ||
"version": "2.3.3", | ||
"version": "2.4.0", | ||
"description": "tsParticles Base movement", | ||
@@ -77,4 +77,4 @@ "homepage": "https://particles.js.org", | ||
"dependencies": { | ||
"tsparticles-engine": "^2.3.3" | ||
"tsparticles-engine": "^2.4.0" | ||
} | ||
} |
@@ -7,3 +7,3 @@ /*! | ||
* How to use? : Check the GitHub README | ||
* v2.3.3 | ||
* v2.4.0 | ||
*/ | ||
@@ -19,4 +19,4 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
} | ||
})(this, function(__WEBPACK_EXTERNAL_MODULE__961__) { | ||
return /******/ (function() { // webpackBootstrap | ||
})(this, (__WEBPACK_EXTERNAL_MODULE__961__) => { | ||
return /******/ (() => { // webpackBootstrap | ||
/******/ "use strict"; | ||
@@ -26,3 +26,3 @@ /******/ var __webpack_modules__ = ({ | ||
/***/ 961: | ||
/***/ (function(module) { | ||
/***/ ((module) => { | ||
@@ -61,5 +61,5 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__961__; | ||
/******/ /* webpack/runtime/define property getters */ | ||
/******/ !function() { | ||
/******/ (() => { | ||
/******/ // define getter functions for harmony exports | ||
/******/ __webpack_require__.d = function(exports, definition) { | ||
/******/ __webpack_require__.d = (exports, definition) => { | ||
/******/ for(var key in definition) { | ||
@@ -71,13 +71,13 @@ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { | ||
/******/ }; | ||
/******/ }(); | ||
/******/ })(); | ||
/******/ | ||
/******/ /* webpack/runtime/hasOwnProperty shorthand */ | ||
/******/ !function() { | ||
/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } | ||
/******/ }(); | ||
/******/ (() => { | ||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) | ||
/******/ })(); | ||
/******/ | ||
/******/ /* webpack/runtime/make namespace object */ | ||
/******/ !function() { | ||
/******/ (() => { | ||
/******/ // define __esModule on exports | ||
/******/ __webpack_require__.r = function(exports) { | ||
/******/ __webpack_require__.r = (exports) => { | ||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { | ||
@@ -88,3 +88,3 @@ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
/******/ }; | ||
/******/ }(); | ||
/******/ })(); | ||
/******/ | ||
@@ -94,3 +94,3 @@ /************************************************************************/ | ||
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. | ||
!function() { | ||
(() => { | ||
// ESM COMPAT FLAG | ||
@@ -101,3 +101,3 @@ __webpack_require__.r(__webpack_exports__); | ||
__webpack_require__.d(__webpack_exports__, { | ||
"loadBaseMover": function() { return /* binding */ loadBaseMover; } | ||
"loadBaseMover": () => (/* binding */ loadBaseMover) | ||
}); | ||
@@ -111,22 +111,18 @@ | ||
const initialPosition = particle.initialPosition, | ||
{ | ||
dx, | ||
dy | ||
} = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getDistances)(initialPosition, particle.position), | ||
dxFixed = Math.abs(dx), | ||
dyFixed = Math.abs(dy), | ||
hDistance = particle.retina.maxDistance.horizontal, | ||
vDistance = particle.retina.maxDistance.vertical; | ||
{ | ||
dx, | ||
dy | ||
} = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getDistances)(initialPosition, particle.position), | ||
dxFixed = Math.abs(dx), | ||
dyFixed = Math.abs(dy), | ||
hDistance = particle.retina.maxDistance.horizontal, | ||
vDistance = particle.retina.maxDistance.vertical; | ||
if (!hDistance && !vDistance) { | ||
return; | ||
} | ||
if ((hDistance && dxFixed >= hDistance || vDistance && dyFixed >= vDistance) && !particle.misplaced) { | ||
particle.misplaced = !!hDistance && dxFixed > hDistance || !!vDistance && dyFixed > vDistance; | ||
if (hDistance) { | ||
particle.velocity.x = particle.velocity.y / 2 - particle.velocity.x; | ||
} | ||
if (vDistance) { | ||
@@ -139,8 +135,6 @@ particle.velocity.y = particle.velocity.x / 2 - particle.velocity.y; | ||
const pos = particle.position, | ||
vel = particle.velocity; | ||
vel = particle.velocity; | ||
if (hDistance && (pos.x < initialPosition.x && vel.x < 0 || pos.x > initialPosition.x && vel.x > 0)) { | ||
vel.x *= -(0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getRandom)(); | ||
} | ||
if (vDistance && (pos.y < initialPosition.y && vel.y < 0 || pos.y > initialPosition.y && vel.y > 0)) { | ||
@@ -153,14 +147,8 @@ vel.y *= -(0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getRandom)(); | ||
const container = particle.container; | ||
if (!particle.spin) { | ||
return; | ||
} | ||
const updateFunc = { | ||
x: particle.spin.direction === "clockwise" | ||
/* RotateDirection.clockwise */ | ||
? Math.cos : Math.sin, | ||
y: particle.spin.direction === "clockwise" | ||
/* RotateDirection.clockwise */ | ||
? Math.sin : Math.cos | ||
x: particle.spin.direction === "clockwise" ? Math.cos : Math.sin, | ||
y: particle.spin.direction === "clockwise" ? Math.sin : Math.cos | ||
}; | ||
@@ -171,3 +159,2 @@ particle.position.x = particle.spin.center.x + particle.spin.radius * updateFunc.x(particle.spin.angle); | ||
const maxCanvasSize = Math.max(container.canvas.size.width, container.canvas.size.height); | ||
if (particle.spin.radius > maxCanvasSize / 2) { | ||
@@ -180,3 +167,2 @@ particle.spin.radius = maxCanvasSize / 2; | ||
} | ||
particle.spin.angle += moveSpeed / 100 * (1 - particle.spin.radius / maxCanvasSize); | ||
@@ -186,11 +172,8 @@ } | ||
var _a; | ||
const particlesOptions = particle.options; | ||
const pathOptions = particlesOptions.move.path; | ||
const pathEnabled = pathOptions.enable; | ||
const particlesOptions = particle.options, | ||
pathOptions = particlesOptions.move.path, | ||
pathEnabled = pathOptions.enable; | ||
if (!pathEnabled) { | ||
return; | ||
} | ||
if (particle.lastPathTime <= particle.pathDelay) { | ||
@@ -200,9 +183,6 @@ particle.lastPathTime += delta.value; | ||
} | ||
const path = (_a = particle.pathGenerator) === null || _a === void 0 ? void 0 : _a.generate(particle); | ||
if (path) { | ||
particle.velocity.addTo(path); | ||
} | ||
if (pathOptions.clamp) { | ||
@@ -212,3 +192,2 @@ particle.velocity.x = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.clamp)(particle.velocity.x, -1, 1); | ||
} | ||
particle.lastPathTime -= particle.pathDelay; | ||
@@ -225,7 +204,6 @@ } | ||
var _a; | ||
const container = particle.container, | ||
options = particle.options, | ||
gravityOptions = options.move.gravity, | ||
spinOptions = options.move.spin; | ||
options = particle.options, | ||
gravityOptions = options.move.gravity, | ||
spinOptions = options.move.spin; | ||
particle.gravity = { | ||
@@ -236,23 +214,18 @@ enable: gravityOptions.enable, | ||
}; | ||
if (spinOptions.enable) { | ||
const spinPos = (_a = spinOptions.position) !== null && _a !== void 0 ? _a : { | ||
x: 50, | ||
y: 50 | ||
}; | ||
const spinCenter = { | ||
x: spinPos.x / 100 * container.canvas.size.width, | ||
y: spinPos.y / 100 * container.canvas.size.height | ||
}; | ||
const pos = particle.getPosition(); | ||
const distance = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getDistance)(pos, spinCenter); | ||
const spinAcceleration = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getRangeValue)(spinOptions.acceleration); | ||
x: 50, | ||
y: 50 | ||
}, | ||
spinCenter = { | ||
x: spinPos.x / 100 * container.canvas.size.width, | ||
y: spinPos.y / 100 * container.canvas.size.height | ||
}, | ||
pos = particle.getPosition(), | ||
distance = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getDistance)(pos, spinCenter), | ||
spinAcceleration = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getRangeValue)(spinOptions.acceleration); | ||
particle.retina.spinAcceleration = spinAcceleration * container.retina.pixelRatio; | ||
particle.spin = { | ||
center: spinCenter, | ||
direction: particle.velocity.x >= 0 ? "clockwise" | ||
/* RotateDirection.clockwise */ | ||
: "counter-clockwise" | ||
/* RotateDirection.counterClockwise */ | ||
, | ||
direction: particle.velocity.x >= 0 ? "clockwise" : "counter-clockwise", | ||
angle: particle.velocity.angle, | ||
@@ -264,29 +237,22 @@ radius: distance, | ||
} | ||
isEnabled(particle) { | ||
return !particle.destroyed && particle.options.move.enable; | ||
} | ||
move(particle, delta) { | ||
var _a, _b, _c; | ||
var _d, _e; | ||
const particleOptions = particle.options, | ||
moveOptions = particleOptions.move; | ||
moveOptions = particleOptions.move; | ||
if (!moveOptions.enable) { | ||
return; | ||
} | ||
const container = particle.container, | ||
slowFactor = getProximitySpeedFactor(particle), | ||
baseSpeed = ((_a = (_d = particle.retina).moveSpeed) !== null && _a !== void 0 ? _a : _d.moveSpeed = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getRangeValue)(moveOptions.speed) * container.retina.pixelRatio) * container.retina.reduceFactor, | ||
moveDrift = (_b = (_e = particle.retina).moveDrift) !== null && _b !== void 0 ? _b : _e.moveDrift = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getRangeValue)(particle.options.move.drift) * container.retina.pixelRatio, | ||
maxSize = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.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; | ||
slowFactor = getProximitySpeedFactor(particle), | ||
baseSpeed = ((_a = (_d = particle.retina).moveSpeed) !== null && _a !== void 0 ? _a : _d.moveSpeed = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getRangeValue)(moveOptions.speed) * container.retina.pixelRatio) * container.retina.reduceFactor, | ||
moveDrift = (_b = (_e = particle.retina).moveDrift) !== null && _b !== void 0 ? _b : _e.moveDrift = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getRangeValue)(particle.options.move.drift) * container.retina.pixelRatio, | ||
maxSize = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.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; | ||
if (moveOptions.spin.enable) { | ||
@@ -297,24 +263,17 @@ spin(particle, moveSpeed); | ||
const gravityOptions = particle.gravity, | ||
gravityFactor = (gravityOptions === null || gravityOptions === void 0 ? void 0 : gravityOptions.enable) && gravityOptions.inverse ? -1 : 1; | ||
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; | ||
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) { | ||
@@ -324,12 +283,8 @@ particle.velocity.y = velocity.y / moveSpeed; | ||
} | ||
const zIndexOptions = particle.options.zIndex, | ||
zVelocityFactor = (1 - particle.zIndexFactor) ** zIndexOptions.velocityRate; | ||
zVelocityFactor = (1 - particle.zIndexFactor) ** zIndexOptions.velocityRate; | ||
if (zVelocityFactor != 1) { | ||
velocity.multTo(zVelocityFactor); | ||
} | ||
particle.position.addTo(velocity); | ||
if (moveOptions.vibrate) { | ||
@@ -340,6 +295,4 @@ particle.position.x += Math.sin(particle.position.x * Math.cos(particle.position.y)); | ||
} | ||
applyDistance(particle); | ||
} | ||
} | ||
@@ -351,3 +304,4 @@ ;// CONCATENATED MODULE: ./dist/browser/index.js | ||
} | ||
}(); | ||
})(); | ||
/******/ return __webpack_exports__; | ||
@@ -354,0 +308,0 @@ /******/ })() |
/*! 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={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}()})); | ||
!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,(e=>(()=>{"use strict";var i={961: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=(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=(e,i)=>Object.prototype.hasOwnProperty.call(e,i),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{loadBaseMover:()=>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,x=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,x);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)&&x&&(i.velocity.y+=o*(n.acceleration*t.factor)/(60*x)),d&&x&&(i.velocity.x+=d*t.factor/(60*x));const s=i.moveDecay;1!=s&&i.velocity.multTo(s);const r=i.velocity.mult(x),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,x&&(i.velocity.y=r.y/x));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.3.3 | ||
* v2.4.0 | ||
*/ |
@@ -25,10 +25,6 @@ (function (factory) { | ||
if (spinOptions.enable) { | ||
const spinPos = (_a = spinOptions.position) !== null && _a !== void 0 ? _a : { x: 50, y: 50 }; | ||
const spinCenter = { | ||
const spinPos = (_a = spinOptions.position) !== null && _a !== void 0 ? _a : { x: 50, y: 50 }, spinCenter = { | ||
x: (spinPos.x / 100) * container.canvas.size.width, | ||
y: (spinPos.y / 100) * container.canvas.size.height, | ||
}; | ||
const pos = particle.getPosition(); | ||
const distance = (0, tsparticles_engine_1.getDistance)(pos, spinCenter); | ||
const spinAcceleration = (0, tsparticles_engine_1.getRangeValue)(spinOptions.acceleration); | ||
}, pos = particle.getPosition(), distance = (0, tsparticles_engine_1.getDistance)(pos, spinCenter), spinAcceleration = (0, tsparticles_engine_1.getRangeValue)(spinOptions.acceleration); | ||
particle.retina.spinAcceleration = spinAcceleration * container.retina.pixelRatio; | ||
@@ -35,0 +31,0 @@ particle.spin = { |
@@ -68,5 +68,3 @@ (function (factory) { | ||
var _a; | ||
const particlesOptions = particle.options; | ||
const pathOptions = particlesOptions.move.path; | ||
const pathEnabled = pathOptions.enable; | ||
const particlesOptions = particle.options, pathOptions = particlesOptions.move.path, pathEnabled = pathOptions.enable; | ||
if (!pathEnabled) { | ||
@@ -73,0 +71,0 @@ return; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
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
341110
1067
Updatedtsparticles-engine@^2.4.0