tsparticles-engine
Version:
Easily create highly customizable particle, confetti and fireworks animations and use them as animated backgrounds for your website. Ready to use components available also for React, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Riot.js, Inferno.
55 lines (54 loc) • 1.98 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.InteractionManager = void 0;
class InteractionManager {
constructor(engine, container) {
this.container = container;
this._engine = engine;
this._interactors = engine.plugins.getInteractors(this.container, true);
this._externalInteractors = [];
this._particleInteractors = [];
}
async externalInteract(delta) {
for (const interactor of this._externalInteractors) {
interactor.isEnabled() && (await interactor.interact(delta));
}
}
handleClickMode(mode) {
for (const interactor of this._externalInteractors) {
interactor.handleClickMode && interactor.handleClickMode(mode);
}
}
init() {
this._externalInteractors = [];
this._particleInteractors = [];
for (const interactor of this._interactors) {
switch (interactor.type) {
case "external":
this._externalInteractors.push(interactor);
break;
case "particles":
this._particleInteractors.push(interactor);
break;
}
interactor.init();
}
}
async particlesInteract(particle, delta) {
for (const interactor of this._externalInteractors) {
interactor.clear(particle, delta);
}
for (const interactor of this._particleInteractors) {
interactor.isEnabled(particle) && (await interactor.interact(particle, delta));
}
}
async reset(particle) {
for (const interactor of this._externalInteractors) {
interactor.isEnabled() && interactor.reset(particle);
}
for (const interactor of this._particleInteractors) {
interactor.isEnabled(particle) && interactor.reset(particle);
}
}
}
exports.InteractionManager = InteractionManager;
;