@tsparticles/editor
Version:
tsParticles Configuration Editor
95 lines (94 loc) • 3.25 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DivsEventsOptionsEditor = void 0;
const engine_1 = require("@tsparticles/engine");
const object_gui_1 = require("object-gui");
const EditorBase_1 = require("../../../../EditorBase");
class DivsEventsOptionsEditor extends EditorBase_1.EditorBase {
constructor(particles) {
super(particles);
}
addToGroup(parent) {
this.group = parent.addGroup("onDiv", "Divs Events");
this.options = this.group.data;
this.addDivs();
if (this.options() instanceof Array) {
this.group.addButton("addDiv", "Add Div", false).click(() => {
const arr = this.options();
const divGroup = this.group.addGroup(arr.length.toString(10), `Div ${arr.length + 1}`, true, this.options);
this.addDiv(divGroup);
void this.particles().refresh();
});
}
}
addDiv(group) {
const options = group.data;
if (options().selectors instanceof Array) {
const selectorsGroup = group.addGroup("selectors", "Selectors");
selectorsGroup.addButton("addSelector", "Add Selector", false).click(() => {
const arr = options().selectors;
selectorsGroup
.addProperty(arr.length.toString(10), `Selector ${arr.length + 1}`, object_gui_1.EditorType.string)
.change(() => {
void this.particles().refresh();
});
void this.particles().refresh();
});
}
else {
group.addProperty("selectors", "Selectors", object_gui_1.EditorType.string).change(() => {
void this.particles().refresh();
});
}
group
.addProperty("enable", "Enable", object_gui_1.EditorType.boolean)
.change(() => {
void this.particles().refresh();
})
.step(0.01)
.min(0)
.max(1);
this.group
.addProperty("mode", "Mode", object_gui_1.EditorType.select)
.change(() => {
void this.particles().refresh();
})
.addItems([
{
value: "bounce",
},
{
value: "bubble",
},
{
value: "repulse",
},
]);
group
.addProperty("type", "Type", object_gui_1.EditorType.select)
.change(() => {
void this.particles().refresh();
})
.addItems([
{
value: engine_1.DivType.circle,
},
{
value: engine_1.DivType.rectangle,
},
]);
}
addDivs() {
const options = this.options;
if (options() instanceof Array) {
for (let i = 0; i < options.length; i++) {
const group = this.group.addGroup(i.toString(10), `Div_${i + 1}`, true, options);
this.addDiv(group);
}
}
else {
this.addDiv(this.group);
}
}
}
exports.DivsEventsOptionsEditor = DivsEventsOptionsEditor;