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

_configs: Map<string, RecursivePartial<IOptions>>
_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

Accessors

  • get version(): string
  • Returns string

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

    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>

  • addShape adds shape to tsParticles, it will be available to all future instances created

    Parameters

    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

  • Retrieves a Container from all the objects loaded

    Parameters

    • index: number

      The object index

    Returns undefined | Container

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

  • init method, used by imports

    Returns void

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

    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>

    A Promise with the Container object created

  • 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

    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>

    A Promise with the Container object created

  • 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

    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>

    A Promise with the Container object created

  • Adds another click handler to all the loaded Container objects.

    Parameters

    • callback: ((e, particles?) => void)

      The function called after the click event is fired

        • (e, particles?): void
        • Parameters

          • e: Event
          • Optional particles: Particle[]

          Returns void

    Returns void