@tsparticles/editor
Version:
tsParticles Configuration Editor
58 lines (57 loc) • 1.84 kB
JavaScript
import { EditorType } from "object-gui";
import { EditorBase } from "../../../../EditorBase";
import { loadAbsorbersPlugin } from "@tsparticles/plugin-absorbers";
import { loadEmittersPlugin } from "@tsparticles/plugin-emitters";
export class ClickEventsOptionsEditor extends EditorBase {
constructor(particles) {
super(particles);
}
addToGroup(parent) {
this.group = parent.addGroup("onClick", "Click Events");
this.options = this.group.data;
this.addProperties();
}
addProperties() {
this.group.addProperty("enable", "Enable", EditorType.boolean).change(() => {
void this.particles().refresh();
});
const modeSelectInput = this.group
.addProperty("mode", "Mode", EditorType.select)
.change(() => {
void this.particles().refresh();
})
.addItems([
{
value: "attract",
},
{
value: "bubble",
},
{
value: "pause",
},
{
value: "push",
},
{
value: "remove",
},
{
value: "repulse",
},
{
value: "trail",
},
]);
if (typeof loadAbsorbersPlugin !== "undefined") {
const absorbersGroup = "Absorbers";
modeSelectInput.addItemGroup(absorbersGroup);
modeSelectInput.addItem("absorber", undefined, absorbersGroup);
}
if (typeof loadEmittersPlugin !== "undefined") {
const emittersGroup = "Emitters";
modeSelectInput.addItemGroup(emittersGroup);
modeSelectInput.addItem("emitter", undefined, emittersGroup);
}
}
}