@tsparticles/interaction-external-bounce 3.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +70 -0
  3. package/browser/Bouncer.js +80 -0
  4. package/browser/Options/Classes/Bounce.js +13 -0
  5. package/browser/Options/Classes/BounceOptions.js +1 -0
  6. package/browser/Options/Interfaces/IBounce.js +1 -0
  7. package/browser/Types.js +1 -0
  8. package/browser/index.js +6 -0
  9. package/cjs/Bouncer.js +95 -0
  10. package/cjs/Options/Classes/Bounce.js +17 -0
  11. package/cjs/Options/Classes/BounceOptions.js +2 -0
  12. package/cjs/Options/Interfaces/IBounce.js +2 -0
  13. package/cjs/Types.js +2 -0
  14. package/cjs/index.js +35 -0
  15. package/esm/Bouncer.js +80 -0
  16. package/esm/Options/Classes/Bounce.js +13 -0
  17. package/esm/Options/Classes/BounceOptions.js +1 -0
  18. package/esm/Options/Interfaces/IBounce.js +1 -0
  19. package/esm/Types.js +1 -0
  20. package/esm/index.js +6 -0
  21. package/package.json +82 -0
  22. package/report.html +39 -0
  23. package/tsparticles.interaction.external.bounce.js +221 -0
  24. package/tsparticles.interaction.external.bounce.min.js +2 -0
  25. package/tsparticles.interaction.external.bounce.min.js.LICENSE.txt +8 -0
  26. package/types/Bouncer.d.ts +15 -0
  27. package/types/Options/Classes/Bounce.d.ts +7 -0
  28. package/types/Options/Classes/BounceOptions.d.ts +7 -0
  29. package/types/Options/Interfaces/IBounce.d.ts +3 -0
  30. package/types/Types.d.ts +16 -0
  31. package/types/index.d.ts +4 -0
  32. package/umd/Bouncer.js +94 -0
  33. package/umd/Options/Classes/Bounce.js +27 -0
  34. package/umd/Options/Classes/BounceOptions.js +12 -0
  35. package/umd/Options/Interfaces/IBounce.js +12 -0
  36. package/umd/Types.js +12 -0
  37. package/umd/index.js +34 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Matteo Bruni
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,70 @@
1
+ [![banner](https://particles.js.org/images/banner2.png)](https://particles.js.org)
2
+
3
+ # tsParticles External Bounce Interaction
4
+
5
+ [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/tsparticles-interaction-external-bounce/badge)](https://www.jsdelivr.com/package/npm/tsparticles-interaction-external-bounce)
6
+ [![npmjs](https://badge.fury.io/js/tsparticles-interaction-external-bounce.svg)](https://www.npmjs.com/package/tsparticles-interaction-external-bounce)
7
+ [![npmjs](https://img.shields.io/npm/dt/tsparticles-interaction-external-bounce)](https://www.npmjs.com/package/tsparticles-interaction-external-bounce) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](https://github.com/sponsors/matteobruni)
8
+
9
+ [tsParticles](https://github.com/matteobruni/tsparticles) interaction plugin for bounce effect around mouse or HTML
10
+ elements.
11
+
12
+ ## How to use it
13
+
14
+ ### CDN / Vanilla JS / jQuery
15
+
16
+ The CDN/Vanilla version JS has one required file in vanilla configuration:
17
+
18
+ Including the `tsparticles.interaction.external.bounce.min.js` file will export the function to load the interaction
19
+ plugin:
20
+
21
+ ```javascript
22
+ loadExternalBounceInteraction;
23
+ ```
24
+
25
+ ### Usage
26
+
27
+ Once the scripts are loaded you can set up `tsParticles` and the interaction plugin like this:
28
+
29
+ ```javascript
30
+ loadExternalBounceInteraction(tsParticles);
31
+
32
+ tsParticles.load({
33
+ id: "tsparticles",
34
+ options: {
35
+ /* options */
36
+ },
37
+ });
38
+ ```
39
+
40
+ ### ESM / CommonJS
41
+
42
+ This package is compatible also with ES or CommonJS modules, firstly this needs to be installed, like this:
43
+
44
+ ```shell
45
+ $ npm install tsparticles-interaction-external-bounce
46
+ ```
47
+
48
+ or
49
+
50
+ ```shell
51
+ $ yarn add tsparticles-interaction-external-bounce
52
+ ```
53
+
54
+ Then you need to import it in the app, like this:
55
+
56
+ ```javascript
57
+ const { tsParticles } = require("tsparticles-engine");
58
+ const { loadExternalBounceInteraction } = require("tsparticles-interaction-external-bounce");
59
+
60
+ loadExternalBounceInteraction(tsParticles);
61
+ ```
62
+
63
+ or
64
+
65
+ ```javascript
66
+ import { tsParticles } from "tsparticles-engine";
67
+ import { loadExternalBounceInteraction } from "tsparticles-interaction-external-bounce";
68
+
69
+ loadExternalBounceInteraction(tsParticles);
70
+ ```
@@ -0,0 +1,80 @@
1
+ import { Circle, ExternalInteractorBase, Rectangle, Vector, calculateBounds, circleBounce, circleBounceDataFromParticle, divModeExecute, isDivModeEnabled, isInArray, mouseMoveEvent, rectBounce, } from "@tsparticles/engine";
2
+ import { Bounce } from "./Options/Classes/Bounce";
3
+ export class Bouncer extends ExternalInteractorBase {
4
+ constructor(container) {
5
+ super(container);
6
+ }
7
+ clear() {
8
+ }
9
+ init() {
10
+ const container = this.container, bounce = container.actualOptions.interactivity.modes.bounce;
11
+ if (!bounce) {
12
+ return;
13
+ }
14
+ container.retina.bounceModeDistance = bounce.distance * container.retina.pixelRatio;
15
+ }
16
+ async interact() {
17
+ const container = this.container, options = container.actualOptions, events = options.interactivity.events, mouseMoveStatus = container.interactivity.status === mouseMoveEvent, hoverEnabled = events.onHover.enable, hoverMode = events.onHover.mode, divs = events.onDiv;
18
+ if (mouseMoveStatus && hoverEnabled && isInArray("bounce", hoverMode)) {
19
+ this.processMouseBounce();
20
+ }
21
+ else {
22
+ divModeExecute("bounce", divs, (selector, div) => this.singleSelectorBounce(selector, div));
23
+ }
24
+ }
25
+ isEnabled(particle) {
26
+ var _a;
27
+ const container = this.container, options = container.actualOptions, mouse = container.interactivity.mouse, events = ((_a = particle === null || particle === void 0 ? void 0 : particle.interactivity) !== null && _a !== void 0 ? _a : options.interactivity).events, divs = events.onDiv;
28
+ return ((mouse.position && events.onHover.enable && isInArray("bounce", events.onHover.mode)) ||
29
+ isDivModeEnabled("bounce", divs));
30
+ }
31
+ loadModeOptions(options, ...sources) {
32
+ if (!options.bounce) {
33
+ options.bounce = new Bounce();
34
+ }
35
+ for (const source of sources) {
36
+ options.bounce.load(source === null || source === void 0 ? void 0 : source.bounce);
37
+ }
38
+ }
39
+ reset() {
40
+ }
41
+ processBounce(position, radius, area) {
42
+ const query = this.container.particles.quadTree.query(area, (p) => this.isEnabled(p));
43
+ for (const particle of query) {
44
+ if (area instanceof Circle) {
45
+ circleBounce(circleBounceDataFromParticle(particle), {
46
+ position,
47
+ radius,
48
+ mass: (radius ** 2 * Math.PI) / 2,
49
+ velocity: Vector.origin,
50
+ factor: Vector.origin,
51
+ });
52
+ }
53
+ else if (area instanceof Rectangle) {
54
+ rectBounce(particle, calculateBounds(position, radius));
55
+ }
56
+ }
57
+ }
58
+ processMouseBounce() {
59
+ const container = this.container, pxRatio = container.retina.pixelRatio, tolerance = 10 * pxRatio, mousePos = container.interactivity.mouse.position, radius = container.retina.bounceModeDistance;
60
+ if (!radius || radius < 0 || !mousePos) {
61
+ return;
62
+ }
63
+ this.processBounce(mousePos, radius, new Circle(mousePos.x, mousePos.y, radius + tolerance));
64
+ }
65
+ singleSelectorBounce(selector, div) {
66
+ const container = this.container, query = document.querySelectorAll(selector);
67
+ if (!query.length) {
68
+ return;
69
+ }
70
+ query.forEach((item) => {
71
+ const elem = item, pxRatio = container.retina.pixelRatio, pos = {
72
+ x: (elem.offsetLeft + elem.offsetWidth / 2) * pxRatio,
73
+ y: (elem.offsetTop + elem.offsetHeight / 2) * pxRatio,
74
+ }, radius = (elem.offsetWidth / 2) * pxRatio, tolerance = 10 * pxRatio, area = div.type === "circle"
75
+ ? new Circle(pos.x, pos.y, radius + tolerance)
76
+ : new Rectangle(elem.offsetLeft * pxRatio - tolerance, elem.offsetTop * pxRatio - tolerance, elem.offsetWidth * pxRatio + tolerance * 2, elem.offsetHeight * pxRatio + tolerance * 2);
77
+ this.processBounce(pos, radius, area);
78
+ });
79
+ }
80
+ }
@@ -0,0 +1,13 @@
1
+ export class Bounce {
2
+ constructor() {
3
+ this.distance = 200;
4
+ }
5
+ load(data) {
6
+ if (!data) {
7
+ return;
8
+ }
9
+ if (data.distance !== undefined) {
10
+ this.distance = data.distance;
11
+ }
12
+ }
13
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import { Bouncer } from "./Bouncer";
2
+ export async function loadExternalBounceInteraction(engine) {
3
+ await engine.addInteractor("externalBounce", (container) => new Bouncer(container));
4
+ }
5
+ export * from "./Options/Classes/Bounce";
6
+ export * from "./Options/Interfaces/IBounce";
package/cjs/Bouncer.js ADDED
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Bouncer = void 0;
13
+ const engine_1 = require("@tsparticles/engine");
14
+ const Bounce_1 = require("./Options/Classes/Bounce");
15
+ class Bouncer extends engine_1.ExternalInteractorBase {
16
+ constructor(container) {
17
+ super(container);
18
+ }
19
+ clear() {
20
+ }
21
+ init() {
22
+ const container = this.container, bounce = container.actualOptions.interactivity.modes.bounce;
23
+ if (!bounce) {
24
+ return;
25
+ }
26
+ container.retina.bounceModeDistance = bounce.distance * container.retina.pixelRatio;
27
+ }
28
+ interact() {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ const container = this.container, options = container.actualOptions, events = options.interactivity.events, mouseMoveStatus = container.interactivity.status === engine_1.mouseMoveEvent, hoverEnabled = events.onHover.enable, hoverMode = events.onHover.mode, divs = events.onDiv;
31
+ if (mouseMoveStatus && hoverEnabled && (0, engine_1.isInArray)("bounce", hoverMode)) {
32
+ this.processMouseBounce();
33
+ }
34
+ else {
35
+ (0, engine_1.divModeExecute)("bounce", divs, (selector, div) => this.singleSelectorBounce(selector, div));
36
+ }
37
+ });
38
+ }
39
+ isEnabled(particle) {
40
+ var _a;
41
+ const container = this.container, options = container.actualOptions, mouse = container.interactivity.mouse, events = ((_a = particle === null || particle === void 0 ? void 0 : particle.interactivity) !== null && _a !== void 0 ? _a : options.interactivity).events, divs = events.onDiv;
42
+ return ((mouse.position && events.onHover.enable && (0, engine_1.isInArray)("bounce", events.onHover.mode)) ||
43
+ (0, engine_1.isDivModeEnabled)("bounce", divs));
44
+ }
45
+ loadModeOptions(options, ...sources) {
46
+ if (!options.bounce) {
47
+ options.bounce = new Bounce_1.Bounce();
48
+ }
49
+ for (const source of sources) {
50
+ options.bounce.load(source === null || source === void 0 ? void 0 : source.bounce);
51
+ }
52
+ }
53
+ reset() {
54
+ }
55
+ processBounce(position, radius, area) {
56
+ const query = this.container.particles.quadTree.query(area, (p) => this.isEnabled(p));
57
+ for (const particle of query) {
58
+ if (area instanceof engine_1.Circle) {
59
+ (0, engine_1.circleBounce)((0, engine_1.circleBounceDataFromParticle)(particle), {
60
+ position,
61
+ radius,
62
+ mass: (Math.pow(radius, 2) * Math.PI) / 2,
63
+ velocity: engine_1.Vector.origin,
64
+ factor: engine_1.Vector.origin,
65
+ });
66
+ }
67
+ else if (area instanceof engine_1.Rectangle) {
68
+ (0, engine_1.rectBounce)(particle, (0, engine_1.calculateBounds)(position, radius));
69
+ }
70
+ }
71
+ }
72
+ processMouseBounce() {
73
+ const container = this.container, pxRatio = container.retina.pixelRatio, tolerance = 10 * pxRatio, mousePos = container.interactivity.mouse.position, radius = container.retina.bounceModeDistance;
74
+ if (!radius || radius < 0 || !mousePos) {
75
+ return;
76
+ }
77
+ this.processBounce(mousePos, radius, new engine_1.Circle(mousePos.x, mousePos.y, radius + tolerance));
78
+ }
79
+ singleSelectorBounce(selector, div) {
80
+ const container = this.container, query = document.querySelectorAll(selector);
81
+ if (!query.length) {
82
+ return;
83
+ }
84
+ query.forEach((item) => {
85
+ const elem = item, pxRatio = container.retina.pixelRatio, pos = {
86
+ x: (elem.offsetLeft + elem.offsetWidth / 2) * pxRatio,
87
+ y: (elem.offsetTop + elem.offsetHeight / 2) * pxRatio,
88
+ }, radius = (elem.offsetWidth / 2) * pxRatio, tolerance = 10 * pxRatio, area = div.type === "circle"
89
+ ? new engine_1.Circle(pos.x, pos.y, radius + tolerance)
90
+ : new engine_1.Rectangle(elem.offsetLeft * pxRatio - tolerance, elem.offsetTop * pxRatio - tolerance, elem.offsetWidth * pxRatio + tolerance * 2, elem.offsetHeight * pxRatio + tolerance * 2);
91
+ this.processBounce(pos, radius, area);
92
+ });
93
+ }
94
+ }
95
+ exports.Bouncer = Bouncer;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Bounce = void 0;
4
+ class Bounce {
5
+ constructor() {
6
+ this.distance = 200;
7
+ }
8
+ load(data) {
9
+ if (!data) {
10
+ return;
11
+ }
12
+ if (data.distance !== undefined) {
13
+ this.distance = data.distance;
14
+ }
15
+ }
16
+ }
17
+ exports.Bounce = Bounce;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/cjs/Types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/cjs/index.js ADDED
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
+ return new (P || (P = Promise))(function (resolve, reject) {
19
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
23
+ });
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.loadExternalBounceInteraction = void 0;
27
+ const Bouncer_1 = require("./Bouncer");
28
+ function loadExternalBounceInteraction(engine) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ yield engine.addInteractor("externalBounce", (container) => new Bouncer_1.Bouncer(container));
31
+ });
32
+ }
33
+ exports.loadExternalBounceInteraction = loadExternalBounceInteraction;
34
+ __exportStar(require("./Options/Classes/Bounce"), exports);
35
+ __exportStar(require("./Options/Interfaces/IBounce"), exports);
package/esm/Bouncer.js ADDED
@@ -0,0 +1,80 @@
1
+ import { Circle, ExternalInteractorBase, Rectangle, Vector, calculateBounds, circleBounce, circleBounceDataFromParticle, divModeExecute, isDivModeEnabled, isInArray, mouseMoveEvent, rectBounce, } from "@tsparticles/engine";
2
+ import { Bounce } from "./Options/Classes/Bounce";
3
+ export class Bouncer extends ExternalInteractorBase {
4
+ constructor(container) {
5
+ super(container);
6
+ }
7
+ clear() {
8
+ }
9
+ init() {
10
+ const container = this.container, bounce = container.actualOptions.interactivity.modes.bounce;
11
+ if (!bounce) {
12
+ return;
13
+ }
14
+ container.retina.bounceModeDistance = bounce.distance * container.retina.pixelRatio;
15
+ }
16
+ async interact() {
17
+ const container = this.container, options = container.actualOptions, events = options.interactivity.events, mouseMoveStatus = container.interactivity.status === mouseMoveEvent, hoverEnabled = events.onHover.enable, hoverMode = events.onHover.mode, divs = events.onDiv;
18
+ if (mouseMoveStatus && hoverEnabled && isInArray("bounce", hoverMode)) {
19
+ this.processMouseBounce();
20
+ }
21
+ else {
22
+ divModeExecute("bounce", divs, (selector, div) => this.singleSelectorBounce(selector, div));
23
+ }
24
+ }
25
+ isEnabled(particle) {
26
+ var _a;
27
+ const container = this.container, options = container.actualOptions, mouse = container.interactivity.mouse, events = ((_a = particle === null || particle === void 0 ? void 0 : particle.interactivity) !== null && _a !== void 0 ? _a : options.interactivity).events, divs = events.onDiv;
28
+ return ((mouse.position && events.onHover.enable && isInArray("bounce", events.onHover.mode)) ||
29
+ isDivModeEnabled("bounce", divs));
30
+ }
31
+ loadModeOptions(options, ...sources) {
32
+ if (!options.bounce) {
33
+ options.bounce = new Bounce();
34
+ }
35
+ for (const source of sources) {
36
+ options.bounce.load(source === null || source === void 0 ? void 0 : source.bounce);
37
+ }
38
+ }
39
+ reset() {
40
+ }
41
+ processBounce(position, radius, area) {
42
+ const query = this.container.particles.quadTree.query(area, (p) => this.isEnabled(p));
43
+ for (const particle of query) {
44
+ if (area instanceof Circle) {
45
+ circleBounce(circleBounceDataFromParticle(particle), {
46
+ position,
47
+ radius,
48
+ mass: (radius ** 2 * Math.PI) / 2,
49
+ velocity: Vector.origin,
50
+ factor: Vector.origin,
51
+ });
52
+ }
53
+ else if (area instanceof Rectangle) {
54
+ rectBounce(particle, calculateBounds(position, radius));
55
+ }
56
+ }
57
+ }
58
+ processMouseBounce() {
59
+ const container = this.container, pxRatio = container.retina.pixelRatio, tolerance = 10 * pxRatio, mousePos = container.interactivity.mouse.position, radius = container.retina.bounceModeDistance;
60
+ if (!radius || radius < 0 || !mousePos) {
61
+ return;
62
+ }
63
+ this.processBounce(mousePos, radius, new Circle(mousePos.x, mousePos.y, radius + tolerance));
64
+ }
65
+ singleSelectorBounce(selector, div) {
66
+ const container = this.container, query = document.querySelectorAll(selector);
67
+ if (!query.length) {
68
+ return;
69
+ }
70
+ query.forEach((item) => {
71
+ const elem = item, pxRatio = container.retina.pixelRatio, pos = {
72
+ x: (elem.offsetLeft + elem.offsetWidth / 2) * pxRatio,
73
+ y: (elem.offsetTop + elem.offsetHeight / 2) * pxRatio,
74
+ }, radius = (elem.offsetWidth / 2) * pxRatio, tolerance = 10 * pxRatio, area = div.type === "circle"
75
+ ? new Circle(pos.x, pos.y, radius + tolerance)
76
+ : new Rectangle(elem.offsetLeft * pxRatio - tolerance, elem.offsetTop * pxRatio - tolerance, elem.offsetWidth * pxRatio + tolerance * 2, elem.offsetHeight * pxRatio + tolerance * 2);
77
+ this.processBounce(pos, radius, area);
78
+ });
79
+ }
80
+ }
@@ -0,0 +1,13 @@
1
+ export class Bounce {
2
+ constructor() {
3
+ this.distance = 200;
4
+ }
5
+ load(data) {
6
+ if (!data) {
7
+ return;
8
+ }
9
+ if (data.distance !== undefined) {
10
+ this.distance = data.distance;
11
+ }
12
+ }
13
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/esm/Types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/esm/index.js ADDED
@@ -0,0 +1,6 @@
1
+ import { Bouncer } from "./Bouncer";
2
+ export async function loadExternalBounceInteraction(engine) {
3
+ await engine.addInteractor("externalBounce", (container) => new Bouncer(container));
4
+ }
5
+ export * from "./Options/Classes/Bounce";
6
+ export * from "./Options/Interfaces/IBounce";
package/package.json ADDED
@@ -0,0 +1,82 @@
1
+ {
2
+ "name": "@tsparticles/interaction-external-bounce",
3
+ "version": "3.0.0-alpha.0",
4
+ "description": "tsParticles bounce external interaction",
5
+ "homepage": "https://particles.js.org",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/matteobruni/tsparticles.git",
9
+ "directory": "interactions/external/bounce"
10
+ },
11
+ "keywords": [
12
+ "front-end",
13
+ "frontend",
14
+ "tsparticles",
15
+ "particles.js",
16
+ "particlesjs",
17
+ "particles",
18
+ "particle",
19
+ "canvas",
20
+ "jsparticles",
21
+ "xparticles",
22
+ "particles-js",
23
+ "particles-bg",
24
+ "particles-bg-vue",
25
+ "particles-ts",
26
+ "particles.ts",
27
+ "react-particles-js",
28
+ "react-particles.js",
29
+ "react-particles",
30
+ "react",
31
+ "reactjs",
32
+ "vue-particles",
33
+ "ngx-particles",
34
+ "angular-particles",
35
+ "particleground",
36
+ "vue",
37
+ "vuejs",
38
+ "preact",
39
+ "preactjs",
40
+ "jquery",
41
+ "angularjs",
42
+ "angular",
43
+ "typescript",
44
+ "javascript",
45
+ "animation",
46
+ "web",
47
+ "html5",
48
+ "web-design",
49
+ "webdesign",
50
+ "css",
51
+ "html",
52
+ "css3",
53
+ "animated",
54
+ "background",
55
+ "confetti",
56
+ "canvas",
57
+ "fireworks",
58
+ "fireworks-js",
59
+ "confetti-js",
60
+ "confettijs",
61
+ "fireworksjs",
62
+ "canvas-confetti",
63
+ "@tsparticles/plugin",
64
+ "@tsparticles/interaction"
65
+ ],
66
+ "author": "Matteo Bruni <matteo.bruni@me.com>",
67
+ "license": "MIT",
68
+ "bugs": {
69
+ "url": "https://github.com/matteobruni/tsparticles/issues"
70
+ },
71
+ "main": "cjs/index.js",
72
+ "jsdelivr": "tsparticles.interaction.external.bounce.min.js",
73
+ "unpkg": "tsparticles.interaction.external.bounce.min.js",
74
+ "module": "esm/index.js",
75
+ "types": "types/index.d.ts",
76
+ "publishConfig": {
77
+ "access": "public"
78
+ },
79
+ "dependencies": {
80
+ "@tsparticles/engine": "^3.0.0-alpha.0"
81
+ }
82
+ }