@tsparticles/interaction-external-push
Advanced tools
Comparing version 3.0.0-alpha.1 to 3.0.0-beta.0
import { Pusher } from "./Pusher"; | ||
export async function loadExternalPushInteraction(engine) { | ||
await engine.addInteractor("externalPush", (container) => new Pusher(container)); | ||
export async function loadExternalPushInteraction(engine, refresh = true) { | ||
await engine.addInteractor("externalPush", (container) => new Pusher(container), refresh); | ||
} | ||
export * from "./Options/Classes/Push"; | ||
export * from "./Options/Interfaces/IPush"; |
@@ -0,1 +1,2 @@ | ||
import { setRangeValue } from "@tsparticles/engine"; | ||
export class Push { | ||
@@ -11,6 +12,5 @@ constructor() { | ||
set particles_nb(value) { | ||
this.quantity = value; | ||
this.quantity = setRangeValue(value); | ||
} | ||
load(data) { | ||
var _a; | ||
if (!data) { | ||
@@ -28,7 +28,7 @@ return; | ||
} | ||
const quantity = (_a = data.quantity) !== null && _a !== void 0 ? _a : data.particles_nb; | ||
const quantity = data.quantity ?? data.particles_nb; | ||
if (quantity !== undefined) { | ||
this.quantity = quantity; | ||
this.quantity = setRangeValue(quantity); | ||
} | ||
} | ||
} |
@@ -1,4 +0,3 @@ | ||
import { ExternalInteractorBase } from "@tsparticles/engine"; | ||
import { ExternalInteractorBase, getRangeValue, itemFromArray, } from "@tsparticles/engine"; | ||
import { Push } from "./Options/Classes/Push"; | ||
import { itemFromArray } from "@tsparticles/engine"; | ||
export class Pusher extends ExternalInteractorBase { | ||
@@ -15,8 +14,8 @@ constructor(container) { | ||
} | ||
const pushNb = pushOptions.quantity; | ||
if (pushNb <= 0) { | ||
const quantity = getRangeValue(pushOptions.quantity); | ||
if (quantity <= 0) { | ||
return; | ||
} | ||
const group = itemFromArray([undefined, ...pushOptions.groups]), groupOptions = group !== undefined ? container.actualOptions.particles.groups[group] : undefined; | ||
container.particles.push(pushNb, container.interactivity.mouse, groupOptions, group); | ||
container.particles.push(quantity, container.interactivity.mouse, groupOptions, group); | ||
}; | ||
@@ -38,3 +37,3 @@ } | ||
for (const source of sources) { | ||
options.push.load(source === null || source === void 0 ? void 0 : source.push); | ||
options.push.load(source?.push); | ||
} | ||
@@ -41,0 +40,0 @@ } |
@@ -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.loadExternalPushInteraction = void 0; | ||
const Pusher_1 = require("./Pusher"); | ||
function loadExternalPushInteraction(engine) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield engine.addInteractor("externalPush", (container) => new Pusher_1.Pusher(container)); | ||
}); | ||
async function loadExternalPushInteraction(engine, refresh = true) { | ||
await engine.addInteractor("externalPush", (container) => new Pusher_1.Pusher(container), refresh); | ||
} | ||
@@ -34,0 +23,0 @@ exports.loadExternalPushInteraction = loadExternalPushInteraction; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Push = void 0; | ||
const engine_1 = require("@tsparticles/engine"); | ||
class Push { | ||
@@ -14,6 +15,5 @@ constructor() { | ||
set particles_nb(value) { | ||
this.quantity = value; | ||
this.quantity = (0, engine_1.setRangeValue)(value); | ||
} | ||
load(data) { | ||
var _a; | ||
if (!data) { | ||
@@ -31,5 +31,5 @@ return; | ||
} | ||
const quantity = (_a = data.quantity) !== null && _a !== void 0 ? _a : data.particles_nb; | ||
const quantity = data.quantity ?? data.particles_nb; | ||
if (quantity !== undefined) { | ||
this.quantity = quantity; | ||
this.quantity = (0, engine_1.setRangeValue)(quantity); | ||
} | ||
@@ -36,0 +36,0 @@ } |
"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 }); | ||
@@ -15,3 +6,2 @@ exports.Pusher = void 0; | ||
const Push_1 = require("./Options/Classes/Push"); | ||
const engine_2 = require("@tsparticles/engine"); | ||
class Pusher extends engine_1.ExternalInteractorBase { | ||
@@ -28,8 +18,8 @@ constructor(container) { | ||
} | ||
const pushNb = pushOptions.quantity; | ||
if (pushNb <= 0) { | ||
const quantity = (0, engine_1.getRangeValue)(pushOptions.quantity); | ||
if (quantity <= 0) { | ||
return; | ||
} | ||
const group = (0, engine_2.itemFromArray)([undefined, ...pushOptions.groups]), groupOptions = group !== undefined ? container.actualOptions.particles.groups[group] : undefined; | ||
container.particles.push(pushNb, container.interactivity.mouse, groupOptions, group); | ||
const group = (0, engine_1.itemFromArray)([undefined, ...pushOptions.groups]), groupOptions = group !== undefined ? container.actualOptions.particles.groups[group] : undefined; | ||
container.particles.push(quantity, container.interactivity.mouse, groupOptions, group); | ||
}; | ||
@@ -41,5 +31,3 @@ } | ||
} | ||
interact() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
}); | ||
async interact() { | ||
} | ||
@@ -54,3 +42,3 @@ isEnabled() { | ||
for (const source of sources) { | ||
options.push.load(source === null || source === void 0 ? void 0 : source.push); | ||
options.push.load(source?.push); | ||
} | ||
@@ -57,0 +45,0 @@ } |
import { Pusher } from "./Pusher"; | ||
export async function loadExternalPushInteraction(engine) { | ||
await engine.addInteractor("externalPush", (container) => new Pusher(container)); | ||
export async function loadExternalPushInteraction(engine, refresh = true) { | ||
await engine.addInteractor("externalPush", (container) => new Pusher(container), refresh); | ||
} | ||
export * from "./Options/Classes/Push"; | ||
export * from "./Options/Interfaces/IPush"; |
@@ -0,1 +1,2 @@ | ||
import { setRangeValue } from "@tsparticles/engine"; | ||
export class Push { | ||
@@ -11,6 +12,5 @@ constructor() { | ||
set particles_nb(value) { | ||
this.quantity = value; | ||
this.quantity = setRangeValue(value); | ||
} | ||
load(data) { | ||
var _a; | ||
if (!data) { | ||
@@ -28,7 +28,7 @@ return; | ||
} | ||
const quantity = (_a = data.quantity) !== null && _a !== void 0 ? _a : data.particles_nb; | ||
const quantity = data.quantity ?? data.particles_nb; | ||
if (quantity !== undefined) { | ||
this.quantity = quantity; | ||
this.quantity = setRangeValue(quantity); | ||
} | ||
} | ||
} |
@@ -1,4 +0,3 @@ | ||
import { ExternalInteractorBase } from "@tsparticles/engine"; | ||
import { ExternalInteractorBase, getRangeValue, itemFromArray, } from "@tsparticles/engine"; | ||
import { Push } from "./Options/Classes/Push"; | ||
import { itemFromArray } from "@tsparticles/engine"; | ||
export class Pusher extends ExternalInteractorBase { | ||
@@ -15,8 +14,8 @@ constructor(container) { | ||
} | ||
const pushNb = pushOptions.quantity; | ||
if (pushNb <= 0) { | ||
const quantity = getRangeValue(pushOptions.quantity); | ||
if (quantity <= 0) { | ||
return; | ||
} | ||
const group = itemFromArray([undefined, ...pushOptions.groups]), groupOptions = group !== undefined ? container.actualOptions.particles.groups[group] : undefined; | ||
container.particles.push(pushNb, container.interactivity.mouse, groupOptions, group); | ||
container.particles.push(quantity, container.interactivity.mouse, groupOptions, group); | ||
}; | ||
@@ -38,3 +37,3 @@ } | ||
for (const source of sources) { | ||
options.push.load(source === null || source === void 0 ? void 0 : source.push); | ||
options.push.load(source?.push); | ||
} | ||
@@ -41,0 +40,0 @@ } |
{ | ||
"name": "@tsparticles/interaction-external-push", | ||
"version": "3.0.0-alpha.1", | ||
"version": "3.0.0-beta.0", | ||
"description": "tsParticles push external interaction", | ||
@@ -76,8 +76,9 @@ "homepage": "https://particles.js.org", | ||
"types": "types/index.d.ts", | ||
"sideEffects": false, | ||
"dependencies": { | ||
"@tsparticles/engine": "^3.0.0-beta.0" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@tsparticles/engine": "^3.0.0-alpha.1" | ||
} | ||
} | ||
} |
@@ -5,5 +5,5 @@ [![banner](https://particles.js.org/images/banner2.png)](https://particles.js.org) | ||
[![jsDelivr](https://data.jsdelivr.com/v1/package/npm/tsparticles-interaction-external-push/badge)](https://www.jsdelivr.com/package/npm/tsparticles-interaction-external-push) | ||
[![npmjs](https://badge.fury.io/js/tsparticles-interaction-external-push.svg)](https://www.npmjs.com/package/tsparticles-interaction-external-push) | ||
[![npmjs](https://img.shields.io/npm/dt/tsparticles-interaction-external-push)](https://www.npmjs.com/package/tsparticles-interaction-external-push) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](https://github.com/sponsors/matteobruni) | ||
[![jsDelivr](https://data.jsdelivr.com/v1/package/npm/@tsparticles/interaction-external-push/badge)](https://www.jsdelivr.com/package/npm/@tsparticles/interaction-external-push) | ||
[![npmjs](https://badge.fury.io/js/@tsparticles/interaction-external-push.svg)](https://www.npmjs.com/package/@tsparticles/interaction-external-push) | ||
[![npmjs](https://img.shields.io/npm/dt/@tsparticles/interaction-external-push)](https://www.npmjs.com/package/@tsparticles/interaction-external-push) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](https://github.com/sponsors/matteobruni) | ||
@@ -31,10 +31,12 @@ [tsParticles](https://github.com/matteobruni/tsparticles) interaction plugin for push effect around mouse or HTML | ||
```javascript | ||
loadExternalPushInteraction(tsParticles); | ||
(async () => { | ||
await loadExternalPushInteraction(tsParticles); | ||
tsParticles.load({ | ||
id: "tsparticles", | ||
options: { | ||
/* options */ | ||
}, | ||
}); | ||
await tsParticles.load({ | ||
id: "tsparticles", | ||
options: { | ||
/* options */ | ||
}, | ||
}); | ||
})(); | ||
``` | ||
@@ -47,3 +49,3 @@ | ||
```shell | ||
$ npm install tsparticles-interaction-external-push | ||
$ npm install @tsparticles/interaction-external-push | ||
``` | ||
@@ -54,3 +56,3 @@ | ||
```shell | ||
$ yarn add tsparticles-interaction-external-push | ||
$ yarn add @tsparticles/interaction-external-push | ||
``` | ||
@@ -61,6 +63,8 @@ | ||
```javascript | ||
const { tsParticles } = require("tsparticles-engine"); | ||
const { loadExternalPushInteraction } = require("tsparticles-interaction-external-push"); | ||
const { tsParticles } = require("@tsparticles/engine"); | ||
const { loadExternalPushInteraction } = require("@tsparticles/interaction-external-push"); | ||
loadExternalPushInteraction(tsParticles); | ||
(async () => { | ||
await loadExternalPushInteraction(tsParticles); | ||
})(); | ||
``` | ||
@@ -71,6 +75,8 @@ | ||
```javascript | ||
import { tsParticles } from "tsparticles-engine"; | ||
import { loadExternalPushInteraction } from "tsparticles-interaction-external-push"; | ||
import { tsParticles } from "@tsparticles/engine"; | ||
import { loadExternalPushInteraction } from "@tsparticles/interaction-external-push"; | ||
loadExternalPushInteraction(tsParticles); | ||
(async () => { | ||
await loadExternalPushInteraction(tsParticles); | ||
})(); | ||
``` |
@@ -7,3 +7,3 @@ /*! | ||
* How to use? : Check the GitHub README | ||
* v3.0.0-alpha.1 | ||
* v3.0.0-beta.0 | ||
*/ | ||
@@ -95,4 +95,4 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
__webpack_require__.d(__webpack_exports__, { | ||
"Push": () => (/* reexport */ Push), | ||
"loadExternalPushInteraction": () => (/* binding */ loadExternalPushInteraction) | ||
Push: () => (/* reexport */ Push), | ||
loadExternalPushInteraction: () => (/* binding */ loadExternalPushInteraction) | ||
}); | ||
@@ -103,2 +103,3 @@ | ||
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Push.js | ||
class Push { | ||
@@ -114,6 +115,5 @@ constructor() { | ||
set particles_nb(value) { | ||
this.quantity = value; | ||
this.quantity = (0,engine_root_window_.setRangeValue)(value); | ||
} | ||
load(data) { | ||
var _a; | ||
if (!data) { | ||
@@ -131,5 +131,5 @@ return; | ||
} | ||
const quantity = (_a = data.quantity) !== null && _a !== void 0 ? _a : data.particles_nb; | ||
const quantity = data.quantity ?? data.particles_nb; | ||
if (quantity !== undefined) { | ||
this.quantity = quantity; | ||
this.quantity = (0,engine_root_window_.setRangeValue)(quantity); | ||
} | ||
@@ -141,3 +141,2 @@ } | ||
class Pusher extends engine_root_window_.ExternalInteractorBase { | ||
@@ -156,4 +155,4 @@ constructor(container) { | ||
} | ||
const pushNb = pushOptions.quantity; | ||
if (pushNb <= 0) { | ||
const quantity = (0,engine_root_window_.getRangeValue)(pushOptions.quantity); | ||
if (quantity <= 0) { | ||
return; | ||
@@ -163,3 +162,3 @@ } | ||
groupOptions = group !== undefined ? container.actualOptions.particles.groups[group] : undefined; | ||
container.particles.push(pushNb, container.interactivity.mouse, groupOptions, group); | ||
container.particles.push(quantity, container.interactivity.mouse, groupOptions, group); | ||
}; | ||
@@ -178,3 +177,3 @@ } | ||
for (const source of sources) { | ||
options.push.load(source === null || source === void 0 ? void 0 : source.push); | ||
options.push.load(source?.push); | ||
} | ||
@@ -186,4 +185,4 @@ } | ||
async function loadExternalPushInteraction(engine) { | ||
await engine.addInteractor("externalPush", container => new Pusher(container)); | ||
async function loadExternalPushInteraction(engine, refresh = true) { | ||
await engine.addInteractor("externalPush", container => new Pusher(container), refresh); | ||
} | ||
@@ -190,0 +189,0 @@ |
/*! For license information please see tsparticles.interaction.external.push.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 r="object"==typeof exports?e(require("@tsparticles/engine")):e(t.window);for(var o in r)("object"==typeof exports?exports:t)[o]=r[o]}}(this,(t=>(()=>{"use strict";var e={533:e=>{e.exports=t}},r={};function o(t){var i=r[t];if(void 0!==i)return i.exports;var s=r[t]={exports:{}};return e[t](s,s.exports,o),s.exports}o.d=(t,e)=>{for(var r in e)o.o(e,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};return(()=>{o.r(i),o.d(i,{Push:()=>e,loadExternalPushInteraction:()=>s});var t=o(533);class e{constructor(){this.default=!0,this.groups=[],this.quantity=4}get particles_nb(){return this.quantity}set particles_nb(t){this.quantity=t}load(t){var e;if(!t)return;void 0!==t.default&&(this.default=t.default),void 0!==t.groups&&(this.groups=t.groups.map((t=>t))),this.groups.length||(this.default=!0);const r=null!==(e=t.quantity)&&void 0!==e?e:t.particles_nb;void 0!==r&&(this.quantity=r)}}class r extends t.ExternalInteractorBase{constructor(e){super(e),this.handleClickMode=e=>{if("push"!==e)return;const r=this.container,o=r.actualOptions.interactivity.modes.push;if(!o)return;const i=o.quantity;if(i<=0)return;const s=(0,t.itemFromArray)([void 0,...o.groups]),n=void 0!==s?r.actualOptions.particles.groups[s]:void 0;r.particles.push(i,r.interactivity.mouse,n,s)}}clear(){}init(){}async interact(){}isEnabled(){return!0}loadModeOptions(t,...r){t.push||(t.push=new e);for(const e of r)t.push.load(null==e?void 0:e.push)}reset(){}}async function s(t){await t.addInteractor("externalPush",(t=>new r(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 r="object"==typeof exports?e(require("@tsparticles/engine")):e(t.window);for(var o in r)("object"==typeof exports?exports:t)[o]=r[o]}}(this,(t=>(()=>{"use strict";var e={533:e=>{e.exports=t}},r={};function o(t){var s=r[t];if(void 0!==s)return s.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,o),i.exports}o.d=(t,e)=>{for(var r in e)o.o(e,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var s={};return(()=>{o.r(s),o.d(s,{Push:()=>e,loadExternalPushInteraction:()=>i});var t=o(533);class e{constructor(){this.default=!0,this.groups=[],this.quantity=4}get particles_nb(){return this.quantity}set particles_nb(e){this.quantity=(0,t.setRangeValue)(e)}load(e){if(!e)return;void 0!==e.default&&(this.default=e.default),void 0!==e.groups&&(this.groups=e.groups.map((t=>t))),this.groups.length||(this.default=!0);const r=e.quantity??e.particles_nb;void 0!==r&&(this.quantity=(0,t.setRangeValue)(r))}}class r extends t.ExternalInteractorBase{constructor(e){super(e),this.handleClickMode=e=>{if("push"!==e)return;const r=this.container,o=r.actualOptions.interactivity.modes.push;if(!o)return;const s=(0,t.getRangeValue)(o.quantity);if(s<=0)return;const i=(0,t.itemFromArray)([void 0,...o.groups]),n=void 0!==i?r.actualOptions.particles.groups[i]:void 0;r.particles.push(s,r.interactivity.mouse,n,i)}}clear(){}init(){}async interact(){}isEnabled(){return!0}loadModeOptions(t,...r){t.push||(t.push=new e);for(const e of r)t.push.load(e?.push)}reset(){}}async function i(t,e=!0){await t.addInteractor("externalPush",(t=>new r(t)),e)}})(),s})())); |
@@ -1,8 +0,1 @@ | ||
/*! | ||
* Author : Matteo Bruni | ||
* MIT license: https://opensource.org/licenses/MIT | ||
* Demo / Generator : https://particles.js.org/ | ||
* GitHub : https://www.github.com/matteobruni/tsparticles | ||
* How to use? : Check the GitHub README | ||
* v3.0.0-alpha.1 | ||
*/ | ||
/*! tsParticles Push External Interaction v3.0.0-beta.0 by Matteo Bruni */ |
import type { Engine } from "@tsparticles/engine"; | ||
export declare function loadExternalPushInteraction(engine: Engine): Promise<void>; | ||
export declare function loadExternalPushInteraction(engine: Engine, refresh?: boolean): Promise<void>; | ||
export * from "./Options/Classes/Push"; | ||
export * from "./Options/Interfaces/IPush"; |
@@ -1,2 +0,2 @@ | ||
import type { IOptionLoader, RecursivePartial } from "@tsparticles/engine"; | ||
import { type IOptionLoader, type RangeValue, type RecursivePartial } from "@tsparticles/engine"; | ||
import type { IPush } from "../Interfaces/IPush"; | ||
@@ -6,7 +6,7 @@ export declare class Push implements IPush, IOptionLoader<IPush> { | ||
groups: string[]; | ||
quantity: number; | ||
quantity: RangeValue; | ||
constructor(); | ||
get particles_nb(): number; | ||
set particles_nb(value: number); | ||
get particles_nb(): RangeValue; | ||
set particles_nb(value: RangeValue); | ||
load(data?: RecursivePartial<IPush>): void; | ||
} |
@@ -0,6 +1,7 @@ | ||
import type { RangeValue } from "@tsparticles/engine"; | ||
export interface IPush { | ||
default: boolean; | ||
groups: string[]; | ||
particles_nb: number; | ||
quantity: number; | ||
particles_nb: RangeValue; | ||
quantity: RangeValue; | ||
} |
@@ -1,3 +0,2 @@ | ||
import { ExternalInteractorBase } from "@tsparticles/engine"; | ||
import type { IModes, Modes, RecursivePartial } from "@tsparticles/engine"; | ||
import { ExternalInteractorBase, type IModes, type Modes, type RecursivePartial } from "@tsparticles/engine"; | ||
import type { IPushMode, PushContainer, PushMode } from "./Types"; | ||
@@ -4,0 +3,0 @@ export declare class Pusher extends ExternalInteractorBase<PushContainer> { |
@@ -1,5 +0,4 @@ | ||
import type { Container } from "@tsparticles/engine"; | ||
import type { Container, Options } from "@tsparticles/engine"; | ||
import type { IPush } from "./Options/Interfaces/IPush"; | ||
import type { Push } from "./Options/Classes/Push"; | ||
import type { PushOptions } from "./Options/Classes/PushOptions"; | ||
export type IPushMode = { | ||
@@ -14,1 +13,6 @@ push: IPush; | ||
}; | ||
export type PushOptions = Options & { | ||
interactivity: { | ||
modes: PushMode; | ||
}; | ||
}; |
@@ -28,4 +28,4 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
const Pusher_1 = require("./Pusher"); | ||
async function loadExternalPushInteraction(engine) { | ||
await engine.addInteractor("externalPush", (container) => new Pusher_1.Pusher(container)); | ||
async function loadExternalPushInteraction(engine, refresh = true) { | ||
await engine.addInteractor("externalPush", (container) => new Pusher_1.Pusher(container), refresh); | ||
} | ||
@@ -32,0 +32,0 @@ exports.loadExternalPushInteraction = loadExternalPushInteraction; |
@@ -7,3 +7,3 @@ (function (factory) { | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports"], factory); | ||
define(["require", "exports", "@tsparticles/engine"], factory); | ||
} | ||
@@ -14,2 +14,3 @@ })(function (require, exports) { | ||
exports.Push = void 0; | ||
const engine_1 = require("@tsparticles/engine"); | ||
class Push { | ||
@@ -25,6 +26,5 @@ constructor() { | ||
set particles_nb(value) { | ||
this.quantity = value; | ||
this.quantity = (0, engine_1.setRangeValue)(value); | ||
} | ||
load(data) { | ||
var _a; | ||
if (!data) { | ||
@@ -42,5 +42,5 @@ return; | ||
} | ||
const quantity = (_a = data.quantity) !== null && _a !== void 0 ? _a : data.particles_nb; | ||
const quantity = data.quantity ?? data.particles_nb; | ||
if (quantity !== undefined) { | ||
this.quantity = quantity; | ||
this.quantity = (0, engine_1.setRangeValue)(quantity); | ||
} | ||
@@ -47,0 +47,0 @@ } |
@@ -7,3 +7,3 @@ (function (factory) { | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports", "@tsparticles/engine", "./Options/Classes/Push", "@tsparticles/engine"], factory); | ||
define(["require", "exports", "@tsparticles/engine", "./Options/Classes/Push"], factory); | ||
} | ||
@@ -16,3 +16,2 @@ })(function (require, exports) { | ||
const Push_1 = require("./Options/Classes/Push"); | ||
const engine_2 = require("@tsparticles/engine"); | ||
class Pusher extends engine_1.ExternalInteractorBase { | ||
@@ -29,8 +28,8 @@ constructor(container) { | ||
} | ||
const pushNb = pushOptions.quantity; | ||
if (pushNb <= 0) { | ||
const quantity = (0, engine_1.getRangeValue)(pushOptions.quantity); | ||
if (quantity <= 0) { | ||
return; | ||
} | ||
const group = (0, engine_2.itemFromArray)([undefined, ...pushOptions.groups]), groupOptions = group !== undefined ? container.actualOptions.particles.groups[group] : undefined; | ||
container.particles.push(pushNb, container.interactivity.mouse, groupOptions, group); | ||
const group = (0, engine_1.itemFromArray)([undefined, ...pushOptions.groups]), groupOptions = group !== undefined ? container.actualOptions.particles.groups[group] : undefined; | ||
container.particles.push(quantity, container.interactivity.mouse, groupOptions, group); | ||
}; | ||
@@ -52,3 +51,3 @@ } | ||
for (const source of sources) { | ||
options.push.load(source === null || source === void 0 ? void 0 : source.push); | ||
options.push.load(source?.push); | ||
} | ||
@@ -55,0 +54,0 @@ } |
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
77
309854
32
654