@tsparticles/interaction-external-bubble 4.1.2 → 4.2.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.
- package/browser/Bubbler.js +16 -19
- package/browser/Options/Classes/BubbleBase.js +9 -24
- package/browser/Options/Classes/BubbleDiv.js +3 -9
- package/browser/index.js +1 -1
- package/browser/index.lazy.js +1 -1
- package/cjs/Bubbler.js +16 -19
- package/cjs/Options/Classes/BubbleBase.js +9 -24
- package/cjs/Options/Classes/BubbleDiv.js +3 -9
- package/cjs/index.js +1 -1
- package/cjs/index.lazy.js +1 -1
- package/esm/Bubbler.js +16 -19
- package/esm/Options/Classes/BubbleBase.js +9 -24
- package/esm/Options/Classes/BubbleDiv.js +3 -9
- package/esm/index.js +1 -1
- package/esm/index.lazy.js +1 -1
- package/package.json +3 -3
- package/report.html +1 -1
- package/tsparticles.interaction.external.bubble.js +27 -51
- package/tsparticles.interaction.external.bubble.min.js +1 -1
- package/types/Options/Classes/BubbleBase.d.ts +0 -1
- package/types/Options/Classes/BubbleDiv.d.ts +0 -1
- package/types/Options/Classes/BubbleOptions.d.ts +4 -2
package/browser/Bubbler.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Circle, Rectangle, colorMix, double, getDistance, half, isInArray, itemFromSingleOrMultiple, millisecondsToSeconds, rangeColorToHsl, rgbToHsl, safeDocument, } from "@tsparticles/engine";
|
|
1
|
+
import { Circle, Rectangle, colorMix, double, getDistance, half, isInArray, itemFromSingleOrMultiple, loadOptionProperty, millisecondsToSeconds, rangeColorToHsl, rgbToHsl, safeDocument, } from "@tsparticles/engine";
|
|
2
2
|
import { DivType, ExternalInteractorBase, divMode, divModeExecute, isDivModeEnabled, mouseLeaveEvent, mouseMoveEvent, } from "@tsparticles/plugin-interactivity";
|
|
3
3
|
import { Bubble } from "./Options/Classes/Bubble.js";
|
|
4
4
|
import { ProcessBubbleType } from "./Enums.js";
|
|
@@ -74,15 +74,12 @@ export class Bubbler extends ExternalInteractorBase {
|
|
|
74
74
|
return isInArray(bubbleMode, onHover.mode) || isInArray(bubbleMode, onClick.mode) || divBubble;
|
|
75
75
|
}
|
|
76
76
|
loadModeOptions(options, ...sources) {
|
|
77
|
-
options
|
|
78
|
-
for (const source of sources) {
|
|
79
|
-
options.bubble.load(source?.bubble);
|
|
80
|
-
}
|
|
77
|
+
loadOptionProperty(options, "bubble", Bubble, ...sources);
|
|
81
78
|
}
|
|
82
79
|
reset(_interactivityData, particle) {
|
|
83
80
|
particle.bubble.inRange = false;
|
|
84
81
|
}
|
|
85
|
-
#clickBubble
|
|
82
|
+
#clickBubble(interactivityData) {
|
|
86
83
|
const container = this.container, options = container.actualOptions, mouseClickPos = interactivityData.mouse.clickPosition, bubbleOptions = options.interactivity?.modes.bubble;
|
|
87
84
|
if (!bubbleOptions || !mouseClickPos) {
|
|
88
85
|
return;
|
|
@@ -137,8 +134,8 @@ export class Bubbler extends ExternalInteractorBase {
|
|
|
137
134
|
delete particle.bubble.color;
|
|
138
135
|
}
|
|
139
136
|
}
|
|
140
|
-
}
|
|
141
|
-
#hoverBubble
|
|
137
|
+
}
|
|
138
|
+
#hoverBubble(interactivityData) {
|
|
142
139
|
const container = this.container, mousePos = interactivityData.mouse.position, distance = container.retina.bubbleModeDistance;
|
|
143
140
|
if (!distance || distance < minDistance || !mousePos) {
|
|
144
141
|
return;
|
|
@@ -161,8 +158,8 @@ export class Bubbler extends ExternalInteractorBase {
|
|
|
161
158
|
this.reset(interactivityData, particle);
|
|
162
159
|
}
|
|
163
160
|
}
|
|
164
|
-
}
|
|
165
|
-
#hoverBubbleColor
|
|
161
|
+
}
|
|
162
|
+
#hoverBubbleColor(particle, ratio, divBubble) {
|
|
166
163
|
const options = this.container.actualOptions, bubbleOptions = divBubble ?? options.interactivity?.modes.bubble;
|
|
167
164
|
if (!bubbleOptions) {
|
|
168
165
|
return;
|
|
@@ -188,8 +185,8 @@ export class Bubbler extends ExternalInteractorBase {
|
|
|
188
185
|
else {
|
|
189
186
|
particle.bubble.color = particle.bubble.finalColor;
|
|
190
187
|
}
|
|
191
|
-
}
|
|
192
|
-
#hoverBubbleOpacity
|
|
188
|
+
}
|
|
189
|
+
#hoverBubbleOpacity(particle, ratio, divBubble) {
|
|
193
190
|
const container = this.container, options = container.actualOptions, modeOpacity = divBubble?.opacity ?? options.interactivity?.modes.bubble?.opacity;
|
|
194
191
|
if (!modeOpacity) {
|
|
195
192
|
return;
|
|
@@ -198,8 +195,8 @@ export class Bubbler extends ExternalInteractorBase {
|
|
|
198
195
|
if (opacity !== undefined) {
|
|
199
196
|
particle.bubble.opacity = opacity;
|
|
200
197
|
}
|
|
201
|
-
}
|
|
202
|
-
#hoverBubbleSize
|
|
198
|
+
}
|
|
199
|
+
#hoverBubbleSize(particle, ratio, divBubble) {
|
|
203
200
|
const container = this.container, modeSize = divBubble?.size ? divBubble.size * container.retina.pixelRatio : container.retina.bubbleModeSize;
|
|
204
201
|
if (modeSize === undefined) {
|
|
205
202
|
return;
|
|
@@ -208,8 +205,8 @@ export class Bubbler extends ExternalInteractorBase {
|
|
|
208
205
|
if (size !== undefined) {
|
|
209
206
|
particle.bubble.radius = size;
|
|
210
207
|
}
|
|
211
|
-
}
|
|
212
|
-
#process
|
|
208
|
+
}
|
|
209
|
+
#process(particle, distMouse, timeSpent, data) {
|
|
213
210
|
const container = this.container, bubbleParam = data.bubbleObj.optValue, options = container.actualOptions, bubbleOptions = options.interactivity?.modes.bubble;
|
|
214
211
|
if (!bubbleOptions || bubbleParam === undefined) {
|
|
215
212
|
return;
|
|
@@ -251,8 +248,8 @@ export class Bubbler extends ExternalInteractorBase {
|
|
|
251
248
|
}
|
|
252
249
|
}
|
|
253
250
|
}
|
|
254
|
-
}
|
|
255
|
-
#singleSelectorHover
|
|
251
|
+
}
|
|
252
|
+
#singleSelectorHover(interactivityData, delta, selector, div) {
|
|
256
253
|
const container = this.container, selectors = safeDocument().querySelectorAll(selector), bubble = container.actualOptions.interactivity?.modes.bubble;
|
|
257
254
|
if (!bubble || !selectors.length) {
|
|
258
255
|
return;
|
|
@@ -279,5 +276,5 @@ export class Bubbler extends ExternalInteractorBase {
|
|
|
279
276
|
this.#hoverBubbleColor(particle, defaultRatio, divBubble);
|
|
280
277
|
}
|
|
281
278
|
});
|
|
282
|
-
}
|
|
279
|
+
}
|
|
283
280
|
}
|
|
@@ -1,40 +1,25 @@
|
|
|
1
|
-
import { OptionsColor, executeOnSingleOrMultiple, isArray, isNull, } from "@tsparticles/engine";
|
|
1
|
+
import { OptionsColor, executeOnSingleOrMultiple, isArray, isNull, loadProperty, loadRangeProperty, } from "@tsparticles/engine";
|
|
2
2
|
export class BubbleBase {
|
|
3
3
|
color;
|
|
4
|
-
distance;
|
|
5
|
-
duration;
|
|
6
|
-
mix;
|
|
4
|
+
distance = 200;
|
|
5
|
+
duration = 0.4;
|
|
6
|
+
mix = false;
|
|
7
7
|
opacity;
|
|
8
8
|
size;
|
|
9
|
-
constructor() {
|
|
10
|
-
this.distance = 200;
|
|
11
|
-
this.duration = 0.4;
|
|
12
|
-
this.mix = false;
|
|
13
|
-
}
|
|
14
9
|
load(data) {
|
|
15
10
|
if (isNull(data)) {
|
|
16
11
|
return;
|
|
17
12
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
this.duration = data.duration;
|
|
23
|
-
}
|
|
24
|
-
if (data.mix !== undefined) {
|
|
25
|
-
this.mix = data.mix;
|
|
26
|
-
}
|
|
27
|
-
if (data.opacity !== undefined) {
|
|
28
|
-
this.opacity = data.opacity;
|
|
29
|
-
}
|
|
13
|
+
loadProperty(this, "distance", data.distance);
|
|
14
|
+
loadProperty(this, "duration", data.duration);
|
|
15
|
+
loadProperty(this, "mix", data.mix);
|
|
16
|
+
loadRangeProperty(this, "opacity", data.opacity);
|
|
30
17
|
if (data.color !== undefined) {
|
|
31
18
|
const sourceColor = isArray(this.color) ? undefined : this.color;
|
|
32
19
|
this.color = executeOnSingleOrMultiple(data.color, color => {
|
|
33
20
|
return OptionsColor.create(sourceColor, color);
|
|
34
21
|
});
|
|
35
22
|
}
|
|
36
|
-
|
|
37
|
-
this.size = data.size;
|
|
38
|
-
}
|
|
23
|
+
loadProperty(this, "size", data.size);
|
|
39
24
|
}
|
|
40
25
|
}
|
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
import { isNull } from "@tsparticles/engine";
|
|
1
|
+
import { isNull, loadProperty, } from "@tsparticles/engine";
|
|
2
2
|
import { BubbleBase } from "./BubbleBase.js";
|
|
3
3
|
export class BubbleDiv extends BubbleBase {
|
|
4
|
-
selectors;
|
|
5
|
-
constructor() {
|
|
6
|
-
super();
|
|
7
|
-
this.selectors = [];
|
|
8
|
-
}
|
|
4
|
+
selectors = [];
|
|
9
5
|
load(data) {
|
|
10
6
|
super.load(data);
|
|
11
7
|
if (isNull(data)) {
|
|
12
8
|
return;
|
|
13
9
|
}
|
|
14
|
-
|
|
15
|
-
this.selectors = data.selectors;
|
|
16
|
-
}
|
|
10
|
+
loadProperty(this, "selectors", data.selectors);
|
|
17
11
|
}
|
|
18
12
|
}
|
package/browser/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ensureInteractivityPluginLoaded } from "@tsparticles/plugin-interactivity";
|
|
2
2
|
import { Bubbler } from "./Bubbler.js";
|
|
3
3
|
export async function loadExternalBubbleInteraction(engine) {
|
|
4
|
-
engine.checkVersion("4.
|
|
4
|
+
engine.checkVersion("4.2.0");
|
|
5
5
|
await engine.pluginManager.register((e) => {
|
|
6
6
|
ensureInteractivityPluginLoaded(e);
|
|
7
7
|
e.pluginManager.addInteractor?.("externalBubble", container => {
|
package/browser/index.lazy.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export async function loadExternalBubbleInteraction(engine) {
|
|
2
|
-
engine.checkVersion("4.
|
|
2
|
+
engine.checkVersion("4.2.0");
|
|
3
3
|
await engine.pluginManager.register(async (e) => {
|
|
4
4
|
const { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity/lazy");
|
|
5
5
|
ensureInteractivityPluginLoaded(e);
|
package/cjs/Bubbler.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Circle, Rectangle, colorMix, double, getDistance, half, isInArray, itemFromSingleOrMultiple, millisecondsToSeconds, rangeColorToHsl, rgbToHsl, safeDocument, } from "@tsparticles/engine";
|
|
1
|
+
import { Circle, Rectangle, colorMix, double, getDistance, half, isInArray, itemFromSingleOrMultiple, loadOptionProperty, millisecondsToSeconds, rangeColorToHsl, rgbToHsl, safeDocument, } from "@tsparticles/engine";
|
|
2
2
|
import { DivType, ExternalInteractorBase, divMode, divModeExecute, isDivModeEnabled, mouseLeaveEvent, mouseMoveEvent, } from "@tsparticles/plugin-interactivity";
|
|
3
3
|
import { Bubble } from "./Options/Classes/Bubble.js";
|
|
4
4
|
import { ProcessBubbleType } from "./Enums.js";
|
|
@@ -74,15 +74,12 @@ export class Bubbler extends ExternalInteractorBase {
|
|
|
74
74
|
return isInArray(bubbleMode, onHover.mode) || isInArray(bubbleMode, onClick.mode) || divBubble;
|
|
75
75
|
}
|
|
76
76
|
loadModeOptions(options, ...sources) {
|
|
77
|
-
options
|
|
78
|
-
for (const source of sources) {
|
|
79
|
-
options.bubble.load(source?.bubble);
|
|
80
|
-
}
|
|
77
|
+
loadOptionProperty(options, "bubble", Bubble, ...sources);
|
|
81
78
|
}
|
|
82
79
|
reset(_interactivityData, particle) {
|
|
83
80
|
particle.bubble.inRange = false;
|
|
84
81
|
}
|
|
85
|
-
#clickBubble
|
|
82
|
+
#clickBubble(interactivityData) {
|
|
86
83
|
const container = this.container, options = container.actualOptions, mouseClickPos = interactivityData.mouse.clickPosition, bubbleOptions = options.interactivity?.modes.bubble;
|
|
87
84
|
if (!bubbleOptions || !mouseClickPos) {
|
|
88
85
|
return;
|
|
@@ -137,8 +134,8 @@ export class Bubbler extends ExternalInteractorBase {
|
|
|
137
134
|
delete particle.bubble.color;
|
|
138
135
|
}
|
|
139
136
|
}
|
|
140
|
-
}
|
|
141
|
-
#hoverBubble
|
|
137
|
+
}
|
|
138
|
+
#hoverBubble(interactivityData) {
|
|
142
139
|
const container = this.container, mousePos = interactivityData.mouse.position, distance = container.retina.bubbleModeDistance;
|
|
143
140
|
if (!distance || distance < minDistance || !mousePos) {
|
|
144
141
|
return;
|
|
@@ -161,8 +158,8 @@ export class Bubbler extends ExternalInteractorBase {
|
|
|
161
158
|
this.reset(interactivityData, particle);
|
|
162
159
|
}
|
|
163
160
|
}
|
|
164
|
-
}
|
|
165
|
-
#hoverBubbleColor
|
|
161
|
+
}
|
|
162
|
+
#hoverBubbleColor(particle, ratio, divBubble) {
|
|
166
163
|
const options = this.container.actualOptions, bubbleOptions = divBubble ?? options.interactivity?.modes.bubble;
|
|
167
164
|
if (!bubbleOptions) {
|
|
168
165
|
return;
|
|
@@ -188,8 +185,8 @@ export class Bubbler extends ExternalInteractorBase {
|
|
|
188
185
|
else {
|
|
189
186
|
particle.bubble.color = particle.bubble.finalColor;
|
|
190
187
|
}
|
|
191
|
-
}
|
|
192
|
-
#hoverBubbleOpacity
|
|
188
|
+
}
|
|
189
|
+
#hoverBubbleOpacity(particle, ratio, divBubble) {
|
|
193
190
|
const container = this.container, options = container.actualOptions, modeOpacity = divBubble?.opacity ?? options.interactivity?.modes.bubble?.opacity;
|
|
194
191
|
if (!modeOpacity) {
|
|
195
192
|
return;
|
|
@@ -198,8 +195,8 @@ export class Bubbler extends ExternalInteractorBase {
|
|
|
198
195
|
if (opacity !== undefined) {
|
|
199
196
|
particle.bubble.opacity = opacity;
|
|
200
197
|
}
|
|
201
|
-
}
|
|
202
|
-
#hoverBubbleSize
|
|
198
|
+
}
|
|
199
|
+
#hoverBubbleSize(particle, ratio, divBubble) {
|
|
203
200
|
const container = this.container, modeSize = divBubble?.size ? divBubble.size * container.retina.pixelRatio : container.retina.bubbleModeSize;
|
|
204
201
|
if (modeSize === undefined) {
|
|
205
202
|
return;
|
|
@@ -208,8 +205,8 @@ export class Bubbler extends ExternalInteractorBase {
|
|
|
208
205
|
if (size !== undefined) {
|
|
209
206
|
particle.bubble.radius = size;
|
|
210
207
|
}
|
|
211
|
-
}
|
|
212
|
-
#process
|
|
208
|
+
}
|
|
209
|
+
#process(particle, distMouse, timeSpent, data) {
|
|
213
210
|
const container = this.container, bubbleParam = data.bubbleObj.optValue, options = container.actualOptions, bubbleOptions = options.interactivity?.modes.bubble;
|
|
214
211
|
if (!bubbleOptions || bubbleParam === undefined) {
|
|
215
212
|
return;
|
|
@@ -251,8 +248,8 @@ export class Bubbler extends ExternalInteractorBase {
|
|
|
251
248
|
}
|
|
252
249
|
}
|
|
253
250
|
}
|
|
254
|
-
}
|
|
255
|
-
#singleSelectorHover
|
|
251
|
+
}
|
|
252
|
+
#singleSelectorHover(interactivityData, delta, selector, div) {
|
|
256
253
|
const container = this.container, selectors = safeDocument().querySelectorAll(selector), bubble = container.actualOptions.interactivity?.modes.bubble;
|
|
257
254
|
if (!bubble || !selectors.length) {
|
|
258
255
|
return;
|
|
@@ -279,5 +276,5 @@ export class Bubbler extends ExternalInteractorBase {
|
|
|
279
276
|
this.#hoverBubbleColor(particle, defaultRatio, divBubble);
|
|
280
277
|
}
|
|
281
278
|
});
|
|
282
|
-
}
|
|
279
|
+
}
|
|
283
280
|
}
|
|
@@ -1,40 +1,25 @@
|
|
|
1
|
-
import { OptionsColor, executeOnSingleOrMultiple, isArray, isNull, } from "@tsparticles/engine";
|
|
1
|
+
import { OptionsColor, executeOnSingleOrMultiple, isArray, isNull, loadProperty, loadRangeProperty, } from "@tsparticles/engine";
|
|
2
2
|
export class BubbleBase {
|
|
3
3
|
color;
|
|
4
|
-
distance;
|
|
5
|
-
duration;
|
|
6
|
-
mix;
|
|
4
|
+
distance = 200;
|
|
5
|
+
duration = 0.4;
|
|
6
|
+
mix = false;
|
|
7
7
|
opacity;
|
|
8
8
|
size;
|
|
9
|
-
constructor() {
|
|
10
|
-
this.distance = 200;
|
|
11
|
-
this.duration = 0.4;
|
|
12
|
-
this.mix = false;
|
|
13
|
-
}
|
|
14
9
|
load(data) {
|
|
15
10
|
if (isNull(data)) {
|
|
16
11
|
return;
|
|
17
12
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
this.duration = data.duration;
|
|
23
|
-
}
|
|
24
|
-
if (data.mix !== undefined) {
|
|
25
|
-
this.mix = data.mix;
|
|
26
|
-
}
|
|
27
|
-
if (data.opacity !== undefined) {
|
|
28
|
-
this.opacity = data.opacity;
|
|
29
|
-
}
|
|
13
|
+
loadProperty(this, "distance", data.distance);
|
|
14
|
+
loadProperty(this, "duration", data.duration);
|
|
15
|
+
loadProperty(this, "mix", data.mix);
|
|
16
|
+
loadRangeProperty(this, "opacity", data.opacity);
|
|
30
17
|
if (data.color !== undefined) {
|
|
31
18
|
const sourceColor = isArray(this.color) ? undefined : this.color;
|
|
32
19
|
this.color = executeOnSingleOrMultiple(data.color, color => {
|
|
33
20
|
return OptionsColor.create(sourceColor, color);
|
|
34
21
|
});
|
|
35
22
|
}
|
|
36
|
-
|
|
37
|
-
this.size = data.size;
|
|
38
|
-
}
|
|
23
|
+
loadProperty(this, "size", data.size);
|
|
39
24
|
}
|
|
40
25
|
}
|
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
import { isNull } from "@tsparticles/engine";
|
|
1
|
+
import { isNull, loadProperty, } from "@tsparticles/engine";
|
|
2
2
|
import { BubbleBase } from "./BubbleBase.js";
|
|
3
3
|
export class BubbleDiv extends BubbleBase {
|
|
4
|
-
selectors;
|
|
5
|
-
constructor() {
|
|
6
|
-
super();
|
|
7
|
-
this.selectors = [];
|
|
8
|
-
}
|
|
4
|
+
selectors = [];
|
|
9
5
|
load(data) {
|
|
10
6
|
super.load(data);
|
|
11
7
|
if (isNull(data)) {
|
|
12
8
|
return;
|
|
13
9
|
}
|
|
14
|
-
|
|
15
|
-
this.selectors = data.selectors;
|
|
16
|
-
}
|
|
10
|
+
loadProperty(this, "selectors", data.selectors);
|
|
17
11
|
}
|
|
18
12
|
}
|
package/cjs/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ensureInteractivityPluginLoaded } from "@tsparticles/plugin-interactivity";
|
|
2
2
|
import { Bubbler } from "./Bubbler.js";
|
|
3
3
|
export async function loadExternalBubbleInteraction(engine) {
|
|
4
|
-
engine.checkVersion("4.
|
|
4
|
+
engine.checkVersion("4.2.0");
|
|
5
5
|
await engine.pluginManager.register((e) => {
|
|
6
6
|
ensureInteractivityPluginLoaded(e);
|
|
7
7
|
e.pluginManager.addInteractor?.("externalBubble", container => {
|
package/cjs/index.lazy.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export async function loadExternalBubbleInteraction(engine) {
|
|
2
|
-
engine.checkVersion("4.
|
|
2
|
+
engine.checkVersion("4.2.0");
|
|
3
3
|
await engine.pluginManager.register(async (e) => {
|
|
4
4
|
const { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity/lazy");
|
|
5
5
|
ensureInteractivityPluginLoaded(e);
|
package/esm/Bubbler.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Circle, Rectangle, colorMix, double, getDistance, half, isInArray, itemFromSingleOrMultiple, millisecondsToSeconds, rangeColorToHsl, rgbToHsl, safeDocument, } from "@tsparticles/engine";
|
|
1
|
+
import { Circle, Rectangle, colorMix, double, getDistance, half, isInArray, itemFromSingleOrMultiple, loadOptionProperty, millisecondsToSeconds, rangeColorToHsl, rgbToHsl, safeDocument, } from "@tsparticles/engine";
|
|
2
2
|
import { DivType, ExternalInteractorBase, divMode, divModeExecute, isDivModeEnabled, mouseLeaveEvent, mouseMoveEvent, } from "@tsparticles/plugin-interactivity";
|
|
3
3
|
import { Bubble } from "./Options/Classes/Bubble.js";
|
|
4
4
|
import { ProcessBubbleType } from "./Enums.js";
|
|
@@ -74,15 +74,12 @@ export class Bubbler extends ExternalInteractorBase {
|
|
|
74
74
|
return isInArray(bubbleMode, onHover.mode) || isInArray(bubbleMode, onClick.mode) || divBubble;
|
|
75
75
|
}
|
|
76
76
|
loadModeOptions(options, ...sources) {
|
|
77
|
-
options
|
|
78
|
-
for (const source of sources) {
|
|
79
|
-
options.bubble.load(source?.bubble);
|
|
80
|
-
}
|
|
77
|
+
loadOptionProperty(options, "bubble", Bubble, ...sources);
|
|
81
78
|
}
|
|
82
79
|
reset(_interactivityData, particle) {
|
|
83
80
|
particle.bubble.inRange = false;
|
|
84
81
|
}
|
|
85
|
-
#clickBubble
|
|
82
|
+
#clickBubble(interactivityData) {
|
|
86
83
|
const container = this.container, options = container.actualOptions, mouseClickPos = interactivityData.mouse.clickPosition, bubbleOptions = options.interactivity?.modes.bubble;
|
|
87
84
|
if (!bubbleOptions || !mouseClickPos) {
|
|
88
85
|
return;
|
|
@@ -137,8 +134,8 @@ export class Bubbler extends ExternalInteractorBase {
|
|
|
137
134
|
delete particle.bubble.color;
|
|
138
135
|
}
|
|
139
136
|
}
|
|
140
|
-
}
|
|
141
|
-
#hoverBubble
|
|
137
|
+
}
|
|
138
|
+
#hoverBubble(interactivityData) {
|
|
142
139
|
const container = this.container, mousePos = interactivityData.mouse.position, distance = container.retina.bubbleModeDistance;
|
|
143
140
|
if (!distance || distance < minDistance || !mousePos) {
|
|
144
141
|
return;
|
|
@@ -161,8 +158,8 @@ export class Bubbler extends ExternalInteractorBase {
|
|
|
161
158
|
this.reset(interactivityData, particle);
|
|
162
159
|
}
|
|
163
160
|
}
|
|
164
|
-
}
|
|
165
|
-
#hoverBubbleColor
|
|
161
|
+
}
|
|
162
|
+
#hoverBubbleColor(particle, ratio, divBubble) {
|
|
166
163
|
const options = this.container.actualOptions, bubbleOptions = divBubble ?? options.interactivity?.modes.bubble;
|
|
167
164
|
if (!bubbleOptions) {
|
|
168
165
|
return;
|
|
@@ -188,8 +185,8 @@ export class Bubbler extends ExternalInteractorBase {
|
|
|
188
185
|
else {
|
|
189
186
|
particle.bubble.color = particle.bubble.finalColor;
|
|
190
187
|
}
|
|
191
|
-
}
|
|
192
|
-
#hoverBubbleOpacity
|
|
188
|
+
}
|
|
189
|
+
#hoverBubbleOpacity(particle, ratio, divBubble) {
|
|
193
190
|
const container = this.container, options = container.actualOptions, modeOpacity = divBubble?.opacity ?? options.interactivity?.modes.bubble?.opacity;
|
|
194
191
|
if (!modeOpacity) {
|
|
195
192
|
return;
|
|
@@ -198,8 +195,8 @@ export class Bubbler extends ExternalInteractorBase {
|
|
|
198
195
|
if (opacity !== undefined) {
|
|
199
196
|
particle.bubble.opacity = opacity;
|
|
200
197
|
}
|
|
201
|
-
}
|
|
202
|
-
#hoverBubbleSize
|
|
198
|
+
}
|
|
199
|
+
#hoverBubbleSize(particle, ratio, divBubble) {
|
|
203
200
|
const container = this.container, modeSize = divBubble?.size ? divBubble.size * container.retina.pixelRatio : container.retina.bubbleModeSize;
|
|
204
201
|
if (modeSize === undefined) {
|
|
205
202
|
return;
|
|
@@ -208,8 +205,8 @@ export class Bubbler extends ExternalInteractorBase {
|
|
|
208
205
|
if (size !== undefined) {
|
|
209
206
|
particle.bubble.radius = size;
|
|
210
207
|
}
|
|
211
|
-
}
|
|
212
|
-
#process
|
|
208
|
+
}
|
|
209
|
+
#process(particle, distMouse, timeSpent, data) {
|
|
213
210
|
const container = this.container, bubbleParam = data.bubbleObj.optValue, options = container.actualOptions, bubbleOptions = options.interactivity?.modes.bubble;
|
|
214
211
|
if (!bubbleOptions || bubbleParam === undefined) {
|
|
215
212
|
return;
|
|
@@ -251,8 +248,8 @@ export class Bubbler extends ExternalInteractorBase {
|
|
|
251
248
|
}
|
|
252
249
|
}
|
|
253
250
|
}
|
|
254
|
-
}
|
|
255
|
-
#singleSelectorHover
|
|
251
|
+
}
|
|
252
|
+
#singleSelectorHover(interactivityData, delta, selector, div) {
|
|
256
253
|
const container = this.container, selectors = safeDocument().querySelectorAll(selector), bubble = container.actualOptions.interactivity?.modes.bubble;
|
|
257
254
|
if (!bubble || !selectors.length) {
|
|
258
255
|
return;
|
|
@@ -279,5 +276,5 @@ export class Bubbler extends ExternalInteractorBase {
|
|
|
279
276
|
this.#hoverBubbleColor(particle, defaultRatio, divBubble);
|
|
280
277
|
}
|
|
281
278
|
});
|
|
282
|
-
}
|
|
279
|
+
}
|
|
283
280
|
}
|
|
@@ -1,40 +1,25 @@
|
|
|
1
|
-
import { OptionsColor, executeOnSingleOrMultiple, isArray, isNull, } from "@tsparticles/engine";
|
|
1
|
+
import { OptionsColor, executeOnSingleOrMultiple, isArray, isNull, loadProperty, loadRangeProperty, } from "@tsparticles/engine";
|
|
2
2
|
export class BubbleBase {
|
|
3
3
|
color;
|
|
4
|
-
distance;
|
|
5
|
-
duration;
|
|
6
|
-
mix;
|
|
4
|
+
distance = 200;
|
|
5
|
+
duration = 0.4;
|
|
6
|
+
mix = false;
|
|
7
7
|
opacity;
|
|
8
8
|
size;
|
|
9
|
-
constructor() {
|
|
10
|
-
this.distance = 200;
|
|
11
|
-
this.duration = 0.4;
|
|
12
|
-
this.mix = false;
|
|
13
|
-
}
|
|
14
9
|
load(data) {
|
|
15
10
|
if (isNull(data)) {
|
|
16
11
|
return;
|
|
17
12
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
this.duration = data.duration;
|
|
23
|
-
}
|
|
24
|
-
if (data.mix !== undefined) {
|
|
25
|
-
this.mix = data.mix;
|
|
26
|
-
}
|
|
27
|
-
if (data.opacity !== undefined) {
|
|
28
|
-
this.opacity = data.opacity;
|
|
29
|
-
}
|
|
13
|
+
loadProperty(this, "distance", data.distance);
|
|
14
|
+
loadProperty(this, "duration", data.duration);
|
|
15
|
+
loadProperty(this, "mix", data.mix);
|
|
16
|
+
loadRangeProperty(this, "opacity", data.opacity);
|
|
30
17
|
if (data.color !== undefined) {
|
|
31
18
|
const sourceColor = isArray(this.color) ? undefined : this.color;
|
|
32
19
|
this.color = executeOnSingleOrMultiple(data.color, color => {
|
|
33
20
|
return OptionsColor.create(sourceColor, color);
|
|
34
21
|
});
|
|
35
22
|
}
|
|
36
|
-
|
|
37
|
-
this.size = data.size;
|
|
38
|
-
}
|
|
23
|
+
loadProperty(this, "size", data.size);
|
|
39
24
|
}
|
|
40
25
|
}
|
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
import { isNull } from "@tsparticles/engine";
|
|
1
|
+
import { isNull, loadProperty, } from "@tsparticles/engine";
|
|
2
2
|
import { BubbleBase } from "./BubbleBase.js";
|
|
3
3
|
export class BubbleDiv extends BubbleBase {
|
|
4
|
-
selectors;
|
|
5
|
-
constructor() {
|
|
6
|
-
super();
|
|
7
|
-
this.selectors = [];
|
|
8
|
-
}
|
|
4
|
+
selectors = [];
|
|
9
5
|
load(data) {
|
|
10
6
|
super.load(data);
|
|
11
7
|
if (isNull(data)) {
|
|
12
8
|
return;
|
|
13
9
|
}
|
|
14
|
-
|
|
15
|
-
this.selectors = data.selectors;
|
|
16
|
-
}
|
|
10
|
+
loadProperty(this, "selectors", data.selectors);
|
|
17
11
|
}
|
|
18
12
|
}
|
package/esm/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ensureInteractivityPluginLoaded } from "@tsparticles/plugin-interactivity";
|
|
2
2
|
import { Bubbler } from "./Bubbler.js";
|
|
3
3
|
export async function loadExternalBubbleInteraction(engine) {
|
|
4
|
-
engine.checkVersion("4.
|
|
4
|
+
engine.checkVersion("4.2.0");
|
|
5
5
|
await engine.pluginManager.register((e) => {
|
|
6
6
|
ensureInteractivityPluginLoaded(e);
|
|
7
7
|
e.pluginManager.addInteractor?.("externalBubble", container => {
|
package/esm/index.lazy.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export async function loadExternalBubbleInteraction(engine) {
|
|
2
|
-
engine.checkVersion("4.
|
|
2
|
+
engine.checkVersion("4.2.0");
|
|
3
3
|
await engine.pluginManager.register(async (e) => {
|
|
4
4
|
const { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity/lazy");
|
|
5
5
|
ensureInteractivityPluginLoaded(e);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/interaction-external-bubble",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "tsParticles bubble external interaction",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
},
|
|
98
98
|
"type": "module",
|
|
99
99
|
"peerDependencies": {
|
|
100
|
-
"@tsparticles/engine": "4.
|
|
101
|
-
"@tsparticles/plugin-interactivity": "4.
|
|
100
|
+
"@tsparticles/engine": "4.2.0",
|
|
101
|
+
"@tsparticles/plugin-interactivity": "4.2.0"
|
|
102
102
|
}
|
|
103
103
|
}
|
package/report.html
CHANGED
|
@@ -4930,7 +4930,7 @@ var drawChart = (function (exports) {
|
|
|
4930
4930
|
</script>
|
|
4931
4931
|
<script>
|
|
4932
4932
|
/*<!--*/
|
|
4933
|
-
const data = {"version":2,"tree":{"name":"root","children":[{"name":"tsparticles.interaction.external.bubble.js","children":[{"name":"dist/browser","children":[{"name":"Options/Classes","children":[{"uid":"
|
|
4933
|
+
const data = {"version":2,"tree":{"name":"root","children":[{"name":"tsparticles.interaction.external.bubble.js","children":[{"name":"dist/browser","children":[{"name":"Options/Classes","children":[{"uid":"cf70f7e3-1","name":"BubbleBase.js"},{"uid":"cf70f7e3-3","name":"BubbleDiv.js"},{"uid":"cf70f7e3-5","name":"Bubble.js"}]},{"uid":"cf70f7e3-7","name":"Enums.js"},{"uid":"cf70f7e3-9","name":"Utils.js"},{"uid":"cf70f7e3-11","name":"Bubbler.js"},{"uid":"cf70f7e3-13","name":"index.js"},{"uid":"cf70f7e3-15","name":"browser.js"}]}]}],"isRoot":true},"nodeParts":{"cf70f7e3-1":{"renderedLength":893,"gzipLength":0,"brotliLength":0,"metaUid":"cf70f7e3-0"},"cf70f7e3-3":{"renderedLength":276,"gzipLength":0,"brotliLength":0,"metaUid":"cf70f7e3-2"},"cf70f7e3-5":{"renderedLength":392,"gzipLength":0,"brotliLength":0,"metaUid":"cf70f7e3-4"},"cf70f7e3-7":{"renderedLength":257,"gzipLength":0,"brotliLength":0,"metaUid":"cf70f7e3-6"},"cf70f7e3-9":{"renderedLength":508,"gzipLength":0,"brotliLength":0,"metaUid":"cf70f7e3-8"},"cf70f7e3-11":{"renderedLength":13938,"gzipLength":0,"brotliLength":0,"metaUid":"cf70f7e3-10"},"cf70f7e3-13":{"renderedLength":409,"gzipLength":0,"brotliLength":0,"metaUid":"cf70f7e3-12"},"cf70f7e3-15":{"renderedLength":201,"gzipLength":0,"brotliLength":0,"metaUid":"cf70f7e3-14"}},"nodeMetas":{"cf70f7e3-0":{"id":"/dist/browser/Options/Classes/BubbleBase.js","moduleParts":{"tsparticles.interaction.external.bubble.js":"cf70f7e3-1"},"imported":[{"uid":"cf70f7e3-17"}],"importedBy":[{"uid":"cf70f7e3-12"},{"uid":"cf70f7e3-2"},{"uid":"cf70f7e3-4"}]},"cf70f7e3-2":{"id":"/dist/browser/Options/Classes/BubbleDiv.js","moduleParts":{"tsparticles.interaction.external.bubble.js":"cf70f7e3-3"},"imported":[{"uid":"cf70f7e3-17"},{"uid":"cf70f7e3-0"}],"importedBy":[{"uid":"cf70f7e3-12"},{"uid":"cf70f7e3-4"}]},"cf70f7e3-4":{"id":"/dist/browser/Options/Classes/Bubble.js","moduleParts":{"tsparticles.interaction.external.bubble.js":"cf70f7e3-5"},"imported":[{"uid":"cf70f7e3-17"},{"uid":"cf70f7e3-0"},{"uid":"cf70f7e3-2"}],"importedBy":[{"uid":"cf70f7e3-12"},{"uid":"cf70f7e3-10"}]},"cf70f7e3-6":{"id":"/dist/browser/Enums.js","moduleParts":{"tsparticles.interaction.external.bubble.js":"cf70f7e3-7"},"imported":[],"importedBy":[{"uid":"cf70f7e3-10"}]},"cf70f7e3-8":{"id":"/dist/browser/Utils.js","moduleParts":{"tsparticles.interaction.external.bubble.js":"cf70f7e3-9"},"imported":[{"uid":"cf70f7e3-17"}],"importedBy":[{"uid":"cf70f7e3-10"}]},"cf70f7e3-10":{"id":"/dist/browser/Bubbler.js","moduleParts":{"tsparticles.interaction.external.bubble.js":"cf70f7e3-11"},"imported":[{"uid":"cf70f7e3-17"},{"uid":"cf70f7e3-16"},{"uid":"cf70f7e3-4"},{"uid":"cf70f7e3-6"},{"uid":"cf70f7e3-8"}],"importedBy":[{"uid":"cf70f7e3-12"}]},"cf70f7e3-12":{"id":"/dist/browser/index.js","moduleParts":{"tsparticles.interaction.external.bubble.js":"cf70f7e3-13"},"imported":[{"uid":"cf70f7e3-16"},{"uid":"cf70f7e3-10"},{"uid":"cf70f7e3-0"},{"uid":"cf70f7e3-2"},{"uid":"cf70f7e3-4"}],"importedBy":[{"uid":"cf70f7e3-14"}]},"cf70f7e3-14":{"id":"/dist/browser/browser.js","moduleParts":{"tsparticles.interaction.external.bubble.js":"cf70f7e3-15"},"imported":[{"uid":"cf70f7e3-12"}],"importedBy":[],"isEntry":true},"cf70f7e3-16":{"id":"@tsparticles/plugin-interactivity","moduleParts":{},"imported":[],"importedBy":[{"uid":"cf70f7e3-12"},{"uid":"cf70f7e3-10"}],"isExternal":true},"cf70f7e3-17":{"id":"@tsparticles/engine","moduleParts":{},"imported":[],"importedBy":[{"uid":"cf70f7e3-10"},{"uid":"cf70f7e3-0"},{"uid":"cf70f7e3-2"},{"uid":"cf70f7e3-4"},{"uid":"cf70f7e3-8"}],"isExternal":true}},"env":{"rollup":"4.62.0"},"options":{"gzip":false,"brotli":false,"sourcemap":false}};
|
|
4934
4934
|
|
|
4935
4935
|
const run = () => {
|
|
4936
4936
|
const width = window.innerWidth;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function(g){g.__tsParticlesInternals=g.__tsParticlesInternals||{};g.__tsParticlesInternals.bundles=g.__tsParticlesInternals.bundles||{};g.__tsParticlesInternals.effects=g.__tsParticlesInternals.effects||{};g.__tsParticlesInternals.engine=g.__tsParticlesInternals.engine||{};g.__tsParticlesInternals.interactions=g.__tsParticlesInternals.interactions||{};g.__tsParticlesInternals.palettes=g.__tsParticlesInternals.palettes||{};g.__tsParticlesInternals.paths=g.__tsParticlesInternals.paths||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins.emittersShapes=g.__tsParticlesInternals.plugins.emittersShapes||{};g.__tsParticlesInternals.presets=g.__tsParticlesInternals.presets||{};g.__tsParticlesInternals.shapes=g.__tsParticlesInternals.shapes||{};g.__tsParticlesInternals.updaters=g.__tsParticlesInternals.updaters||{};g.__tsParticlesInternals.utils=g.__tsParticlesInternals.utils||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas.utils=g.__tsParticlesInternals.canvas.utils||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path.utils=g.__tsParticlesInternals.path.utils||{};var __tsProxyFactory=typeof Proxy!=="undefined"?function(obj){return new Proxy(obj,{get:function(target,key){if(!(key in target)){target[key]={};}return target[key];}});}:function(obj){return obj;};g.__tsParticlesInternals.bundles=__tsProxyFactory(g.__tsParticlesInternals.bundles);g.__tsParticlesInternals.effects=__tsProxyFactory(g.__tsParticlesInternals.effects);g.__tsParticlesInternals.interactions=__tsProxyFactory(g.__tsParticlesInternals.interactions);g.__tsParticlesInternals.palettes=__tsProxyFactory(g.__tsParticlesInternals.palettes);g.__tsParticlesInternals.paths=__tsProxyFactory(g.__tsParticlesInternals.paths);g.__tsParticlesInternals.plugins=__tsProxyFactory(g.__tsParticlesInternals.plugins);g.__tsParticlesInternals.plugins.emittersShapes=__tsProxyFactory(g.__tsParticlesInternals.plugins.emittersShapes);g.__tsParticlesInternals.presets=__tsProxyFactory(g.__tsParticlesInternals.presets);g.__tsParticlesInternals.shapes=__tsProxyFactory(g.__tsParticlesInternals.shapes);g.__tsParticlesInternals.updaters=__tsProxyFactory(g.__tsParticlesInternals.updaters);g.__tsParticlesInternals.utils=__tsProxyFactory(g.__tsParticlesInternals.utils);g.__tsParticlesInternals.canvas=__tsProxyFactory(g.__tsParticlesInternals.canvas);g.__tsParticlesInternals.path=__tsProxyFactory(g.__tsParticlesInternals.path);g.tsparticlesInternalExports=g.tsparticlesInternalExports||{};})(typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:this);
|
|
2
|
-
/* External Interaction v4.
|
|
2
|
+
/* External Interaction v4.2.0 */
|
|
3
3
|
(function (global, factory) {
|
|
4
4
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tsparticles/plugin-interactivity'), require('@tsparticles/engine')) :
|
|
5
5
|
typeof define === 'function' && define.amd ? define(['exports', '@tsparticles/plugin-interactivity', '@tsparticles/engine'], factory) :
|
|
@@ -8,58 +8,37 @@
|
|
|
8
8
|
|
|
9
9
|
class BubbleBase {
|
|
10
10
|
color;
|
|
11
|
-
distance;
|
|
12
|
-
duration;
|
|
13
|
-
mix;
|
|
11
|
+
distance = 200;
|
|
12
|
+
duration = 0.4;
|
|
13
|
+
mix = false;
|
|
14
14
|
opacity;
|
|
15
15
|
size;
|
|
16
|
-
constructor() {
|
|
17
|
-
this.distance = 200;
|
|
18
|
-
this.duration = 0.4;
|
|
19
|
-
this.mix = false;
|
|
20
|
-
}
|
|
21
16
|
load(data) {
|
|
22
17
|
if (engine.isNull(data)) {
|
|
23
18
|
return;
|
|
24
19
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
this.duration = data.duration;
|
|
30
|
-
}
|
|
31
|
-
if (data.mix !== undefined) {
|
|
32
|
-
this.mix = data.mix;
|
|
33
|
-
}
|
|
34
|
-
if (data.opacity !== undefined) {
|
|
35
|
-
this.opacity = data.opacity;
|
|
36
|
-
}
|
|
20
|
+
engine.loadProperty(this, "distance", data.distance);
|
|
21
|
+
engine.loadProperty(this, "duration", data.duration);
|
|
22
|
+
engine.loadProperty(this, "mix", data.mix);
|
|
23
|
+
engine.loadRangeProperty(this, "opacity", data.opacity);
|
|
37
24
|
if (data.color !== undefined) {
|
|
38
25
|
const sourceColor = engine.isArray(this.color) ? undefined : this.color;
|
|
39
26
|
this.color = engine.executeOnSingleOrMultiple(data.color, color => {
|
|
40
27
|
return engine.OptionsColor.create(sourceColor, color);
|
|
41
28
|
});
|
|
42
29
|
}
|
|
43
|
-
|
|
44
|
-
this.size = data.size;
|
|
45
|
-
}
|
|
30
|
+
engine.loadProperty(this, "size", data.size);
|
|
46
31
|
}
|
|
47
32
|
}
|
|
48
33
|
|
|
49
34
|
class BubbleDiv extends BubbleBase {
|
|
50
|
-
selectors;
|
|
51
|
-
constructor() {
|
|
52
|
-
super();
|
|
53
|
-
this.selectors = [];
|
|
54
|
-
}
|
|
35
|
+
selectors = [];
|
|
55
36
|
load(data) {
|
|
56
37
|
super.load(data);
|
|
57
38
|
if (engine.isNull(data)) {
|
|
58
39
|
return;
|
|
59
40
|
}
|
|
60
|
-
|
|
61
|
-
this.selectors = data.selectors;
|
|
62
|
-
}
|
|
41
|
+
engine.loadProperty(this, "selectors", data.selectors);
|
|
63
42
|
}
|
|
64
43
|
}
|
|
65
44
|
|
|
@@ -168,15 +147,12 @@
|
|
|
168
147
|
return engine.isInArray(bubbleMode, onHover.mode) || engine.isInArray(bubbleMode, onClick.mode) || divBubble;
|
|
169
148
|
}
|
|
170
149
|
loadModeOptions(options, ...sources) {
|
|
171
|
-
options
|
|
172
|
-
for (const source of sources) {
|
|
173
|
-
options.bubble.load(source?.bubble);
|
|
174
|
-
}
|
|
150
|
+
engine.loadOptionProperty(options, "bubble", Bubble, ...sources);
|
|
175
151
|
}
|
|
176
152
|
reset(_interactivityData, particle) {
|
|
177
153
|
particle.bubble.inRange = false;
|
|
178
154
|
}
|
|
179
|
-
#clickBubble
|
|
155
|
+
#clickBubble(interactivityData) {
|
|
180
156
|
const container = this.container, options = container.actualOptions, mouseClickPos = interactivityData.mouse.clickPosition, bubbleOptions = options.interactivity?.modes.bubble;
|
|
181
157
|
if (!bubbleOptions || !mouseClickPos) {
|
|
182
158
|
return;
|
|
@@ -231,8 +207,8 @@
|
|
|
231
207
|
delete particle.bubble.color;
|
|
232
208
|
}
|
|
233
209
|
}
|
|
234
|
-
}
|
|
235
|
-
#hoverBubble
|
|
210
|
+
}
|
|
211
|
+
#hoverBubble(interactivityData) {
|
|
236
212
|
const container = this.container, mousePos = interactivityData.mouse.position, distance = container.retina.bubbleModeDistance;
|
|
237
213
|
if (!distance || distance < minDistance || !mousePos) {
|
|
238
214
|
return;
|
|
@@ -255,8 +231,8 @@
|
|
|
255
231
|
this.reset(interactivityData, particle);
|
|
256
232
|
}
|
|
257
233
|
}
|
|
258
|
-
}
|
|
259
|
-
#hoverBubbleColor
|
|
234
|
+
}
|
|
235
|
+
#hoverBubbleColor(particle, ratio, divBubble) {
|
|
260
236
|
const options = this.container.actualOptions, bubbleOptions = divBubble ?? options.interactivity?.modes.bubble;
|
|
261
237
|
if (!bubbleOptions) {
|
|
262
238
|
return;
|
|
@@ -282,8 +258,8 @@
|
|
|
282
258
|
else {
|
|
283
259
|
particle.bubble.color = particle.bubble.finalColor;
|
|
284
260
|
}
|
|
285
|
-
}
|
|
286
|
-
#hoverBubbleOpacity
|
|
261
|
+
}
|
|
262
|
+
#hoverBubbleOpacity(particle, ratio, divBubble) {
|
|
287
263
|
const container = this.container, options = container.actualOptions, modeOpacity = divBubble?.opacity ?? options.interactivity?.modes.bubble?.opacity;
|
|
288
264
|
if (!modeOpacity) {
|
|
289
265
|
return;
|
|
@@ -292,8 +268,8 @@
|
|
|
292
268
|
if (opacity !== undefined) {
|
|
293
269
|
particle.bubble.opacity = opacity;
|
|
294
270
|
}
|
|
295
|
-
}
|
|
296
|
-
#hoverBubbleSize
|
|
271
|
+
}
|
|
272
|
+
#hoverBubbleSize(particle, ratio, divBubble) {
|
|
297
273
|
const container = this.container, modeSize = divBubble?.size ? divBubble.size * container.retina.pixelRatio : container.retina.bubbleModeSize;
|
|
298
274
|
if (modeSize === undefined) {
|
|
299
275
|
return;
|
|
@@ -302,8 +278,8 @@
|
|
|
302
278
|
if (size !== undefined) {
|
|
303
279
|
particle.bubble.radius = size;
|
|
304
280
|
}
|
|
305
|
-
}
|
|
306
|
-
#process
|
|
281
|
+
}
|
|
282
|
+
#process(particle, distMouse, timeSpent, data) {
|
|
307
283
|
const container = this.container, bubbleParam = data.bubbleObj.optValue, options = container.actualOptions, bubbleOptions = options.interactivity?.modes.bubble;
|
|
308
284
|
if (!bubbleOptions || bubbleParam === undefined) {
|
|
309
285
|
return;
|
|
@@ -345,8 +321,8 @@
|
|
|
345
321
|
}
|
|
346
322
|
}
|
|
347
323
|
}
|
|
348
|
-
}
|
|
349
|
-
#singleSelectorHover
|
|
324
|
+
}
|
|
325
|
+
#singleSelectorHover(interactivityData, delta, selector, div) {
|
|
350
326
|
const container = this.container, selectors = engine.safeDocument().querySelectorAll(selector), bubble = container.actualOptions.interactivity?.modes.bubble;
|
|
351
327
|
if (!bubble || !selectors.length) {
|
|
352
328
|
return;
|
|
@@ -373,11 +349,11 @@
|
|
|
373
349
|
this.#hoverBubbleColor(particle, defaultRatio, divBubble);
|
|
374
350
|
}
|
|
375
351
|
});
|
|
376
|
-
}
|
|
352
|
+
}
|
|
377
353
|
}
|
|
378
354
|
|
|
379
355
|
async function loadExternalBubbleInteraction(engine) {
|
|
380
|
-
engine.checkVersion("4.
|
|
356
|
+
engine.checkVersion("4.2.0");
|
|
381
357
|
await engine.pluginManager.register((e) => {
|
|
382
358
|
pluginInteractivity.ensureInteractivityPluginLoaded(e);
|
|
383
359
|
e.pluginManager.addInteractor?.("externalBubble", container => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e){e.__tsParticlesInternals=e.__tsParticlesInternals||{},e.__tsParticlesInternals.bundles=e.__tsParticlesInternals.bundles||{},e.__tsParticlesInternals.effects=e.__tsParticlesInternals.effects||{},e.__tsParticlesInternals.engine=e.__tsParticlesInternals.engine||{},e.__tsParticlesInternals.interactions=e.__tsParticlesInternals.interactions||{},e.__tsParticlesInternals.palettes=e.__tsParticlesInternals.palettes||{},e.__tsParticlesInternals.paths=e.__tsParticlesInternals.paths||{},e.__tsParticlesInternals.plugins=e.__tsParticlesInternals.plugins||{},e.__tsParticlesInternals.plugins=e.__tsParticlesInternals.plugins||{},e.__tsParticlesInternals.plugins.emittersShapes=e.__tsParticlesInternals.plugins.emittersShapes||{},e.__tsParticlesInternals.presets=e.__tsParticlesInternals.presets||{},e.__tsParticlesInternals.shapes=e.__tsParticlesInternals.shapes||{},e.__tsParticlesInternals.updaters=e.__tsParticlesInternals.updaters||{},e.__tsParticlesInternals.utils=e.__tsParticlesInternals.utils||{},e.__tsParticlesInternals.canvas=e.__tsParticlesInternals.canvas||{},e.__tsParticlesInternals.canvas=e.__tsParticlesInternals.canvas||{},e.__tsParticlesInternals.canvas.utils=e.__tsParticlesInternals.canvas.utils||{},e.__tsParticlesInternals.path=e.__tsParticlesInternals.path||{},e.__tsParticlesInternals.path=e.__tsParticlesInternals.path||{},e.__tsParticlesInternals.path.utils=e.__tsParticlesInternals.path.utils||{};var t="undefined"!=typeof Proxy?function(e){return new Proxy(e,{get:function(e,t){return t in e||(e[t]={}),e[t]}})}:function(e){return e};e.__tsParticlesInternals.bundles=t(e.__tsParticlesInternals.bundles),e.__tsParticlesInternals.effects=t(e.__tsParticlesInternals.effects),e.__tsParticlesInternals.interactions=t(e.__tsParticlesInternals.interactions),e.__tsParticlesInternals.palettes=t(e.__tsParticlesInternals.palettes),e.__tsParticlesInternals.paths=t(e.__tsParticlesInternals.paths),e.__tsParticlesInternals.plugins=t(e.__tsParticlesInternals.plugins),e.__tsParticlesInternals.plugins.emittersShapes=t(e.__tsParticlesInternals.plugins.emittersShapes),e.__tsParticlesInternals.presets=t(e.__tsParticlesInternals.presets),e.__tsParticlesInternals.shapes=t(e.__tsParticlesInternals.shapes),e.__tsParticlesInternals.updaters=t(e.__tsParticlesInternals.updaters),e.__tsParticlesInternals.utils=t(e.__tsParticlesInternals.utils),e.__tsParticlesInternals.canvas=t(e.__tsParticlesInternals.canvas),e.__tsParticlesInternals.path=t(e.__tsParticlesInternals.path),e.tsparticlesInternalExports=e.tsparticlesInternalExports||{}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:this),function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@tsparticles/plugin-interactivity"),require("@tsparticles/engine")):"function"==typeof define&&define.amd?define(["exports","@tsparticles/plugin-interactivity","@tsparticles/engine"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).__tsParticlesInternals=e.__tsParticlesInternals||{},e.__tsParticlesInternals.interactions=e.__tsParticlesInternals.interactions||{},e.__tsParticlesInternals.interactions.externalBubble=e.__tsParticlesInternals.interactions.externalBubble||{}),e.__tsParticlesInternals.plugins.interactivity,e.__tsParticlesInternals.engine)}(this,function(e,t,s){"use strict";class i{color;distance;duration;mix;opacity;size;
|
|
1
|
+
!function(e){e.__tsParticlesInternals=e.__tsParticlesInternals||{},e.__tsParticlesInternals.bundles=e.__tsParticlesInternals.bundles||{},e.__tsParticlesInternals.effects=e.__tsParticlesInternals.effects||{},e.__tsParticlesInternals.engine=e.__tsParticlesInternals.engine||{},e.__tsParticlesInternals.interactions=e.__tsParticlesInternals.interactions||{},e.__tsParticlesInternals.palettes=e.__tsParticlesInternals.palettes||{},e.__tsParticlesInternals.paths=e.__tsParticlesInternals.paths||{},e.__tsParticlesInternals.plugins=e.__tsParticlesInternals.plugins||{},e.__tsParticlesInternals.plugins=e.__tsParticlesInternals.plugins||{},e.__tsParticlesInternals.plugins.emittersShapes=e.__tsParticlesInternals.plugins.emittersShapes||{},e.__tsParticlesInternals.presets=e.__tsParticlesInternals.presets||{},e.__tsParticlesInternals.shapes=e.__tsParticlesInternals.shapes||{},e.__tsParticlesInternals.updaters=e.__tsParticlesInternals.updaters||{},e.__tsParticlesInternals.utils=e.__tsParticlesInternals.utils||{},e.__tsParticlesInternals.canvas=e.__tsParticlesInternals.canvas||{},e.__tsParticlesInternals.canvas=e.__tsParticlesInternals.canvas||{},e.__tsParticlesInternals.canvas.utils=e.__tsParticlesInternals.canvas.utils||{},e.__tsParticlesInternals.path=e.__tsParticlesInternals.path||{},e.__tsParticlesInternals.path=e.__tsParticlesInternals.path||{},e.__tsParticlesInternals.path.utils=e.__tsParticlesInternals.path.utils||{};var t="undefined"!=typeof Proxy?function(e){return new Proxy(e,{get:function(e,t){return t in e||(e[t]={}),e[t]}})}:function(e){return e};e.__tsParticlesInternals.bundles=t(e.__tsParticlesInternals.bundles),e.__tsParticlesInternals.effects=t(e.__tsParticlesInternals.effects),e.__tsParticlesInternals.interactions=t(e.__tsParticlesInternals.interactions),e.__tsParticlesInternals.palettes=t(e.__tsParticlesInternals.palettes),e.__tsParticlesInternals.paths=t(e.__tsParticlesInternals.paths),e.__tsParticlesInternals.plugins=t(e.__tsParticlesInternals.plugins),e.__tsParticlesInternals.plugins.emittersShapes=t(e.__tsParticlesInternals.plugins.emittersShapes),e.__tsParticlesInternals.presets=t(e.__tsParticlesInternals.presets),e.__tsParticlesInternals.shapes=t(e.__tsParticlesInternals.shapes),e.__tsParticlesInternals.updaters=t(e.__tsParticlesInternals.updaters),e.__tsParticlesInternals.utils=t(e.__tsParticlesInternals.utils),e.__tsParticlesInternals.canvas=t(e.__tsParticlesInternals.canvas),e.__tsParticlesInternals.path=t(e.__tsParticlesInternals.path),e.tsparticlesInternalExports=e.tsparticlesInternalExports||{}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:this),function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@tsparticles/plugin-interactivity"),require("@tsparticles/engine")):"function"==typeof define&&define.amd?define(["exports","@tsparticles/plugin-interactivity","@tsparticles/engine"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).__tsParticlesInternals=e.__tsParticlesInternals||{},e.__tsParticlesInternals.interactions=e.__tsParticlesInternals.interactions||{},e.__tsParticlesInternals.interactions.externalBubble=e.__tsParticlesInternals.interactions.externalBubble||{}),e.__tsParticlesInternals.plugins.interactivity,e.__tsParticlesInternals.engine)}(this,function(e,t,s){"use strict";class i{color;distance=200;duration=.4;mix=!1;opacity;size;load(e){if(!s.isNull(e)){if(s.loadProperty(this,"distance",e.distance),s.loadProperty(this,"duration",e.duration),s.loadProperty(this,"mix",e.mix),s.loadRangeProperty(this,"opacity",e.opacity),void 0!==e.color){const t=s.isArray(this.color)?void 0:this.color;this.color=s.executeOnSingleOrMultiple(e.color,e=>s.OptionsColor.create(t,e))}s.loadProperty(this,"size",e.size)}}}class n extends i{selectors=[];load(e){super.load(e),s.isNull(e)||s.loadProperty(this,"selectors",e.selectors)}}class l extends i{divs;load(e){super.load(e),s.isNull(e)||(this.divs=s.executeOnSingleOrMultiple(e.divs,e=>{const t=new n;return t.load(e),t}))}}var a;function r(e,t,i,n){if(t>=i){const l=e+(t-i)*n;return s.clamp(l,e,t)}if(t<i){const l=e-(i-t)*n;return s.clamp(l,t,e)}}!function(e){e.color="color",e.opacity="opacity",e.size="size"}(a||(a={}));const o="bubble";class c extends t.ExternalInteractorBase{handleClickMode;#e;#t;constructor(e,t){super(t),this.#t=e,this.#e=0,t.bubble??={},this.handleClickMode=e=>{e===o&&(t.bubble??={},t.bubble.clicking=!0)}}get maxDistance(){return this.#e}clear(e,t,s){e.bubble.inRange&&!s||(delete e.bubble.div,delete e.bubble.opacity,delete e.bubble.radius,delete e.bubble.color)}init(){const e=this.container,t=e.actualOptions.interactivity?.modes.bubble;t&&(this.#e=t.distance,e.retina.bubbleModeDistance=t.distance*e.retina.pixelRatio,void 0!==t.size&&(e.retina.bubbleModeSize=t.size*e.retina.pixelRatio))}interact(e,i){const n=this.container.actualOptions,l=n.interactivity?.events;if(!l)return;const a=l.onHover,r=l.onClick,c=a.enable,b=a.mode,u=r.enable,_=r.mode,p=l.onDiv;c&&s.isInArray(o,b)?this.#s(e):u&&s.isInArray(o,_)?this.#i(e):t.divModeExecute(o,p,(t,s)=>{this.#n(e,i,t,s)})}isEnabled(e,i){const n=this.container.actualOptions,l=e.mouse,a=(i?.interactivity??n.interactivity)?.events;if(!a)return!1;const{onClick:r,onDiv:c,onHover:b}=a,u=t.isDivModeEnabled(o,c);return!!(u||b.enable&&l.position||r.enable&&l.clickPosition)&&(s.isInArray(o,b.mode)||s.isInArray(o,r.mode)||u)}loadModeOptions(e,...t){s.loadOptionProperty(e,"bubble",l,...t)}reset(e,t){t.bubble.inRange=!1}#i(e){const t=this.container,i=t.actualOptions,n=e.mouse.clickPosition,l=i.interactivity?.modes.bubble;if(!l||!n)return;t.bubble??={};const r=t.retina.bubbleModeDistance;if(!r||r<0)return;const o=t.particles.grid.queryCircle(n,r,t=>this.isEnabled(e,t)),{bubble:c}=t;for(const i of o){if(!c.clicking)continue;i.bubble.inRange=!c.durationEnd;const o=i.getPosition(),b=s.getDistance(o,n),u=(performance.now()-(e.mouse.clickTime??0))/s.millisecondsToSeconds;u>l.duration&&(c.durationEnd=!0),u>l.duration*s.double&&(c.clicking=!1,c.durationEnd=!1);const _={bubbleObj:{optValue:t.retina.bubbleModeSize,value:i.bubble.radius},particlesObj:{optValue:i.size.max,value:i.size.value},type:a.size};this.#l(i,b,u,_);const p={bubbleObj:{optValue:l.opacity,value:i.bubble.opacity},particlesObj:{optValue:i.opacity?.max??1,value:i.opacity?.value??1},type:a.opacity};this.#l(i,b,u,p),!c.durationEnd&&b<=r?this.#a(i,b):delete i.bubble.color}}#s(e){const i=this.container,n=e.mouse.position,l=i.retina.bubbleModeDistance;if(!l||l<0||!n)return;const a=i.particles.grid.queryCircle(n,l,t=>this.isEnabled(e,t));for(const i of a){i.bubble.inRange=!0;const a=i.getPosition(),r=s.getDistance(a,n),o=1-r/l;r<=l?o>=0&&e.status===t.mouseMoveEvent&&(this.#r(i,o),this.#o(i,o),this.#a(i,o)):this.reset(e,i),e.status===t.mouseLeaveEvent&&this.reset(e,i)}}#a(e,t,i){const n=this.container.actualOptions,l=i??n.interactivity?.modes.bubble;if(l){if(!e.bubble.finalColor){const t=l.color;if(!t)return;const i=s.itemFromSingleOrMultiple(t);e.bubble.finalColor=s.rangeColorToHsl(this.#t,i)}if(e.bubble.finalColor)if(l.mix){e.bubble.color=void 0;const i=e.getFillColor();e.bubble.color=i?s.rgbToHsl(s.colorMix(i,e.bubble.finalColor,1-t,t)):e.bubble.finalColor}else e.bubble.color=e.bubble.finalColor}}#o(e,t,s){const i=this.container.actualOptions,n=s?.opacity??i.interactivity?.modes.bubble?.opacity;if(!n)return;const l=r(e.opacity?.value??1,n,e.opacity?.max??1,t);void 0!==l&&(e.bubble.opacity=l)}#r(e,t,s){const i=this.container,n=s?.size?s.size*i.retina.pixelRatio:i.retina.bubbleModeSize;if(void 0===n)return;const l=r(e.size.value,n,e.size.max,t);void 0!==l&&(e.bubble.radius=l)}#l(e,t,s,i){const n=this.container,l=i.bubbleObj.optValue,r=n.actualOptions,o=r.interactivity?.modes.bubble;if(!o||void 0===l)return;const c=o.duration,b=n.retina.bubbleModeDistance,u=i.particlesObj.optValue,_=i.bubbleObj.value,p=i.particlesObj.value??0,d=i.type;if(b&&!(b<0)&&l!==u)if(n.bubble??={},n.bubble.durationEnd)_&&(d===a.size&&delete e.bubble.radius,d===a.opacity&&delete e.bubble.opacity);else if(t<=b){if((_??p)!==l){const t=p-s*(p-l)/c;d===a.size&&(e.bubble.radius=t),d===a.opacity&&(e.bubble.opacity=t)}}else d===a.size&&delete e.bubble.radius,d===a.opacity&&delete e.bubble.opacity}#n(e,i,n,l){const a=this.container,r=s.safeDocument().querySelectorAll(n),o=a.actualOptions.interactivity?.modes.bubble;o&&r.length&&r.forEach(n=>{const r=n,c=a.retina.pixelRatio,b={x:(r.offsetLeft+r.offsetWidth*s.half)*c,y:(r.offsetTop+r.offsetHeight*s.half)*c},u=r.offsetWidth*s.half*c,_=l.type===t.DivType.circle?new s.Circle(b.x,b.y,u):new s.Rectangle(r.offsetLeft*c,r.offsetTop*c,r.offsetWidth*c,r.offsetHeight*c),p=a.particles.grid.query(_,t=>this.isEnabled(e,t));for(const e of p){if(!_.contains(e.getPosition()))continue;e.bubble.inRange=!0;const s=o.divs,n=t.divMode(s,r);e.bubble.div&&e.bubble.div===r||(this.clear(e,i,!0),e.bubble.div=r),this.#r(e,1,n),this.#o(e,1,n),this.#a(e,1,n)}})}}async function b(e){e.checkVersion("4.2.0"),await e.pluginManager.register(e=>{t.ensureInteractivityPluginLoaded(e),e.pluginManager.addInteractor?.("externalBubble",t=>Promise.resolve(new c(e.pluginManager,t)))})}const u=globalThis;u.__tsParticlesInternals=u.__tsParticlesInternals??{},u.loadExternalBubbleInteraction=b,e.Bubble=l,e.BubbleBase=i,e.BubbleDiv=n,e.loadExternalBubbleInteraction=b}),Object.assign(globalThis.window||globalThis,{loadExternalBubbleInteraction:(globalThis.__tsParticlesInternals.interactions.externalBubble||{}).loadExternalBubbleInteraction}),delete(globalThis.window||globalThis).tsparticlesInternalExports;
|
|
@@ -3,6 +3,5 @@ import { BubbleBase } from "./BubbleBase.js";
|
|
|
3
3
|
import type { IBubbleDiv } from "../Interfaces/IBubbleDiv.js";
|
|
4
4
|
export declare class BubbleDiv extends BubbleBase implements IBubbleDiv, IOptionLoader<IBubbleDiv> {
|
|
5
5
|
selectors: SingleOrMultiple<string>;
|
|
6
|
-
constructor();
|
|
7
6
|
load(data?: RecursivePartial<IBubbleDiv>): void;
|
|
8
7
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Bubble } from "./Bubble.js";
|
|
2
2
|
import type { InteractivityOptions } from "@tsparticles/plugin-interactivity";
|
|
3
3
|
export type BubbleOptions = InteractivityOptions & {
|
|
4
4
|
interactivity?: {
|
|
5
|
-
modes:
|
|
5
|
+
modes: {
|
|
6
|
+
bubble?: Bubble;
|
|
7
|
+
};
|
|
6
8
|
};
|
|
7
9
|
};
|