Engine class for creating the singleton on window. It's a singleton proxy to the Loader class for initializing Container instances, and for Plugins class responsible for every external feature

Hierarchy

  • Engine

Constructors

  • Engine constructor, initializes plugins, loader and the containers array

    Returns Engine

Properties

#domArray: Container[]

Contains all the Container instances of the current engine instance

#eventDispatcher: EventDispatcher
#initialized: boolean

Checks if the engine instance is initialized

#loader: Loader

Contains the Loader engine instance

plugins: Plugins

Contains the Plugins engine instance

Methods

  • Adds a listener to the specified event

    Parameters

    • type: string

      The event to listen to

    • listener: CustomEventListener

      The listener of the specified event

    Returns void

  • addPathGenerator adds a named path generator to tsParticles, this can be called by options

    Parameters

    • name: string

      the path generator name

    • generator: IMovePathGenerator

      the path generator object

    Returns Promise<void>

  • addPlugin adds plugin to tsParticles, if an instance needs it it will be loaded

    Parameters

    • plugin: IPlugin

      the plugin implementation of IPlugin

    Returns Promise<void>

  • addPreset adds preset to tsParticles, it will be available to all future instances created

    Parameters

    • preset: string

      the preset name

    • options: RecursivePartial<IOptions>

      the options to add to the preset

    • override: boolean = false

      if true, the preset will override any existing with the same name

    Returns Promise<void>

  • Dispatches an event that will be listened from listeners

    Parameters

    • type: string

      The event to dispatch

    • args: CustomEventArgs

      The event parameters

    Returns void

  • All the Container objects loaded

    Returns

    All the Container objects loaded

    Returns Container[]

  • Retrieves a Container from all the objects loaded

    Returns

    The Container object at specified index, if present or not destroyed, otherwise undefined

    Parameters

    • index: number

      The object index

    Returns undefined | Container

  • init method, used by imports

    Returns void

  • Loads an options object from the provided array to create a Container object.

    Returns

    A Promise with the Container object created

    Parameters

    • tagId: string

      The particles container element id

    • options: RecursivePartial<IOptions>[]

      The options array to get the item from

    • Optional index: number

      If provided gets the corresponding item from the array

    Returns Promise<undefined | Container>

  • Loads the provided json with a GET request. The content will be used to create a Container object. This method is async, so if you need a callback refer to JavaScript function fetch

    Returns

    A Promise with the Container object created

    Parameters

    • tagId: SingleOrMultiple<string>

      the particles container element id

    • Optional pathConfigJson: number | SingleOrMultiple<string>

      the json path (or paths array) to use in the GET request

    • Optional index: number

      the index of the paths array, if a single path is passed this value is ignored

    Returns Promise<undefined | Container>

  • Reloads all existing tsParticles loaded instances

    Returns Promise<void>

  • Removes a listener from the specified event

    Parameters

    • type: string

      The event to stop listening to

    • listener: CustomEventListener

      The listener of the specified event

    Returns void

  • Loads the provided option to create a Container object using the element parameter as a container

    Returns

    A Promise with the Container object created

    Parameters

    • id: string | HTMLElement

      The particles container id

    • element: HTMLElement | SingleOrMultiple<string>

      The dom element used to contain the particles

    • Optional pathConfigJson: number | SingleOrMultiple<string>

      the json path (or paths array) to use in the GET request

    • Optional index: number

      the index of the paths array, if a single path is passed this value is ignored

    Returns Promise<undefined | Container>

  • Adds an additional click handler to all the loaded Container objects.

    Parameters

    • callback: ((e: Event, particles?: Particle[]) => void)

      The function called after the click event is fired

        • (e: Event, particles?: Particle[]): void
        • Parameters

          • e: Event
          • Optional particles: Particle[]

          Returns void

    Returns void