Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: changed particles.js compatibility with a new plugin
- Loading branch information
1 parent
88b9dfe
commit 4b7c90b
Showing
5 changed files
with
114 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import type { Container } from "tsparticles-engine"; | ||
import { IParticlesJSOptions } from "./IParticlesJSOptions"; | ||
|
||
/** | ||
* [[include:pjsMigration.md]] | ||
* @category Particles.js | ||
*/ | ||
export interface IParticlesJS { | ||
/** | ||
* Loads the provided options to create a [[Container]] object. | ||
* @deprecated this method is obsolete, please use the new tsParticles.load | ||
* @param tagId the particles container element id | ||
* @param options the options object to initialize the [[Container]] | ||
*/ | ||
(tagId: string, options: IParticlesJSOptions): Promise<Container | undefined>; | ||
|
||
/** | ||
* Loads the provided json with a GET request. | ||
* The content will be used to create a [[Container]] object. | ||
* @deprecated this method is obsolete, please use the new tsParticles.loadJSON | ||
* @param tagId the particles container element id | ||
* @param pathConfigJson the json path to use in the GET request | ||
* @param callback called after the [[Container]] is loaded and it will be passed as a parameter | ||
*/ | ||
load(tagId: string, pathConfigJson: string, callback: (container?: Container) => void): void; | ||
|
||
/** | ||
* Adds an additional click handler to all the loaded [[Container]] objects. | ||
* @deprecated this method is obsolete, please use the new tsParticles.setOnClickHandler | ||
* @param callback the function called after the click event is fired | ||
*/ | ||
setOnClickHandler(callback: EventListenerOrEventListenerObject): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import type { IPlugin, IContainerPlugin } from "tsparticles-engine"; | ||
import type { Options } from "tsparticles-engine/Options/Classes/Options"; | ||
import { fixOptions } from "./fixOptions"; | ||
|
||
export class ParticlesJSPlugin implements IPlugin { | ||
readonly id: string; | ||
|
||
constructor() { | ||
this.id = "particles-js-plugin"; | ||
} | ||
|
||
needsPlugin(): boolean { | ||
return true; | ||
} | ||
|
||
getPlugin(): IContainerPlugin { | ||
return {}; | ||
} | ||
|
||
loadOptions(options: Options): void { | ||
fixOptions(options); | ||
} | ||
} |