Skip to content

Commit

Permalink
feat: added v1 plugins to slim and full bundle, fixed some stuff in p…
Browse files Browse the repository at this point in the history
…js plugin
  • Loading branch information
matteobruni committed Feb 15, 2022
1 parent 3b18578 commit 411ddce
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 4 deletions.
22 changes: 22 additions & 0 deletions bundles/full/src/FullV1Plugin.ts
@@ -0,0 +1,22 @@
import type { IContainerPlugin, IPlugin, Options } from "tsparticles-engine";
import { fixOptions } from "./fixOptions";

export class FullV1Plugin implements IPlugin {
readonly id: string;

constructor() {
this.id = "tsparticles-v1-plugin";
}

needsPlugin(): boolean {
return true;
}

getPlugin(): IContainerPlugin {
return {};
}

loadOptions(options: Options): void {
fixOptions(options);
}
}
7 changes: 7 additions & 0 deletions bundles/full/src/fixOptions.ts
@@ -0,0 +1,7 @@
import type {
ISourceOptions
} from "tsparticles-engine";

export const fixOptions = (options: ISourceOptions): ISourceOptions => {
return options;
}
3 changes: 3 additions & 0 deletions bundles/full/src/index.ts
@@ -1,4 +1,5 @@
import type { Engine } from "tsparticles-engine";
import { FullV1Plugin } from "./FullV1Plugin";
import { loadAbsorbersPlugin } from "tsparticles-plugin-absorbers";
import { loadEmittersPlugin } from "tsparticles-plugin-emitters";
import { loadExternalTrailInteraction } from "tsparticles-interaction-external-trail";
Expand All @@ -9,6 +10,8 @@ import { loadTiltUpdater } from "tsparticles-updater-tilt";
import { loadWobbleUpdater } from "tsparticles-updater-wobble";

export async function loadFull(engine: Engine): Promise<void> {
await engine.addPlugin(new FullV1Plugin());

await loadSlim(engine);

await loadTiltUpdater(engine);
Expand Down
File renamed without changes.
4 changes: 1 addition & 3 deletions bundles/pjs/src/fixOptions.ts
Expand Up @@ -14,7 +14,7 @@ import type {
import { deepExtend, setRangeValue } from "tsparticles-engine";
import type { IParticlesJSOptions } from "./IParticlesJSOptions";

const fixOptions = (options: RecursivePartial<IParticlesJSOptions>): ISourceOptions => {
export const fixOptions = (options: RecursivePartial<IParticlesJSOptions>): ISourceOptions => {
if (options.retina_detect !== undefined) {
options.detectRetina = options.retina_detect;
}
Expand Down Expand Up @@ -170,5 +170,3 @@ const fixOptions = (options: RecursivePartial<IParticlesJSOptions>): ISourceOpti

return options;
};

export { fixOptions };
2 changes: 1 addition & 1 deletion bundles/pjs/src/index.ts
Expand Up @@ -5,7 +5,7 @@
import type { Container, Engine, Particle, RecursivePartial } from "tsparticles-engine";
import type { IParticlesJS } from "./IParticlesJS";
import type { IParticlesJSOptions } from "./IParticlesJSOptions";
import { ParticlesJSPlugin } from "./particlesJSPlugin";
import { ParticlesJSPlugin } from "./ParticlesJSPlugin";

const initPjs = (engine: Engine): { particlesJS: IParticlesJS; pJSDom: Container[] } => {
engine.addPlugin(new ParticlesJSPlugin());
Expand Down
22 changes: 22 additions & 0 deletions bundles/slim/src/SlimV1Plugin.ts
@@ -0,0 +1,22 @@
import type { IContainerPlugin, IPlugin, Options } from "tsparticles-engine";
import { fixOptions } from "./fixOptions";

export class SlimV1Plugin implements IPlugin {
readonly id: string;

constructor() {
this.id = "slim-v1-plugin";
}

needsPlugin(): boolean {
return true;
}

getPlugin(): IContainerPlugin {
return {};
}

loadOptions(options: Options): void {
fixOptions(options);
}
}
7 changes: 7 additions & 0 deletions bundles/slim/src/fixOptions.ts
@@ -0,0 +1,7 @@
import type {
ISourceOptions
} from "tsparticles-engine";

export const fixOptions = (options: ISourceOptions): ISourceOptions => {
return options;
}
3 changes: 3 additions & 0 deletions bundles/slim/src/index.ts
@@ -1,4 +1,5 @@
import type { Engine } from "tsparticles-engine";
import { SlimV1Plugin } from "./SlimV1Plugin";
import { loadAngleUpdater } from "tsparticles-updater-angle";
import { loadBaseMover } from "tsparticles-move-base";
import { loadCircleShape } from "tsparticles-shape-circle";
Expand Down Expand Up @@ -29,6 +30,8 @@ import { loadStrokeColorUpdater } from "tsparticles-updater-stroke-color";
import { loadTextShape } from "tsparticles-shape-text";

export async function loadSlim(engine: Engine): Promise<void> {
await engine.addPlugin(new SlimV1Plugin());

await loadBaseMover(engine);
await loadParallaxMover(engine);

Expand Down

0 comments on commit 411ddce

Please sign in to comment.