Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tsparticles-interaction-external-slow

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tsparticles-interaction-external-slow - npm Package Compare versions

Comparing version 2.9.3 to 2.10.0

20

browser/Slower.js

@@ -1,2 +0,2 @@

import { ExternalInteractorBase, getDistance, isInArray } from "tsparticles-engine";
import { ExternalInteractorBase, getDistance, isInArray, } from "tsparticles-engine";
import { Slow } from "./Options/Classes/Slow";

@@ -23,4 +23,3 @@ export class Slower extends ExternalInteractorBase {

isEnabled(particle) {
var _a;
const container = this.container, mouse = container.interactivity.mouse, events = ((_a = particle === null || particle === void 0 ? void 0 : particle.interactivity) !== null && _a !== void 0 ? _a : container.actualOptions.interactivity).events;
const container = this.container, mouse = container.interactivity.mouse, events = (particle?.interactivity ?? container.actualOptions.interactivity).events;
return events.onHover.enable && !!mouse.position && isInArray("slow", events.onHover.mode);

@@ -33,3 +32,3 @@ }

for (const source of sources) {
options.slow.load(source === null || source === void 0 ? void 0 : source.slow);
options.slow.load(source?.slow);
}

@@ -39,12 +38,13 @@ }

particle.slow.inRange = false;
const container = this.container, options = container.actualOptions, mousePos = container.interactivity.mouse.position, radius = container.retina.slowModeRadius, slow = options.interactivity.modes.slow;
if (!slow || !radius || radius < 0 || !mousePos) {
const container = this.container, options = container.actualOptions, mousePos = container.interactivity.mouse.position, radius = container.retina.slowModeRadius, slowOptions = options.interactivity.modes.slow;
if (!slowOptions || !radius || radius < 0 || !mousePos) {
return;
}
const particlePos = particle.getPosition(), dist = getDistance(mousePos, particlePos), proximityFactor = dist / radius, slowFactor = slow.factor;
if (dist <= radius) {
particle.slow.inRange = true;
particle.slow.factor = proximityFactor / slowFactor;
const particlePos = particle.getPosition(), dist = getDistance(mousePos, particlePos), proximityFactor = dist / radius, slowFactor = slowOptions.factor, { slow } = particle;
if (dist > radius) {
return;
}
slow.inRange = true;
slow.factor = proximityFactor / slowFactor;
}
}

@@ -16,18 +16,7 @@ "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.loadExternalSlowInteraction = void 0;
const Slower_1 = require("./Slower");
function loadExternalSlowInteraction(engine) {
return __awaiter(this, void 0, void 0, function* () {
yield engine.addInteractor("externalSlow", (container) => new Slower_1.Slower(container));
});
async function loadExternalSlowInteraction(engine) {
await engine.addInteractor("externalSlow", (container) => new Slower_1.Slower(container));
}

@@ -34,0 +23,0 @@ exports.loadExternalSlowInteraction = loadExternalSlowInteraction;

"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 });

@@ -32,9 +23,6 @@ exports.Slower = void 0;

}
interact() {
return __awaiter(this, void 0, void 0, function* () {
});
async interact() {
}
isEnabled(particle) {
var _a;
const container = this.container, mouse = container.interactivity.mouse, events = ((_a = particle === null || particle === void 0 ? void 0 : particle.interactivity) !== null && _a !== void 0 ? _a : container.actualOptions.interactivity).events;
const container = this.container, mouse = container.interactivity.mouse, events = (particle?.interactivity ?? container.actualOptions.interactivity).events;
return events.onHover.enable && !!mouse.position && (0, tsparticles_engine_1.isInArray)("slow", events.onHover.mode);

@@ -47,3 +35,3 @@ }

for (const source of sources) {
options.slow.load(source === null || source === void 0 ? void 0 : source.slow);
options.slow.load(source?.slow);
}

@@ -53,13 +41,14 @@ }

particle.slow.inRange = false;
const container = this.container, options = container.actualOptions, mousePos = container.interactivity.mouse.position, radius = container.retina.slowModeRadius, slow = options.interactivity.modes.slow;
if (!slow || !radius || radius < 0 || !mousePos) {
const container = this.container, options = container.actualOptions, mousePos = container.interactivity.mouse.position, radius = container.retina.slowModeRadius, slowOptions = options.interactivity.modes.slow;
if (!slowOptions || !radius || radius < 0 || !mousePos) {
return;
}
const particlePos = particle.getPosition(), dist = (0, tsparticles_engine_1.getDistance)(mousePos, particlePos), proximityFactor = dist / radius, slowFactor = slow.factor;
if (dist <= radius) {
particle.slow.inRange = true;
particle.slow.factor = proximityFactor / slowFactor;
const particlePos = particle.getPosition(), dist = (0, tsparticles_engine_1.getDistance)(mousePos, particlePos), proximityFactor = dist / radius, slowFactor = slowOptions.factor, { slow } = particle;
if (dist > radius) {
return;
}
slow.inRange = true;
slow.factor = proximityFactor / slowFactor;
}
}
exports.Slower = Slower;

@@ -1,2 +0,2 @@

import { ExternalInteractorBase, getDistance, isInArray } from "tsparticles-engine";
import { ExternalInteractorBase, getDistance, isInArray, } from "tsparticles-engine";
import { Slow } from "./Options/Classes/Slow";

@@ -23,4 +23,3 @@ export class Slower extends ExternalInteractorBase {

isEnabled(particle) {
var _a;
const container = this.container, mouse = container.interactivity.mouse, events = ((_a = particle === null || particle === void 0 ? void 0 : particle.interactivity) !== null && _a !== void 0 ? _a : container.actualOptions.interactivity).events;
const container = this.container, mouse = container.interactivity.mouse, events = (particle?.interactivity ?? container.actualOptions.interactivity).events;
return events.onHover.enable && !!mouse.position && isInArray("slow", events.onHover.mode);

@@ -33,3 +32,3 @@ }

for (const source of sources) {
options.slow.load(source === null || source === void 0 ? void 0 : source.slow);
options.slow.load(source?.slow);
}

@@ -39,12 +38,13 @@ }

particle.slow.inRange = false;
const container = this.container, options = container.actualOptions, mousePos = container.interactivity.mouse.position, radius = container.retina.slowModeRadius, slow = options.interactivity.modes.slow;
if (!slow || !radius || radius < 0 || !mousePos) {
const container = this.container, options = container.actualOptions, mousePos = container.interactivity.mouse.position, radius = container.retina.slowModeRadius, slowOptions = options.interactivity.modes.slow;
if (!slowOptions || !radius || radius < 0 || !mousePos) {
return;
}
const particlePos = particle.getPosition(), dist = getDistance(mousePos, particlePos), proximityFactor = dist / radius, slowFactor = slow.factor;
if (dist <= radius) {
particle.slow.inRange = true;
particle.slow.factor = proximityFactor / slowFactor;
const particlePos = particle.getPosition(), dist = getDistance(mousePos, particlePos), proximityFactor = dist / radius, slowFactor = slowOptions.factor, { slow } = particle;
if (dist > radius) {
return;
}
slow.inRange = true;
slow.factor = proximityFactor / slowFactor;
}
}
{
"name": "tsparticles-interaction-external-slow",
"version": "2.9.3",
"version": "2.10.0",
"description": "tsParticles slow external interaction",

@@ -77,4 +77,4 @@ "homepage": "https://particles.js.org",

"dependencies": {
"tsparticles-engine": "^2.9.3"
"tsparticles-engine": "^2.10.0"
}
}

@@ -7,3 +7,3 @@ /*!

* How to use? : Check the GitHub README
* v2.9.3
* v2.10.0
*/

@@ -95,4 +95,4 @@ (function webpackUniversalModuleDefinition(root, factory) {

__webpack_require__.d(__webpack_exports__, {
"Slow": () => (/* reexport */ Slow),
"loadExternalSlowInteraction": () => (/* binding */ loadExternalSlowInteraction)
Slow: () => (/* reexport */ Slow),
loadExternalSlowInteraction: () => (/* binding */ loadExternalSlowInteraction)
});

@@ -143,6 +143,5 @@

isEnabled(particle) {
var _a;
const container = this.container,
mouse = container.interactivity.mouse,
events = ((_a = particle === null || particle === void 0 ? void 0 : particle.interactivity) !== null && _a !== void 0 ? _a : container.actualOptions.interactivity).events;
events = (particle?.interactivity ?? container.actualOptions.interactivity).events;
return events.onHover.enable && !!mouse.position && (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.isInArray)("slow", events.onHover.mode);

@@ -155,3 +154,3 @@ }

for (const source of sources) {
options.slow.load(source === null || source === void 0 ? void 0 : source.slow);
options.slow.load(source?.slow);
}

@@ -165,4 +164,4 @@ }

radius = container.retina.slowModeRadius,
slow = options.interactivity.modes.slow;
if (!slow || !radius || radius < 0 || !mousePos) {
slowOptions = options.interactivity.modes.slow;
if (!slowOptions || !radius || radius < 0 || !mousePos) {
return;

@@ -173,7 +172,11 @@ }

proximityFactor = dist / radius,
slowFactor = slow.factor;
if (dist <= radius) {
particle.slow.inRange = true;
particle.slow.factor = proximityFactor / slowFactor;
slowFactor = slowOptions.factor,
{
slow
} = particle;
if (dist > radius) {
return;
}
slow.inRange = true;
slow.factor = proximityFactor / slowFactor;
}

@@ -180,0 +183,0 @@ }

/*! For license information please see tsparticles.interaction.external.slow.min.js.LICENSE.txt */
!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 r in o)("object"==typeof exports?exports:t)[r]=o[r]}}(this,(t=>(()=>{"use strict";var e={961:e=>{e.exports=t}},o={};function r(t){var i=o[t];if(void 0!==i)return i.exports;var n=o[t]={exports:{}};return e[t](n,n.exports,r),n.exports}r.d=(t,e)=>{for(var o in e)r.o(e,o)&&!r.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};return(()=>{r.r(i),r.d(i,{Slow:()=>e,loadExternalSlowInteraction:()=>n});var t=r(961);class e{constructor(){this.factor=3,this.radius=200}load(t){t&&(void 0!==t.factor&&(this.factor=t.factor),void 0!==t.radius&&(this.radius=t.radius))}}class o extends t.ExternalInteractorBase{constructor(t){super(t)}clear(t,e,o){t.slow.inRange&&!o||(t.slow.factor=1)}init(){const t=this.container,e=t.actualOptions.interactivity.modes.slow;e&&(t.retina.slowModeRadius=e.radius*t.retina.pixelRatio)}async interact(){}isEnabled(e){var o;const r=this.container,i=r.interactivity.mouse,n=(null!==(o=null==e?void 0:e.interactivity)&&void 0!==o?o:r.actualOptions.interactivity).events;return n.onHover.enable&&!!i.position&&(0,t.isInArray)("slow",n.onHover.mode)}loadModeOptions(t,...o){t.slow||(t.slow=new e);for(const e of o)t.slow.load(null==e?void 0:e.slow)}reset(e){e.slow.inRange=!1;const o=this.container,r=o.actualOptions,i=o.interactivity.mouse.position,n=o.retina.slowModeRadius,s=r.interactivity.modes.slow;if(!s||!n||n<0||!i)return;const a=e.getPosition(),l=(0,t.getDistance)(i,a),c=l/n,d=s.factor;l<=n&&(e.slow.inRange=!0,e.slow.factor=c/d)}}async function n(t){await t.addInteractor("externalSlow",(t=>new o(t)))}})(),i})()));
!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 r in o)("object"==typeof exports?exports:t)[r]=o[r]}}(this,(t=>(()=>{"use strict";var e={961:e=>{e.exports=t}},o={};function r(t){var i=o[t];if(void 0!==i)return i.exports;var n=o[t]={exports:{}};return e[t](n,n.exports,r),n.exports}r.d=(t,e)=>{for(var o in e)r.o(e,o)&&!r.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};return(()=>{r.r(i),r.d(i,{Slow:()=>e,loadExternalSlowInteraction:()=>n});var t=r(961);class e{constructor(){this.factor=3,this.radius=200}load(t){t&&(void 0!==t.factor&&(this.factor=t.factor),void 0!==t.radius&&(this.radius=t.radius))}}class o extends t.ExternalInteractorBase{constructor(t){super(t)}clear(t,e,o){t.slow.inRange&&!o||(t.slow.factor=1)}init(){const t=this.container,e=t.actualOptions.interactivity.modes.slow;e&&(t.retina.slowModeRadius=e.radius*t.retina.pixelRatio)}async interact(){}isEnabled(e){const o=this.container,r=o.interactivity.mouse,i=(e?.interactivity??o.actualOptions.interactivity).events;return i.onHover.enable&&!!r.position&&(0,t.isInArray)("slow",i.onHover.mode)}loadModeOptions(t,...o){t.slow||(t.slow=new e);for(const e of o)t.slow.load(e?.slow)}reset(e){e.slow.inRange=!1;const o=this.container,r=o.actualOptions,i=o.interactivity.mouse.position,n=o.retina.slowModeRadius,s=r.interactivity.modes.slow;if(!s||!n||n<0||!i)return;const a=e.getPosition(),c=(0,t.getDistance)(i,a),l=c/n,d=s.factor,{slow:u}=e;c>n||(u.inRange=!0,u.factor=l/d)}}async function n(t){await t.addInteractor("externalSlow",(t=>new o(t)))}})(),i})()));

@@ -1,1 +0,1 @@

/*! tsParticles Slow External Interaction v2.9.3 by Matteo Bruni */
/*! tsParticles Slow External Interaction v2.10.0 by Matteo Bruni */

@@ -1,3 +0,2 @@

import { ExternalInteractorBase } from "tsparticles-engine";
import type { IDelta, IModes, Modes, Particle, RecursivePartial } from "tsparticles-engine";
import { ExternalInteractorBase, type IDelta, type IModes, type Modes, type Particle, type RecursivePartial } from "tsparticles-engine";
import type { ISlowMode, SlowContainer, SlowMode } from "./Types";

@@ -4,0 +3,0 @@ export declare class Slower extends ExternalInteractorBase<SlowContainer> {

@@ -35,4 +35,3 @@ (function (factory) {

isEnabled(particle) {
var _a;
const container = this.container, mouse = container.interactivity.mouse, events = ((_a = particle === null || particle === void 0 ? void 0 : particle.interactivity) !== null && _a !== void 0 ? _a : container.actualOptions.interactivity).events;
const container = this.container, mouse = container.interactivity.mouse, events = (particle?.interactivity ?? container.actualOptions.interactivity).events;
return events.onHover.enable && !!mouse.position && (0, tsparticles_engine_1.isInArray)("slow", events.onHover.mode);

@@ -45,3 +44,3 @@ }

for (const source of sources) {
options.slow.load(source === null || source === void 0 ? void 0 : source.slow);
options.slow.load(source?.slow);
}

@@ -51,11 +50,12 @@ }

particle.slow.inRange = false;
const container = this.container, options = container.actualOptions, mousePos = container.interactivity.mouse.position, radius = container.retina.slowModeRadius, slow = options.interactivity.modes.slow;
if (!slow || !radius || radius < 0 || !mousePos) {
const container = this.container, options = container.actualOptions, mousePos = container.interactivity.mouse.position, radius = container.retina.slowModeRadius, slowOptions = options.interactivity.modes.slow;
if (!slowOptions || !radius || radius < 0 || !mousePos) {
return;
}
const particlePos = particle.getPosition(), dist = (0, tsparticles_engine_1.getDistance)(mousePos, particlePos), proximityFactor = dist / radius, slowFactor = slow.factor;
if (dist <= radius) {
particle.slow.inRange = true;
particle.slow.factor = proximityFactor / slowFactor;
const particlePos = particle.getPosition(), dist = (0, tsparticles_engine_1.getDistance)(mousePos, particlePos), proximityFactor = dist / radius, slowFactor = slowOptions.factor, { slow } = particle;
if (dist > radius) {
return;
}
slow.inRange = true;
slow.factor = proximityFactor / slowFactor;
}

@@ -62,0 +62,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc