Type alias PlayerFactory

PlayerFactory: ((container, iconData, initial) => IPlayer)

Type declaration

    • (container, iconData, initial): IPlayer
    • Defines the callback that will create a player instance on demand for the Element.

      Some use cases for providing your own player factory:

      • Consider abandoning the use of defineElement due to the potential redundancy of default triggers. In this case, assign the player factory before defining the custom element.
      • Enables the provision of a custom (user-defined) player implementation.

      Example:

      import lottie from 'lottie-web';
      import { Element, Player } from '@lordicon/element';

      Element.setPlayerFactory((container, iconData) => {
      return new Player(
      lottie.loadAnimation,
      container,
      iconData,
      );
      });

      customElements.define("lord-icon", Element);

      Parameters

      Returns IPlayer