@tsparticles/interaction-external-bounce 3.0.0-alpha.0
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +21 -0
- package/README.md +70 -0
- package/browser/Bouncer.js +80 -0
- package/browser/Options/Classes/Bounce.js +13 -0
- package/browser/Options/Classes/BounceOptions.js +1 -0
- package/browser/Options/Interfaces/IBounce.js +1 -0
- package/browser/Types.js +1 -0
- package/browser/index.js +6 -0
- package/cjs/Bouncer.js +95 -0
- package/cjs/Options/Classes/Bounce.js +17 -0
- package/cjs/Options/Classes/BounceOptions.js +2 -0
- package/cjs/Options/Interfaces/IBounce.js +2 -0
- package/cjs/Types.js +2 -0
- package/cjs/index.js +35 -0
- package/esm/Bouncer.js +80 -0
- package/esm/Options/Classes/Bounce.js +13 -0
- package/esm/Options/Classes/BounceOptions.js +1 -0
- package/esm/Options/Interfaces/IBounce.js +1 -0
- package/esm/Types.js +1 -0
- package/esm/index.js +6 -0
- package/package.json +82 -0
- package/report.html +39 -0
- package/tsparticles.interaction.external.bounce.js +221 -0
- package/tsparticles.interaction.external.bounce.min.js +2 -0
- package/tsparticles.interaction.external.bounce.min.js.LICENSE.txt +8 -0
- package/types/Bouncer.d.ts +15 -0
- package/types/Options/Classes/Bounce.d.ts +7 -0
- package/types/Options/Classes/BounceOptions.d.ts +7 -0
- package/types/Options/Interfaces/IBounce.d.ts +3 -0
- package/types/Types.d.ts +16 -0
- package/types/index.d.ts +4 -0
- package/umd/Bouncer.js +94 -0
- package/umd/Options/Classes/Bounce.js +27 -0
- package/umd/Options/Classes/BounceOptions.js +12 -0
- package/umd/Options/Interfaces/IBounce.js +12 -0
- package/umd/Types.js +12 -0
- package/umd/index.js +34 -0
@@ -0,0 +1,221 @@
|
|
1
|
+
/*!
|
2
|
+
* Author : Matteo Bruni
|
3
|
+
* MIT license: https://opensource.org/licenses/MIT
|
4
|
+
* Demo / Generator : https://particles.js.org/
|
5
|
+
* GitHub : https://www.github.com/matteobruni/tsparticles
|
6
|
+
* How to use? : Check the GitHub README
|
7
|
+
* v3.0.0-alpha.0
|
8
|
+
*/
|
9
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
10
|
+
if(typeof exports === 'object' && typeof module === 'object')
|
11
|
+
module.exports = factory(require("@tsparticles/engine"));
|
12
|
+
else if(typeof define === 'function' && define.amd)
|
13
|
+
define(["@tsparticles/engine"], factory);
|
14
|
+
else {
|
15
|
+
var a = typeof exports === 'object' ? factory(require("@tsparticles/engine")) : factory(root["window"]);
|
16
|
+
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
17
|
+
}
|
18
|
+
})(this, (__WEBPACK_EXTERNAL_MODULE__533__) => {
|
19
|
+
return /******/ (() => { // webpackBootstrap
|
20
|
+
/******/ "use strict";
|
21
|
+
/******/ var __webpack_modules__ = ({
|
22
|
+
|
23
|
+
/***/ 533:
|
24
|
+
/***/ ((module) => {
|
25
|
+
|
26
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
|
27
|
+
|
28
|
+
/***/ })
|
29
|
+
|
30
|
+
/******/ });
|
31
|
+
/************************************************************************/
|
32
|
+
/******/ // The module cache
|
33
|
+
/******/ var __webpack_module_cache__ = {};
|
34
|
+
/******/
|
35
|
+
/******/ // The require function
|
36
|
+
/******/ function __webpack_require__(moduleId) {
|
37
|
+
/******/ // Check if module is in cache
|
38
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
39
|
+
/******/ if (cachedModule !== undefined) {
|
40
|
+
/******/ return cachedModule.exports;
|
41
|
+
/******/ }
|
42
|
+
/******/ // Create a new module (and put it into the cache)
|
43
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
44
|
+
/******/ // no module.id needed
|
45
|
+
/******/ // no module.loaded needed
|
46
|
+
/******/ exports: {}
|
47
|
+
/******/ };
|
48
|
+
/******/
|
49
|
+
/******/ // Execute the module function
|
50
|
+
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
51
|
+
/******/
|
52
|
+
/******/ // Return the exports of the module
|
53
|
+
/******/ return module.exports;
|
54
|
+
/******/ }
|
55
|
+
/******/
|
56
|
+
/************************************************************************/
|
57
|
+
/******/ /* webpack/runtime/define property getters */
|
58
|
+
/******/ (() => {
|
59
|
+
/******/ // define getter functions for harmony exports
|
60
|
+
/******/ __webpack_require__.d = (exports, definition) => {
|
61
|
+
/******/ for(var key in definition) {
|
62
|
+
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
63
|
+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
64
|
+
/******/ }
|
65
|
+
/******/ }
|
66
|
+
/******/ };
|
67
|
+
/******/ })();
|
68
|
+
/******/
|
69
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
70
|
+
/******/ (() => {
|
71
|
+
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
72
|
+
/******/ })();
|
73
|
+
/******/
|
74
|
+
/******/ /* webpack/runtime/make namespace object */
|
75
|
+
/******/ (() => {
|
76
|
+
/******/ // define __esModule on exports
|
77
|
+
/******/ __webpack_require__.r = (exports) => {
|
78
|
+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
79
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
80
|
+
/******/ }
|
81
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
82
|
+
/******/ };
|
83
|
+
/******/ })();
|
84
|
+
/******/
|
85
|
+
/************************************************************************/
|
86
|
+
var __webpack_exports__ = {};
|
87
|
+
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
88
|
+
(() => {
|
89
|
+
// ESM COMPAT FLAG
|
90
|
+
__webpack_require__.r(__webpack_exports__);
|
91
|
+
|
92
|
+
// EXPORTS
|
93
|
+
__webpack_require__.d(__webpack_exports__, {
|
94
|
+
"Bounce": () => (/* reexport */ Bounce),
|
95
|
+
"loadExternalBounceInteraction": () => (/* binding */ loadExternalBounceInteraction)
|
96
|
+
});
|
97
|
+
|
98
|
+
// EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
|
99
|
+
var engine_root_window_ = __webpack_require__(533);
|
100
|
+
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Bounce.js
|
101
|
+
class Bounce {
|
102
|
+
constructor() {
|
103
|
+
this.distance = 200;
|
104
|
+
}
|
105
|
+
load(data) {
|
106
|
+
if (!data) {
|
107
|
+
return;
|
108
|
+
}
|
109
|
+
if (data.distance !== undefined) {
|
110
|
+
this.distance = data.distance;
|
111
|
+
}
|
112
|
+
}
|
113
|
+
}
|
114
|
+
;// CONCATENATED MODULE: ./dist/browser/Bouncer.js
|
115
|
+
|
116
|
+
|
117
|
+
class Bouncer extends engine_root_window_.ExternalInteractorBase {
|
118
|
+
constructor(container) {
|
119
|
+
super(container);
|
120
|
+
}
|
121
|
+
clear() {}
|
122
|
+
init() {
|
123
|
+
const container = this.container,
|
124
|
+
bounce = container.actualOptions.interactivity.modes.bounce;
|
125
|
+
if (!bounce) {
|
126
|
+
return;
|
127
|
+
}
|
128
|
+
container.retina.bounceModeDistance = bounce.distance * container.retina.pixelRatio;
|
129
|
+
}
|
130
|
+
async interact() {
|
131
|
+
const container = this.container,
|
132
|
+
options = container.actualOptions,
|
133
|
+
events = options.interactivity.events,
|
134
|
+
mouseMoveStatus = container.interactivity.status === engine_root_window_.mouseMoveEvent,
|
135
|
+
hoverEnabled = events.onHover.enable,
|
136
|
+
hoverMode = events.onHover.mode,
|
137
|
+
divs = events.onDiv;
|
138
|
+
if (mouseMoveStatus && hoverEnabled && (0,engine_root_window_.isInArray)("bounce", hoverMode)) {
|
139
|
+
this.processMouseBounce();
|
140
|
+
} else {
|
141
|
+
(0,engine_root_window_.divModeExecute)("bounce", divs, (selector, div) => this.singleSelectorBounce(selector, div));
|
142
|
+
}
|
143
|
+
}
|
144
|
+
isEnabled(particle) {
|
145
|
+
var _a;
|
146
|
+
const container = this.container,
|
147
|
+
options = container.actualOptions,
|
148
|
+
mouse = container.interactivity.mouse,
|
149
|
+
events = ((_a = particle === null || particle === void 0 ? void 0 : particle.interactivity) !== null && _a !== void 0 ? _a : options.interactivity).events,
|
150
|
+
divs = events.onDiv;
|
151
|
+
return mouse.position && events.onHover.enable && (0,engine_root_window_.isInArray)("bounce", events.onHover.mode) || (0,engine_root_window_.isDivModeEnabled)("bounce", divs);
|
152
|
+
}
|
153
|
+
loadModeOptions(options, ...sources) {
|
154
|
+
if (!options.bounce) {
|
155
|
+
options.bounce = new Bounce();
|
156
|
+
}
|
157
|
+
for (const source of sources) {
|
158
|
+
options.bounce.load(source === null || source === void 0 ? void 0 : source.bounce);
|
159
|
+
}
|
160
|
+
}
|
161
|
+
reset() {}
|
162
|
+
processBounce(position, radius, area) {
|
163
|
+
const query = this.container.particles.quadTree.query(area, p => this.isEnabled(p));
|
164
|
+
for (const particle of query) {
|
165
|
+
if (area instanceof engine_root_window_.Circle) {
|
166
|
+
(0,engine_root_window_.circleBounce)((0,engine_root_window_.circleBounceDataFromParticle)(particle), {
|
167
|
+
position,
|
168
|
+
radius,
|
169
|
+
mass: radius ** 2 * Math.PI / 2,
|
170
|
+
velocity: engine_root_window_.Vector.origin,
|
171
|
+
factor: engine_root_window_.Vector.origin
|
172
|
+
});
|
173
|
+
} else if (area instanceof engine_root_window_.Rectangle) {
|
174
|
+
(0,engine_root_window_.rectBounce)(particle, (0,engine_root_window_.calculateBounds)(position, radius));
|
175
|
+
}
|
176
|
+
}
|
177
|
+
}
|
178
|
+
processMouseBounce() {
|
179
|
+
const container = this.container,
|
180
|
+
pxRatio = container.retina.pixelRatio,
|
181
|
+
tolerance = 10 * pxRatio,
|
182
|
+
mousePos = container.interactivity.mouse.position,
|
183
|
+
radius = container.retina.bounceModeDistance;
|
184
|
+
if (!radius || radius < 0 || !mousePos) {
|
185
|
+
return;
|
186
|
+
}
|
187
|
+
this.processBounce(mousePos, radius, new engine_root_window_.Circle(mousePos.x, mousePos.y, radius + tolerance));
|
188
|
+
}
|
189
|
+
singleSelectorBounce(selector, div) {
|
190
|
+
const container = this.container,
|
191
|
+
query = document.querySelectorAll(selector);
|
192
|
+
if (!query.length) {
|
193
|
+
return;
|
194
|
+
}
|
195
|
+
query.forEach(item => {
|
196
|
+
const elem = item,
|
197
|
+
pxRatio = container.retina.pixelRatio,
|
198
|
+
pos = {
|
199
|
+
x: (elem.offsetLeft + elem.offsetWidth / 2) * pxRatio,
|
200
|
+
y: (elem.offsetTop + elem.offsetHeight / 2) * pxRatio
|
201
|
+
},
|
202
|
+
radius = elem.offsetWidth / 2 * pxRatio,
|
203
|
+
tolerance = 10 * pxRatio,
|
204
|
+
area = div.type === "circle" ? new engine_root_window_.Circle(pos.x, pos.y, radius + tolerance) : new engine_root_window_.Rectangle(elem.offsetLeft * pxRatio - tolerance, elem.offsetTop * pxRatio - tolerance, elem.offsetWidth * pxRatio + tolerance * 2, elem.offsetHeight * pxRatio + tolerance * 2);
|
205
|
+
this.processBounce(pos, radius, area);
|
206
|
+
});
|
207
|
+
}
|
208
|
+
}
|
209
|
+
;// CONCATENATED MODULE: ./dist/browser/index.js
|
210
|
+
|
211
|
+
async function loadExternalBounceInteraction(engine) {
|
212
|
+
await engine.addInteractor("externalBounce", container => new Bouncer(container));
|
213
|
+
}
|
214
|
+
|
215
|
+
|
216
|
+
})();
|
217
|
+
|
218
|
+
/******/ return __webpack_exports__;
|
219
|
+
/******/ })()
|
220
|
+
;
|
221
|
+
});
|
@@ -0,0 +1,2 @@
|
|
1
|
+
/*! For license information please see tsparticles.interaction.external.bounce.min.js.LICENSE.txt */
|
2
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var o="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var n in o)("object"==typeof exports?exports:e)[n]=o[n]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},o={};function n(e){var i=o[e];if(void 0!==i)return i.exports;var r=o[e]={exports:{}};return t[e](r,r.exports,n),r.exports}n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{n.r(i),n.d(i,{Bounce:()=>t,loadExternalBounceInteraction:()=>r});var e=n(533);class t{constructor(){this.distance=200}load(e){e&&void 0!==e.distance&&(this.distance=e.distance)}}class o extends e.ExternalInteractorBase{constructor(e){super(e)}clear(){}init(){const e=this.container,t=e.actualOptions.interactivity.modes.bounce;t&&(e.retina.bounceModeDistance=t.distance*e.retina.pixelRatio)}async interact(){const t=this.container,o=t.actualOptions.interactivity.events,n=t.interactivity.status===e.mouseMoveEvent,i=o.onHover.enable,r=o.onHover.mode,c=o.onDiv;n&&i&&(0,e.isInArray)("bounce",r)?this.processMouseBounce():(0,e.divModeExecute)("bounce",c,((e,t)=>this.singleSelectorBounce(e,t)))}isEnabled(t){var o;const n=this.container,i=n.actualOptions,r=n.interactivity.mouse,c=(null!==(o=null==t?void 0:t.interactivity)&&void 0!==o?o:i.interactivity).events,s=c.onDiv;return r.position&&c.onHover.enable&&(0,e.isInArray)("bounce",c.onHover.mode)||(0,e.isDivModeEnabled)("bounce",s)}loadModeOptions(e,...o){e.bounce||(e.bounce=new t);for(const t of o)e.bounce.load(null==t?void 0:t.bounce)}reset(){}processBounce(t,o,n){const i=this.container.particles.quadTree.query(n,(e=>this.isEnabled(e)));for(const r of i)n instanceof e.Circle?(0,e.circleBounce)((0,e.circleBounceDataFromParticle)(r),{position:t,radius:o,mass:o**2*Math.PI/2,velocity:e.Vector.origin,factor:e.Vector.origin}):n instanceof e.Rectangle&&(0,e.rectBounce)(r,(0,e.calculateBounds)(t,o))}processMouseBounce(){const t=this.container,o=10*t.retina.pixelRatio,n=t.interactivity.mouse.position,i=t.retina.bounceModeDistance;!i||i<0||!n||this.processBounce(n,i,new e.Circle(n.x,n.y,i+o))}singleSelectorBounce(t,o){const n=this.container,i=document.querySelectorAll(t);i.length&&i.forEach((t=>{const i=t,r=n.retina.pixelRatio,c={x:(i.offsetLeft+i.offsetWidth/2)*r,y:(i.offsetTop+i.offsetHeight/2)*r},s=i.offsetWidth/2*r,a=10*r,u="circle"===o.type?new e.Circle(c.x,c.y,s+a):new e.Rectangle(i.offsetLeft*r-a,i.offsetTop*r-a,i.offsetWidth*r+2*a,i.offsetHeight*r+2*a);this.processBounce(c,s,u)}))}}async function r(e){await e.addInteractor("externalBounce",(e=>new o(e)))}})(),i})()));
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import type { BounceContainer, BounceMode, IBounceMode } from "./Types";
|
2
|
+
import { ExternalInteractorBase } from "@tsparticles/engine";
|
3
|
+
import type { IModes, Modes, Particle, RecursivePartial } from "@tsparticles/engine";
|
4
|
+
export declare class Bouncer extends ExternalInteractorBase<BounceContainer> {
|
5
|
+
constructor(container: BounceContainer);
|
6
|
+
clear(): void;
|
7
|
+
init(): void;
|
8
|
+
interact(): Promise<void>;
|
9
|
+
isEnabled(particle?: Particle): boolean;
|
10
|
+
loadModeOptions(options: Modes & BounceMode, ...sources: RecursivePartial<(IModes & IBounceMode) | undefined>[]): void;
|
11
|
+
reset(): void;
|
12
|
+
private processBounce;
|
13
|
+
private processMouseBounce;
|
14
|
+
private singleSelectorBounce;
|
15
|
+
}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import type { IOptionLoader, RecursivePartial } from "@tsparticles/engine";
|
2
|
+
import type { IBounce } from "../Interfaces/IBounce";
|
3
|
+
export declare class Bounce implements IBounce, IOptionLoader<IBounce> {
|
4
|
+
distance: number;
|
5
|
+
constructor();
|
6
|
+
load(data?: RecursivePartial<IBounce>): void;
|
7
|
+
}
|
package/types/Types.d.ts
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
import type { Bounce } from "./Options/Classes/Bounce";
|
2
|
+
import type { BounceOptions } from "./Options/Classes/BounceOptions";
|
3
|
+
import type { Container } from "@tsparticles/engine";
|
4
|
+
import type { IBounce } from "./Options/Interfaces/IBounce";
|
5
|
+
export type IBounceMode = {
|
6
|
+
bounce: IBounce;
|
7
|
+
};
|
8
|
+
export type BounceMode = {
|
9
|
+
bounce?: Bounce;
|
10
|
+
};
|
11
|
+
export type BounceContainer = Container & {
|
12
|
+
actualOptions: BounceOptions;
|
13
|
+
retina: {
|
14
|
+
bounceModeDistance?: number;
|
15
|
+
};
|
16
|
+
};
|
package/types/index.d.ts
ADDED
package/umd/Bouncer.js
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
(function (factory) {
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
3
|
+
var v = factory(require, exports);
|
4
|
+
if (v !== undefined) module.exports = v;
|
5
|
+
}
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
7
|
+
define(["require", "exports", "@tsparticles/engine", "./Options/Classes/Bounce"], factory);
|
8
|
+
}
|
9
|
+
})(function (require, exports) {
|
10
|
+
"use strict";
|
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
|
+
async interact() {
|
29
|
+
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;
|
30
|
+
if (mouseMoveStatus && hoverEnabled && (0, engine_1.isInArray)("bounce", hoverMode)) {
|
31
|
+
this.processMouseBounce();
|
32
|
+
}
|
33
|
+
else {
|
34
|
+
(0, engine_1.divModeExecute)("bounce", divs, (selector, div) => this.singleSelectorBounce(selector, div));
|
35
|
+
}
|
36
|
+
}
|
37
|
+
isEnabled(particle) {
|
38
|
+
var _a;
|
39
|
+
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;
|
40
|
+
return ((mouse.position && events.onHover.enable && (0, engine_1.isInArray)("bounce", events.onHover.mode)) ||
|
41
|
+
(0, engine_1.isDivModeEnabled)("bounce", divs));
|
42
|
+
}
|
43
|
+
loadModeOptions(options, ...sources) {
|
44
|
+
if (!options.bounce) {
|
45
|
+
options.bounce = new Bounce_1.Bounce();
|
46
|
+
}
|
47
|
+
for (const source of sources) {
|
48
|
+
options.bounce.load(source === null || source === void 0 ? void 0 : source.bounce);
|
49
|
+
}
|
50
|
+
}
|
51
|
+
reset() {
|
52
|
+
}
|
53
|
+
processBounce(position, radius, area) {
|
54
|
+
const query = this.container.particles.quadTree.query(area, (p) => this.isEnabled(p));
|
55
|
+
for (const particle of query) {
|
56
|
+
if (area instanceof engine_1.Circle) {
|
57
|
+
(0, engine_1.circleBounce)((0, engine_1.circleBounceDataFromParticle)(particle), {
|
58
|
+
position,
|
59
|
+
radius,
|
60
|
+
mass: (radius ** 2 * Math.PI) / 2,
|
61
|
+
velocity: engine_1.Vector.origin,
|
62
|
+
factor: engine_1.Vector.origin,
|
63
|
+
});
|
64
|
+
}
|
65
|
+
else if (area instanceof engine_1.Rectangle) {
|
66
|
+
(0, engine_1.rectBounce)(particle, (0, engine_1.calculateBounds)(position, radius));
|
67
|
+
}
|
68
|
+
}
|
69
|
+
}
|
70
|
+
processMouseBounce() {
|
71
|
+
const container = this.container, pxRatio = container.retina.pixelRatio, tolerance = 10 * pxRatio, mousePos = container.interactivity.mouse.position, radius = container.retina.bounceModeDistance;
|
72
|
+
if (!radius || radius < 0 || !mousePos) {
|
73
|
+
return;
|
74
|
+
}
|
75
|
+
this.processBounce(mousePos, radius, new engine_1.Circle(mousePos.x, mousePos.y, radius + tolerance));
|
76
|
+
}
|
77
|
+
singleSelectorBounce(selector, div) {
|
78
|
+
const container = this.container, query = document.querySelectorAll(selector);
|
79
|
+
if (!query.length) {
|
80
|
+
return;
|
81
|
+
}
|
82
|
+
query.forEach((item) => {
|
83
|
+
const elem = item, pxRatio = container.retina.pixelRatio, pos = {
|
84
|
+
x: (elem.offsetLeft + elem.offsetWidth / 2) * pxRatio,
|
85
|
+
y: (elem.offsetTop + elem.offsetHeight / 2) * pxRatio,
|
86
|
+
}, radius = (elem.offsetWidth / 2) * pxRatio, tolerance = 10 * pxRatio, area = div.type === "circle"
|
87
|
+
? new engine_1.Circle(pos.x, pos.y, radius + tolerance)
|
88
|
+
: new engine_1.Rectangle(elem.offsetLeft * pxRatio - tolerance, elem.offsetTop * pxRatio - tolerance, elem.offsetWidth * pxRatio + tolerance * 2, elem.offsetHeight * pxRatio + tolerance * 2);
|
89
|
+
this.processBounce(pos, radius, area);
|
90
|
+
});
|
91
|
+
}
|
92
|
+
}
|
93
|
+
exports.Bouncer = Bouncer;
|
94
|
+
});
|
@@ -0,0 +1,27 @@
|
|
1
|
+
(function (factory) {
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
3
|
+
var v = factory(require, exports);
|
4
|
+
if (v !== undefined) module.exports = v;
|
5
|
+
}
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
7
|
+
define(["require", "exports"], factory);
|
8
|
+
}
|
9
|
+
})(function (require, exports) {
|
10
|
+
"use strict";
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.Bounce = void 0;
|
13
|
+
class Bounce {
|
14
|
+
constructor() {
|
15
|
+
this.distance = 200;
|
16
|
+
}
|
17
|
+
load(data) {
|
18
|
+
if (!data) {
|
19
|
+
return;
|
20
|
+
}
|
21
|
+
if (data.distance !== undefined) {
|
22
|
+
this.distance = data.distance;
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}
|
26
|
+
exports.Bounce = Bounce;
|
27
|
+
});
|
@@ -0,0 +1,12 @@
|
|
1
|
+
(function (factory) {
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
3
|
+
var v = factory(require, exports);
|
4
|
+
if (v !== undefined) module.exports = v;
|
5
|
+
}
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
7
|
+
define(["require", "exports"], factory);
|
8
|
+
}
|
9
|
+
})(function (require, exports) {
|
10
|
+
"use strict";
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
});
|
@@ -0,0 +1,12 @@
|
|
1
|
+
(function (factory) {
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
3
|
+
var v = factory(require, exports);
|
4
|
+
if (v !== undefined) module.exports = v;
|
5
|
+
}
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
7
|
+
define(["require", "exports"], factory);
|
8
|
+
}
|
9
|
+
})(function (require, exports) {
|
10
|
+
"use strict";
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
});
|
package/umd/Types.js
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
(function (factory) {
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
3
|
+
var v = factory(require, exports);
|
4
|
+
if (v !== undefined) module.exports = v;
|
5
|
+
}
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
7
|
+
define(["require", "exports"], factory);
|
8
|
+
}
|
9
|
+
})(function (require, exports) {
|
10
|
+
"use strict";
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
});
|
package/umd/index.js
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
2
|
+
if (k2 === undefined) k2 = k;
|
3
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
4
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
5
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
6
|
+
}
|
7
|
+
Object.defineProperty(o, k2, desc);
|
8
|
+
}) : (function(o, m, k, k2) {
|
9
|
+
if (k2 === undefined) k2 = k;
|
10
|
+
o[k2] = m[k];
|
11
|
+
}));
|
12
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
13
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
14
|
+
};
|
15
|
+
(function (factory) {
|
16
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
17
|
+
var v = factory(require, exports);
|
18
|
+
if (v !== undefined) module.exports = v;
|
19
|
+
}
|
20
|
+
else if (typeof define === "function" && define.amd) {
|
21
|
+
define(["require", "exports", "./Bouncer", "./Options/Classes/Bounce", "./Options/Interfaces/IBounce"], factory);
|
22
|
+
}
|
23
|
+
})(function (require, exports) {
|
24
|
+
"use strict";
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
26
|
+
exports.loadExternalBounceInteraction = void 0;
|
27
|
+
const Bouncer_1 = require("./Bouncer");
|
28
|
+
async function loadExternalBounceInteraction(engine) {
|
29
|
+
await engine.addInteractor("externalBounce", (container) => new Bouncer_1.Bouncer(container));
|
30
|
+
}
|
31
|
+
exports.loadExternalBounceInteraction = loadExternalBounceInteraction;
|
32
|
+
__exportStar(require("./Options/Classes/Bounce"), exports);
|
33
|
+
__exportStar(require("./Options/Interfaces/IBounce"), exports);
|
34
|
+
});
|