Code Monkey home page Code Monkey logo

ngx-lottie's Introduction

A minimal customizable performance-stable Angular component for rendering After Effects animations. Compatible with Angular 9+.

Compatibility with Angular Versions

ngx-lottie Angular
7.x >= 8 < 13
8.x 13
9.x 14
10.x 15
11.x 17
12.x 18

Table of contents

Features

  • rich: ngx-lottie provides more opportunities to work with API exposed by Lottie
  • strict: all types of objects and events are available to you
  • performant: the lottie-web library can be loaded synchronously or on-demand

Quick example

<ng-lottie
  width="600px"
  height="500px"
  containerClass="moving-box another-class"
  [styles]="styles"
  [options]="options"
  (animationCreated)="animationCreated($event)"
  (configReady)="configReady()"
  (dataReady)="dataReady()"
  (domLoaded)="domLoaded()"
  (enterFrame)="enterFrame($event)"
  (segmentStart)="segmentStart($event)"
  (complete)="complete($event)"
  (loopComplete)="loopComplete($event)"
  (destroy)="destroy($event)"
  (error)="error($event)"
/>

Installation

To install ngx-lottie, run the following command:

npm i lottie-web ngx-lottie
# Or if you use yarn
yarn add lottie-web ngx-lottie
# Or if you use pnpm
pnpm i lottie-web ngx-lottie

Please note: ngx-lottie uses Scarf to collect anonymized installation analytics. These analytics help support the maintainers of this library. However, if you'd like to opt out, you can do so by setting scarfSettings.enabled = false in your project's package.json. Alternatively, you can set the environment variable SCARF_ANALYTICS=false before you install.

Usage

First, add provideLottieOptions to the app.config.ts:

// src/app/app.config.ts
import { provideLottieOptions } from 'ngx-lottie';
import player from 'lottie-web';

export const appConfig: ApplicationConfig = {
  providers: [
    provideLottieOptions({
      player: () => player,
    }),
  ],
};

The lottie-web library can be loaded on demand using dynamic import. Webpack will load this library only when your animation gets rendered for the first time. Given the following code:

// src/app/app.config.ts
import { provideLottieOptions } from 'ngx-lottie';

export const appConfig: ApplicationConfig = {
  providers: [
    provideLottieOptions({
      player: () => import('lottie-web'),
    }),
  ],
};

Now you can use the ng-lottie component and provide your custom options via the options binding.

import { Component } from '@angular/core';
import { AnimationItem } from 'lottie-web';
import { LottieComponent, AnimationOptions } from 'ngx-lottie';

@Component({
  selector: 'app-root',
  template: ` <ng-lottie [options]="options" (animationCreated)="animationCreated($event)" /> `,
  standalone: true,
  imports: [LottieComponent],
})
export class AppComponent {
  options: AnimationOptions = {
    path: '/assets/animation.json',
  };

  animationCreated(animationItem: AnimationItem): void {
    console.log(animationItem);
  }
}

Also, it's possible to use the lottie directive if you'd like to provide your custom container and manage it:

import { Component } from '@angular/core';
import { AnimationItem } from 'lottie-web';
import { LottieDirective, AnimationOptions } from 'ngx-lottie';

@Component({
  selector: 'app-root',
  template: `
    <main lottie [options]="options" (animationCreated)="animationCreated($event)"></main>
  `,
  standalone: true,
  imports: [LottieDirective],
})
export class AppComponent {
  options: AnimationOptions = {
    path: '/assets/animation.json',
  };

  animationCreated(animationItem: AnimationItem): void {
    console.log(animationItem);
  }
}

Updating animation

If you want to update the animation dynamically then you have to update the animation options immutably. Let's look at the following example:

import { Component } from '@angular/core';
import { AnimationItem } from 'lottie-web';
import { LottieComponent, AnimationOptions } from 'ngx-lottie';

@Component({
  selector: 'app-root',
  template: `
    <ng-lottie [options]="options" (animationCreated)="animationCreated($event)" />
    <button (click)="updateAnimation()">Update animation</button>
  `,
  standalone: true,
  imports: [LottieComponent],
})
export class AppComponent {
  options: AnimationOptions = {
    path: '/assets/animation.json',
  };

  animationCreated(animationItem: AnimationItem): void {
    console.log(animationItem);
  }

  updateAnimation(): void {
    // ⚠️⚠️ Don't do this!
    this.options.path = '/assets/new-animation.json';

    // ✔️✔️ Update `options` in this way
    this.options = {
      ...this.options, // In case you have other properties that you want to copy
      path: '/assets/new-animation.json',
    };
  }
}

If you want to update options relying on a response from the server, then you'll have to call detectChanges manually to ensure the change detection is run if ng-lottie is inside a ChangeDetectionStrategy.OnPush component:

import { Component, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core';
import { AnimationItem } from 'lottie-web';
import { LottieComponent, AnimationOptions } from 'ngx-lottie';

@Component({
  selector: 'app-root',
  template: `
    <ng-lottie [options]="options" (animationCreated)="animationCreated($event)" />
    <button (click)="updateAnimation()">Update animation</button>
  `,
  changeDetection: ChangeDetectionStrategy.OnPush,
  standalone: true,
  imports: [LottieComponent],
})
export class AppComponent {
  options: AnimationOptions = {
    path: '/assets/animation.json',
  };

  constructor(
    private ref: ChangeDetectorRef,
    private animationService: AnimationService,
  ) {}

  animationCreated(animationItem: AnimationItem): void {
    console.log(animationItem);
  }

  updateAnimation(): void {
    this.animationService.loadAnimationOptions().subscribe(options => {
      this.options = options;
      this.ref.detectChanges();
    });
  }
}

You can also store options in signal and bind them via the options() signal call:

@Component({
  selector: 'app-root',
  template: `
    <ng-lottie [options]="options()" (animationCreated)="animationCreated($event)" />
    <button (click)="updateAnimation()">Update animation</button>
  `,
  changeDetection: ChangeDetectionStrategy.OnPush,
  standalone: true,
  imports: [LottieComponent],
})
export class AppComponent {
  options = signal<AnimationOptions>({
    path: '/assets/animation.json',
  });

  constructor(
    private ref: ChangeDetectorRef,
    private animationService: AnimationService,
  ) {}

  animationCreated(animationItem: AnimationItem): void {
    console.log(animationItem);
  }

  updateAnimation(): void {
    this.animationService.loadAnimationOptions().subscribe(options => {
      this.options.set(options);
    });
  }
}

Listening to lottie-web events

The ng-lottie adds event listeners to those events that are listened outside. This means that if you've got the following code:

<ng-lottie (loopComplete)="onLoopComplete()" />

In the above example, the ng-lottie will only listen to the loopComplete event on the AnimationItem under the hood. One important note that all events are handled outside of the Angular zone:

ngZone.runOutsideAngular(() => {
  animationItem.addEventListener('loopComplete', () => {});
});

I made such a design decision because animation items can emit hundreds and thousands of events every second. The lottie-web emits some events asynchronously by wrapping them into setTimeout internally. Suppose thousands of events occur during a single second. In that case, Angular will run change detection a thousand times, drastically decreasing performance.

Therefore, event handlers will be called outside of the Angular zone:

import { Component, ChangeDetectionStrategy, NgZone } from '@angular/core';
import { LottieComponent, AnimationOptions } from 'ngx-lottie';

@Component({
  selector: 'app-root',
  template: ` <ng-lottie [options]="options" (loopComplete)="onLoopComplete()" /> `,
  changeDetection: ChangeDetectionStrategy.OnPush,
  standalone: true,
  imports: [LottieComponent],
})
export class AppComponent {
  options: AnimationOptions = {
    path: '/assets/animation.json',
  };

  onLoopComplete(): void {
    NgZone.assertNotInAngularZone();
    console.log(NgZone.isInAngularZone()); // false
  }
}

Therefore you need to re-enter the Angular execution context and call change detection manually via ChangeDetectorRef.detectChanges():

import { Component, ChangeDetectionStrategy, NgZone, ChangeDetectorRef } from '@angular/core';
import { LottieComponent, AnimationOptions } from 'ngx-lottie';

@Component({
  selector: 'app-root',
  template: `
    <ng-lottie [options]="options" (loopComplete)="onLoopComplete()" />
    <p>On loop complete called times = {{ onLoopCompleteCalledTimes }}</p>
  `,
  changeDetection: ChangeDetectionStrategy.OnPush,
  standalone: true,
  imports: [LottieComponent],
})
export class AppComponent {
  options: AnimationOptions = {
    path: '/assets/animation.json',
  };

  onLoopCompleteCalledTimes = 0;

  constructor(
    private ngZone: NgZone,
    private ref: ChangeDetectorRef,
  ) {}

  onLoopComplete(): void {
    this.ngZone.run(() => {
      this.onLoopCompleteCalledTimes++;
      this.ref.detectChanges();
    });
  }
}

Caching

The lottie-web will load your JSON file whenever animation is created. When providing options in the root config, you can also add the provideCacheableAnimationLoader:

// src/app/app.config.ts
import { provideLottieOptions, provideCacheableAnimationLoader } from 'ngx-lottie';

export const appConfig: ApplicationConfig = {
  providers: [
    provideLottieOptions({
      player: () => player,
    }),
    provideCacheableAnimationLoader(),
  ],
};

This will enable the internal cache. The ngx-lottie will load JSON files only once since the cache is enabled.

API

Bindings

The ng-lottie component supports the following bindings:

@Component({
  selector: 'app-root',
  template: `
    <ng-lottie
      width="500px"
      height="600px"
      containerClass="moving-box"
      [styles]="styles"
      [options]="options"
    />
  `,
  standalone: true,
  imports: [LottieComponent],
})
export class AppComponent {
  options: AnimationOptions = {
    path: '/assets/animation.json',
  };

  styles: Partial<CSSStyleDeclaration> = {
    maxWidth: '500px',
    margin: '0 auto',
  };
}
  • options: AnimationOptions options used by AnimationItem
  • width?: string container element width in pixels. Bound to [style.width]. You can provide any CSS unit, e.g. 100em
  • height?: string container element height in pixels. Bound to [style.height]. You can provide any CSS unit, e.g. 100em
  • styles?: Partial<CSSStyleDeclaration> custom styles object. Bound to [ngStyle]
  • containerClass?: string custom container class(es). Bound to [ngClass].

The lottie directive supports only options binding.

Events

@Output() Type Required Description
animationCreated AnimationItem optional Dispatched after the lottie successfully creates animation
configReady void optional Dispatched after the needed renderer is configured
dataReady void optional Dispatched when all parts of the animation have been loaded
domLoaded void optional Dispatched when elements have been added to the DOM
enterFrame BMEnterFrameEvent optional Dispatched after entering the new frame
segmentStart BMSegmentStartEvent optional Dispatched when the new segment is adjusted
loopComplete BMCompleteLoopEvent optional Dispatched after completing frame loop
complete BMCompleteEvent optional Dispatched after completing the last frame
destroy BMDestroyEvent optional Dispatched in the ngOnDestroy hook of the service that manages lottie's events, it's useful for releasing resources
error BMRenderFrameErrorEvent OR BMConfigErrorEvent optional Dispatched if the lottie player could not render some frame or parse the config

Reducing lottie-web bundle size

The size of the lottie-web library is quite large. Because when we write this:

import player from 'lottie-web';

export const appConfig: ApplicationConfig = {
  providers: [
    provideLottieOptions({
      player: () => player,
    }),
  ],
};

// Or if you load `lottie-web` on demand
export const appConfig: ApplicationConfig = {
  providers: [
    provideLottieOptions({
      player: () => import('lottie-web'),
    }),
  ],
};

It bundles all 3 renderers: CanvasRenderer, SVGRenderer and HybridRenderer. The SVGRenderer is used by default. If you don't care which renderer is used and never provide the renderer option, you might want to exclude CanvasRenderer and HybridRenderer. To do this, just import the lottie_svg file that is inside the lottie-web/build/player folder:

import player from 'lottie-web/build/player/lottie_svg';

export const appConfig: ApplicationConfig = {
  providers: [
    provideLottieOptions({
      player: () => player,
    }),
  ],
};

// Or if you load `lottie-web` on demand
export const appConfig: ApplicationConfig = {
  providers: [
    provideLottieOptions({
      player: () => import('lottie-web'),
    }),
  ],
};

Its minified size is 198 KiB.

You can also use the lottie-web light version. As Hernan Torrisi (author of lottie-web) explains:

It should work fine, but animations won't render correctly if they have expressions or effects.

The light version can be imported using the following code:

import player from 'lottie-web/build/player/lottie_light';

export const appConfig: ApplicationConfig = {
  providers: [
    provideLottieOptions({
      player: () => player,
    }),
  ],
};

// Or if you load `lottie-web` on demand
export const appConfig: ApplicationConfig = {
  providers: [
    provideLottieOptions({
      player: () => import('lottie-web/build/player/lottie_light'),
    }),
  ],
};

Its minified size is 148 KiB. Use this at your own risk because I can't know if your animations contain expressions or effects.

Optimizations

The ng-lottie component is marked with the OnPush change detection strategy. This means Angular will not check it in any phase of the change detection mechanism until you change the reference to some binding. For example, if you use an svg renderer and there are a lot of DOM elements projected — you would like to avoid checking this component, as it's not necessary.

The ngx-lottie listens to AnimationItem events outside of the Angular zone. It would be best if you didn't worry that animation events will cause change detection every ms.

But be careful! Always wrap any calls to AnimationItem methods in runOutsideAngular. See the below code:

import { Component, NgZone } from '@angular/core';
import { AnimationItem } from 'lottie-web';
import { LottieComponent, AnimationOptions } from 'ngx-lottie';

@Component({
  selector: 'app-root',
  template: `
    <ng-lottie [options]="options" (animationCreated)="animationCreated($event)" />

    <button (click)="stop()">Stop</button>
    <button (click)="play()">Play</button>
  `,
  standalone: true,
  imports: [LottieComponent],
})
export class AppComponent {
  options: AnimationOptions = {
    path: '/assets/animation.json',
  };

  private animationItem: AnimationItem;

  constructor(private ngZone: NgZone) {}

  animationCreated(animationItem: AnimationItem): void {
    this.animationItem = animationItem;
  }

  stop(): void {
    this.ngZone.runOutsideAngular(() => {
      this.animationItem.stop();
    });
  }

  play(): void {
    this.ngZone.runOutsideAngular(() => {
      this.animationItem.play();
    });
  }
}

Server-side rendering

By default, lottie-web will load your JSON file with animation data every time you create an animation. You may have some problems with the connection, so there may be some delay or even timeout. It's worth loading animation data only once and cache it on the client-side, so every time you create an animation — ngx-lottie will retrieve the animation data from the cache.

The ngx-lottie/server package allows you to preload animation data and cache it using TransferState.

How2?

TL;DR - see the integration folder.

Add the provideLottieServerOptions into your appServerConfig:

// src/app/app.config.server.ts
import { mergeApplicationConfig } from '@angular/core';
import { provideServerRendering } from '@angular/platform-server';
import { provideLottieServerOptions } from 'ngx-lottie/server';

import { appConfig } from './app.config';

export const appServerConfig = mergeApplicationConfig(appConfig, {
  providers: [
    provideServerRendering(),
    provideLottieServerOptions({
      preloadAnimations: {
        folder: 'dist/browser/assets',
        animations: ['data.json'],
      },
    }),
  ],
});

Let's look at these options. animations is an array of JSON files that contain animation data that Node.js should read on the server-side, cache, and transfer to the client. folder is a path where your JSON files are located. Still, you should use it properly. This path is joined with the process.cwd(). Consider the following project structure:

— dist (here you store your output artifacts)
  — browser
    — assets
    — index.html
    — main.hash.js
  - server
    - main.js
— src (here is your app)
— angular.json
— package.json

If you start a server from the root folder like node dist/server/main, thus the folder property should equal dist/browser/assets.

You can now inject the LottieTransferState into your components from the ngx-lottie package. It's tree-shakable by default and won't get bundled until you inject it anywhere:

import { Component } from '@angular/core';
import { LottieComponent, AnimationOptions, LottieTransferState } from 'ngx-lottie';

@Component({
  selector: 'app-root',
  template: ` <ng-lottie [options]="options" /> `,
  standalone: true,
  imports: [LottieComponent],
})
export class AppComponent {
  options: AnimationOptions = {
    animationData: this.lottieTransferState.get('data.json'),
  };

  constructor(private lottieTransferState: LottieTransferState) {}
}

Notice, data.json is a filename that you pass to the preloadAnimations.animations property.

Potential pitfalls

There is only one potential pitfall associated with animations in the Safari browser. Also, this known issue is in the lottie-web library itself. Library consumers have been trying to resolve that issue using different solutions. The only solution that helped most people was installing the latest version of the lottie-web.

ngx-lottie's People

Contributors

arturovt avatar carloshe avatar dependabot[bot] avatar rayanulhassan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ngx-lottie's Issues

Clarify the `options` available

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Current behavior

Expected behavior

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Environment


Libs:
- @angular/core version: X.Y.Z
- ngx-lottie version: X.Y.Z


Browser:
- [ ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

With Angular 10 getting the following error in production mode ERROR in Cannot resolve type entity i3.LottieAnimationViewModule to symbo

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Current behavior

I am using angular 10 with prod build I am getting the following issue
ERROR in Cannot resolve type entity i3.LottieAnimationViewModule to symbol

Expected behavior

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Environment


Libs:
- @angular/core version: X.Y.Z
- ngx-lottie version: X.Y.Z


Browser:
- [ ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

How used Lottie interactivity

Hi team,

How we can used the lottie interactivity features with ngx-lottie ?
https://lottiefiles.com/interactivity

Ia have try to install the lib https://github.com/LottieFiles/lottie-interactivity but i can't find a method to manipulate the ng-lottie... (Notice i'm new in the lottie game :D )

Regards,

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[X] Other... Please describe:

Possible memory leak

Possible memory leak


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[x] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Current behavior

page becomes unresponsive after few route changes

Expected behavior

page should be responsive

Minimal reproduction of the problem with instructions

just changing routes

What is the motivation / use case for changing the behavior?

N/A

Environment


Libs:
- @angular/core version: 8.2.14
- ngx-lottie version: 6.0.0


Browser:
- [x] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: v10.16.3
- Platform:   Windows

Others:

s1
s2
s3

ezgif-6-e042fbd808d5

[Violation] 'requestAnimationFrame' handler took ...

Hi!
I have a problem with performance. When you download the animation, after a while the page hangs in milliseconds. Here is a message from the console:

[Violation] 'requestAnimationFrame' handler took 573ms

Here is my code:

`options: AnimationOptions = {
path: '...'
};

<ng-lottie [options]="options">
`

Animation bug

Hi.

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Current behavior

If I try to specify animation like this

  opts = {
    path: "https://ffom2.csb.app/assets/anim.json",
    loop: false,
    renderer: "svg"
  };

then it works just fine. But specifying animation like this

opts = {
    animationData: animData, // imported JSON
    loop: false,
    renderer: "svg"
  };

it become wierd. The animation gets additional lines.

Expected behavior

Exact same behaviour for specifying path or animationData in animation options.

Minimal reproduction of the problem with instructions

You can see the bug here. It has to have just pulsing cross at the middle of the animation. And it does on its first loop, but each next loop has more and more lines.
I know that the way how animationData property should work is by using LottieTransferState.get('filename.json'), but bug repeats with LottieTransferState either.

Environment


Libs:
- @angular/core version: 11.0.1
- ngx-lottie version: 6.4.0

Browser:
- [x] Chrome (desktop) version 86
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [x] Firefox version 82
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: v14.8.0
- Platform:  Windows 

Problem in Angular 9

core.js:5845 ERROR TypeError: Cannot read property 'nativeElement' of undefined
at LottieAnimationViewComponent.push../node_modules/ng-lottie/ivy_ngcc/dist/esm/src/lottieAnimationView.component.js.LottieAnimationViewComponent.ngOnInit (lottieAnimationView.component.js:19)

I'm facing with this error. How to fix it?

Safari does not work with masks and clip paths.

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ x ] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Current behavior

SVGs in iOS Safari in an Angular X-platform app don't work with masks and clip paths. Mac OS safari works great.

Expected behavior

Should clip SVGs properly.

Minimal reproduction of the problem with instructions

This needs to be reproduced in an iPhone. I've tried creating a stack blitz but had no luck with using the ngx-lottie there. I'm using Ionic 4/Angular so I could make a sample app if you can test it on a device. The effect this bug has on animations can be seen on the following comparison where the first one does not clip correctly. The background is affected by this issue as well so linear-gradients might suffer from this too.


Environment


Libs:
- @angular/core version: 9.1.6
- ngx-lottie version: 6.2.1
- lottie-web version: 5.6.10


Browser:
- [ ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ x ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: 12.18.2
- Platform:  Mac

TypeError: Failed to resolve module specifier 'lottie-web/build/player/lottie.js'

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[x] Other: I can't make it work!

Current behavior

I'm following exactly what said on documentation (or I think I am) but I'm getting this error:
"TypeError: Failed to resolve module specifier 'lottie-web/build/player/lottie.js'"

Expected behavior

I expect to see my JSON animation rendered.

Minimal reproduction of the problem with instructions

You can check my issue here:
https://stackblitz.com/edit/angular-usa7nh

image

Environment


Libs:
- @angular/core version: 8.2.4
- ngx-lottie version: 3.0.0


Browser:
- [x] Opera (desktop) version 63.0.3368.53

For Tooling issues:
- Platform: Windows

Dynamic loading of options is not detected

I'm submitting a...


[ ] Other... Please describe: How to load multiple animation files with different options with in the same ng-lottie, So basically i want to play one animation once the newer animation arrives, it should start planning the latest one, 

Current behavior

With one ng-lottie tag, the newer animations are not played, it always plays the older animation when options are changed

Expected behavior

Should allow new animations to be played when options change,

Minimal reproduction of the problem with instructions

  • Step 1: Set options in ngOnint of the component.
  • Step 2: Reset options again when changed in ngOnchanges
  • Step 3: The options with changes are not displayed
    Change detetion on options is not triggered and so the changed options are not rendered

What is the motivation / use case for changing the behavior?

Play animations dynamically

Environment

Libs:

  • @angular/core version: 8 and 9
  • ngx-lottie version: latest

Browser:

  • Chrome (desktop) version latest

For Tooling issues:

  • Node version: 6.9
  • Platform: MAC

iOS Dark Background in Lottie Animation (Ionic 5)

I have a problem with the integration of a Lottie animation. Under web and on Android devices everything works perfectly, but under iOS I get a black background and can't understand why.


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Current & Expected behavior

lottie-issue-ios

Minimal reproduction of the problem with instructions

  • Template:
<div class="lottie-wrapper">
	<ng-lottie [options]="lottieIntroConfig" [styles]="lottieIntroStyle" containerClass="lottie-wrapper" (domLoaded)="lottieDomLoaded()" (animationCreated)="lottieAnimationCreated($event)"></ng-lottie>
</div>
  • CSS:
div.lottie-wrapper {
	width: var(--lottie-width);
	margin-left: calc((var(--lottie-width) - 100%) / 2 * -1);
	margin-top: var(--lottie-top);
}
  • Typescript:
public lottieIntroConfig: AnimationOptions = {
	path: '/assets/lottie/parnassia_intro.json',
	autoplay: true
};

// also these settings have no effect
public lottieIntroStyle: Partial<CSSStyleDeclaration> = {
	background: '#fff',
	backgroundAttachment: '#fff',
	backgroundClip: '#fff',
	backgroundColor: '#fff',
	backgroundImage: '#fff',
	backgroundOrigin: '#fff',
	fill: '#fff'
}

Environment

Libs:
- "@angular/core": "^9.1.0"
- "@ionic/angular": "^5.0.7"
- "cordova-android": "^8.1.0"
- "cordova-ios": "^5.1.1"
- "ngx-lottie": "^5.4.0"
 
For Tooling issues:
- Node.js version: v10.19.0
- Cordova CLI version: 9.0.3 ([email protected])
- npm version: 6.13.4
- macOS version: 10.14.6
- Xcode version: Xcode 11.0 (Build version 11A420a )

Thanks in advance!
Best, Dennis

Jest 27 compatibility issue

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Current behavior

I have updated Jest to version 27.0.4 and ngx-lottie to 7.0.1 but now I have an issue with my tests:

Jest encountered an unexpected token

Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

By default "node_modules" folder is ignored by transformers.

Here's what you can do:
 • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.
 • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
 • If you need a custom transformation specify a "transform" option in your config.
 • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/configuration
For information about custom transformations, see:
https://jestjs.io/docs/code-transformation

Details:

C:/repositories/greenmotion-frontend/node_modules/ngx-lottie/ngx-lottie.d.ts:4
export * from './index';
^^^^^^

SyntaxError: Unexpected token 'export'

  2 | import { NgModule } from '@angular/core';
  3 | import player from 'lottie-web';
> 4 | import { LottieModule } from 'ngx-lottie';
    | ^
  5 |
  6 | import { AnimationComponent } from './animation.component';
  7 |

  at Runtime.createScriptFromCode (../../node_modules/jest-runtime/build/index.js:1479:14)
  at Object.<anonymous> (src/lib/animation/animation.module.ts:4:1)

NOTE: If I downgrade to ngx-lottie 6.4.0, it works well with Jest 27.

Expected behavior

Same behavior than ngx-lottie 6.4.0

Minimal reproduction of the problem with instructions

Update Jest to version 27.0.4 and ngx-lottie to 7.0.1

What is the motivation / use case for changing the behavior?

I have update my project to Jest 27.

Environment


Libs:
- @angular/core version: 12.0.5
- ngx-lottie version: 7.0.1
- jest: 27.0.4


For Tooling issues:
- Node version: v16.1.0  
- Platform: Windows  

How manage responsive behavior with styles property ?

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[x ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

All is in the title : How to manage responsive behavior with styles property ? I mean adjust different style for medium screen, large screen, as we can do with the @media css ?

Thanks

What is the motivation / use case for changing the behavior?

Environment


Libs:
- @angular/core version: 11
- ngx-lottie version: latest


Browser:
- [x ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

Export internally used InjectionKeys and Classes

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[ ] Performance issue
[x] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Current behavior

Currently it is pretty much impossible to use this library in standalone components introduced in Angular 14: https://angular.io/guide/standalone-components

Expected behavior

Solving this would simply involve exporting a few things that are currently not exported in the library to avoid having to call .forRoot() to setup providers and let us users set those providers manually, as standalone components require us to.

Namely:

  • LOTTIE_OPTIONS InjectionToken
  • CacheableAnimationLoader

This way we can set it up like this:

export async function lottiePlayerFactory() {
  return import(/* webpackChunkName: 'lottie-web' */ 'lottie-web');
}

@Component({
  selector: 'eo-lottie-animation',
  standalone: true,
  imports: [LottieModule, AsyncPipe],
  providers: [AnimationLoader, { provide: LOTTIE_OPTIONS, useValue: { useWebWorker: true, player: lottiePlayerFactory } }],
  template: '<ng-lottie [options]="options$ | async" (animationCreated)="animationCreated($event)"></ng-lottie>',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class LottieAnimationComponent {
  @Input()
  public set animation(name: string) {
    this._options$.next({ path: `/assets/animations/${name}.json` });
  }

  private readonly _options$ = new BehaviorSubject<AnimationOptions>({
    path: '/assets/animations/white-loading.json',
  });

  public readonly options$ = this._options$.asObservable();

  public animationCreated(animationItem: AnimationItem): void {
    console.log(animationItem);
  }
}

What is the motivation / use case for changing the behavior?

Ability to use this library in standalone components in Angular 14.

Environment


Libs:
- @angular/core version: ^14.2.0
- ngx-lottie version: ^9.0.1

Browser:
- [ ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [x] Edge version 104.0.1293.70 (Official build) (arm64)
 
For Tooling issues:
- Node version: 16.16.0
- Platform: macOS

No provider for AnimationLoader

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x ] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Current behavior

I followed the README.md guide to setup ngx-lottie lib to use in a Ionic/Angular projet, but I am facing a issue to use.

Expected behavior

Minimal reproduction of the problem with instructions

import { LottieModule } from "ngx-lottie";

export function playerFactory() {
  return import(/* webpackChunkName: 'lottie-web' */ "lottie-web");
}

@NgModule({
  imports: [
    CommonModule,
    FormsModule,
    IonicModule,
    EarnRewardModalPageRoutingModule,
    LottieModule.forRoot({ player: playerFactory }),
  ],
  declarations: [EarnRewardModalPage],
})
export class EarnRewardModalPageModule {}
ERROR Error: Uncaught (in promise): NullInjectorError: R3InjectorError(Tab2PageModule)[AnimationLoader -> AnimationLoader -> AnimationLoader -> AnimationLoader -> AnimationLoader]: 
  NullInjectorError: No provider for AnimationLoader!
NullInjectorError: R3InjectorError(Tab2PageModule)[AnimationLoader -> AnimationLoader -> AnimationLoader -> AnimationLoader -> AnimationLoader]: 
  NullInjectorError: No provider for AnimationLoader!
    at NullInjector.get (core.js:915)
    at R3Injector.get (core.js:11082)
    at R3Injector.get (core.js:11082)
    at R3Injector.get (core.js:11082)
    at NgModuleRef$1.get (core.js:24199)
    at R3Injector.get (core.js:11082)
    at NgModuleRef$1.get (core.js:24199)
    at R3Injector.get (core.js:11082)
    at NgModuleRef$1.get (core.js:24199)
    at Object.get (core.js:22102)
    at resolvePromise (zone-evergreen.js:798)
    at zone-evergreen.js:705
    at rejected (tslib.es6.js:72)
    at ZoneDelegate.invoke (zone-evergreen.js:364)
    at Object.onInvoke (core.js:27437)
    at ZoneDelegate.invoke (zone-evergreen.js:363)
    at Zone.run (zone-evergreen.js:123)
    at zone-evergreen.js:857
    at ZoneDelegate.invokeTask (zone-evergreen.js:399)
    at Object.onInvokeTask (core.js:27425)

What is the motivation / use case for changing the behavior?

Environment


Libs:
- "@angular/core": "~10.0.0",
- "lottie-web": "^5.7.3"
- "ngx-lottie": "^6.4.0",


Browser:
- [ x] Chrome (desktop) version XX
- [ x] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

Angular Ivy Support

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Current behavior

When i Build an angular app using ivy i get the following error:

Warning: Invalid constructor parameter decorator in xxx/node_modules/ngx-lottie/fesm2015/ngx-lottie.js: () => [ { type: NgZone }, { type: String, decorators: [{ type: Inject, args: [PLATFORM_ID,] }] }, { type: undefined, decorators: [{ type: Inject, args: [LOTTIE_OPTIONS,] }] }, { type: undefined, decorators: [{ type: Inject, args: [ANIMATION_CACHE,] }] } ] Error: Error on worker #6: Error: getInternalNameOfClass() called on a non-ES5 class: expected AnimationLoader to have an inner class declaration at Esm5ReflectionHost.getInternalNameOfClass

Expected behavior

This should work :-)

Minimal reproduction of the problem with instructions

Environment


Libs:
- @angular/core version: 9.1.12
- ngx-lottie version: 6.3.0



Please help :-)

Best Regards from austria!
David

Can we use preload function in client side render?

I'm submitting a...


[x] Performance issue
[x] Feature request

Current behavior

It seems only have 'cache' & server-side preload strategy.

Expected behavior

Suggest interface like below

@NgModule({
    imports: [ 
       LottieClientPreloadModule.forRoot({ 
            preloadAnimations: {
               folder: 'dist/assets',
               animations: ['data.json']
            }
       }) 
    ]
})
export class AppModule 

What is the motivation / use case for changing the behavior?

In 3G Network speed, preloading all json in background can be helpful to improve user experience.

Lottie-web Methods Availability

lottie-web Methods Availability

Does ngx-lottie provide access to the main lottie-web methods documented here?

Primarily:

  • goToAndPlay
  • goToAndStop
  • setDirection
  • playSegments

Libs:
- @angular/core version: 9.0.4
- ngx-lottie version: 6.4.0

Thanks,
Jeff

v7 - upgrade guide?

Hey! Dependabot notified me that I can update ngx-lottie from 6.4.0 to 7.0.4
is there any upgrade guide on how to upgrade, what were the BC breaks one has to deal with?

is possible active only when hover?

hi
good gay.


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[x] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Expected behavior

if have hover option will be better

here is lottie-player example.

      <h3>Play animation on hover with loop intermission</h3>
      <lottie-player
        src="https://assets4.lottiefiles.com/datafiles/zc3XRzudyWE36ZBJr7PIkkqq0PFIrIBgp4ojqShI/newAnimation.json"
        style="width: 400px;"
        loop
        hover
        intermission="1000"
      ></lottie-player>

Dynamic Text updating animationData

I am trying to replace text dynamically in a lottie file similar what Hernan recommends in a plain Javascript approach here:
airbnb/lottie-web#238 (comment)

animationCreated(animationItem: AnimationItem): void {
    let aData = animationItem["animationData"];
    aData.layers[0].t.d.k[0].s.t = "New Value";
}

However, I'm not clear on how this would work with your prescribed updateAnimation since it is expecting a json URL and not a modified json file in memory.

Can you offer the best approach using ngx-lottie?

Thanks!

How to stop all animations globally

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[x] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Current behavior

Currently, to stop an animation, I need to get a reference to each AnimationItem and call stop().

Expected behavior

In order to support a global switch to disable animations, it would be preferable to have a providedIn: 'root' service that all ng-lottie instances listen to in order to disable every animation.

This might be desirable to support, for example, a motionless mode for visually impaired users who might want to disable animations because they are distracting or cause readability problems.

`containerClass` input only allows one class

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Current behavior

<ng-lottie
  containerClass="one two"
></ng-lottie>
Caught Runtime Error. DOMException: Failed to execute 'add' on 'DOMTokenList': The token provided ('one two') contains HTML space characters, which are not valid in tokens.

Expected behavior

Both classes should be assigned to the container.

Minimal reproduction of the problem with instructions

See above example. Root cause:

https://github.com/ngx-lottie/ngx-lottie/blob/master/src/src/lottie.component.ts#L46

Should be split on spaces and iteratively added, perhaps? Under the hood it's calling element.classList.add which only accepts one class. Example:

document.body.classList.add('one two')

What is the motivation / use case for changing the behavior?

Having a one-class limitation seems arbitrary.

Environment


Libs:
- @angular/core version: 8.2.14
- ngx-lottie version: 5.3.2


Browser:

All.

No way of delaying clean-up of animation if used with ngAnimate

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[x] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Current behavior

ngx-lottie onDestroy removes and unloads the animation. When used in conjunction with ngAnimate there is no allowance for a :leave animation to run while preserving the running on the lottie animation

Expected behavior

While the component is still in the DOM the animation should still run. While still preserving the cleanup after the element is removed.

Minimal reproduction of the problem with instructions

This should demonstrate the issue: https://angular-ivy-jvi5bm.stackblitz.io/

When toggling the angular animation in the lottie animation runs as soon as the json is available (in the demo it's bundled in the component - so immediately).
When toggling the angular animation out the ngDestroy fires before the animation runs and the animation is removed - leaving just the container to fade out.

What is the motivation / use case for changing the behavior?

While it's goof that the library tidies up animations it would be nice to preserve the running animation while exiting from the dom.

I don't know if this is possible via some ngAnimate hooks, but if not could a delay option be provided to the ngx-lottie component such that it's ngDestroy waits the delay period before tidying. Then I could pass the animation time through.

Environment


Libs:
- @angular/core version: 10.0.12
- ngx-lottie version: 4.6.0

Browser:
- [x] Chrome (desktop) version 84
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: N/A
- Platform:  All

Others:

Upgrading to latest lottie-web, introduces a runtime error

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Current behavior

Using the latest version of Lottie-Web 5.9.2 produces a runtime error related to types:

Error: node_modules/ngx-lottie/lib/symbols.d.ts:60:47 - error TS2314: Generic type 'AnimationConfigWithData' requires 1 type argument(s).

60 export declare type AnimationConfigWithData = import('lottie-web').AnimationConfigWithData;

They have converted that type to a generic type in version 5.9.x from what I can tell.

Expected behavior

ngx-lottie should be compatible with latest lottie-web

Minimal reproduction of the problem with instructions

Install latest ngx-lottie and latest Lottie-web on any sample and try to run it.

What is the motivation / use case for changing the behavior?

Environment


Libs:
- @angular/core version:  "13.3.0",
- ngx-lottie version: "8.0.1"
- lottie-web version: 5.9.2
- "typescript": "4.5.4",


Browser:
- [x] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: XX   16.14.2
- Platform:  Mac

Others:

lottie-web Methods Availability

lottie-web Methods Availability

Does ngx-lottie provide access to the main lottie-web methods documented here?

Primarily:

  • goToAndPlay
  • goToAndStop
  • setDirection
  • playSegments

Libs:
- @angular/core version: 9.0.4
- ngx-lottie version: 6.4.0

Thanks,
Jeff

Reverse Animation

how to achieve reverse animation and even change animation dynamically.... can someone help me 😀😀😀

how to change path on the fly by code?

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[ x] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

current behavior

if i have a lottie and i want to replace the animation on the fly according to events or notifications (i got 10 lotties) .i have to create multiple ng-lottie components and configs and replace using ngif or ngswitch
its a bummer.. :(

Expected behavior

i wish i could call config.path= newJson and with angular binding it will be replaced on the fly

can it be?

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Environment


Libs:
- @angular/core version: X.Y.Z
- ngx-lottie version: X.Y.Z


Browser:
- [ ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

Cannot find module 'lottie-web'.ts

I'm trying to use ngx-lottie but when i try to import lottie-web I receive this error message: Cannot find module 'lottie-web'.ts(2307). Where can I find Lottie-Web?

Access Timeline Markers?

Access Timeline Markers?

How would you recommend accessing the markers property located at:

AnimationItem.animationData.markers

The current typings do not allow access to it.


Libs:
- @angular/core version: 9.0.4
- ngx-lottie version: 6.4.0

Thanks,

Jeff

Compatibility angular 8

  • Other- Question

Hey, im using angular 8.2.9 and everything works fine, i dont need markDirty or detectChanges features, are there any known issues for most basic usage in angular 8?

Current behavior

Works fine

Expected behavior

Shouldnt work?

Environment


Libs:
 "@angular/core": "~8.2.9",
"lottie-web": "^5.7.4",
"ngx-lottie": "^6.4.0",

Missing property on BMCompleteLoopEvent

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ X] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Current behavior

While subscribing to the loop event on a lottieplayer, an error is thrown because the property "currentLoop" is missing on BMCompleteLoopEvent. Hence we have to manually extend the type in our ts.

Expected behavior

"currenLoop" should be provided by default in BMCompleteLoopEvent.

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

I want to stop the animation after a certain amount of loops.

Environment


Libs:
- @angular/core version: 12.2.16
- ngx-lottie version: 7.0.4
- 

Browser:
- [X ] Chrome (desktop) version XX
- [ X] Chrome (Android) version XX
- [ X] Chrome (iOS) version XX
- [ X] Firefox version XX
- [ X] Safari (desktop) version XX
- [ X] Safari (iOS) version XX
- [ X] IE version XX
- [ X] Edge version XX
 
For Tooling issues:
- Node version: 18.0.0  
- Platform: Mac 

Others:

The version 8.2.1 is not compatible with angular 13

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Current behavior

On install the last version "8.2.1" tha application crashes on start with angular 13, because seams that the library has been compiled with angualr 14.

MicrosoftTeams-image

Expected behavior

Version 8.2.1 should work with angular 13.

Minimal reproduction of the problem with instructions

  • Step 1: Create a project with angualr 13
  • Step 2: Install ngx-lottie library version 8.2.1
  • Step 3: Add a small example.
  • Step 4: Start the project.

Environment


Libs:
- @angular/core version: 13.3.11
- ngx-lottie version: 8.2.1

For Tooling issues:
- Node version: 16.14.2
- Platform:  Mac

How to update lottie without reseting the frame?

Hello,
I'm using this awesome package for one website i'm working on. We want to allow the users to update some values from the lottie file (like image, texts, colors, etc.)
For that, we updating the animationData object and then send it back to the library like this:

this.options = {
...this.options,
animationData: this.animationData //We update this animation data with the proper new values.
};

The thing is, if we do this way, animation is reset. So in case it was already playing and, for example, in frame number 60, it resets to frame 0, and we want it to keep playing where it was.

Is it possible somehow?

Thanks!

PD: You can find out example of our application here: https://animm-ui.web.app/animation/1 and you'll see the issue.

lottie-web-build-player-lottie_svg.js should be loaded only when animation gets rendered for the first time

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Current behavior

lottie-web-build-player-lottie_svg.js is loaded on startup even though I used dynamic import with Webpack magic comments as described: "The lottie-web library can be loaded on demand using dynamic import. Webpack will load this library only when your animation gets rendered for the first time"

Expected behavior

lottie-web-build-player-lottie_svg.js should be loaded only when animation gets rendered for the first time

Minimal reproduction of the problem with instructions

I did as described in the "Usage" section (and excluded CanvasRenderer and HybridRenderer as described in "Reducing lottie-web bundle size" section:

import { NgModule } from '@angular/core';
import { LottieModule } from 'ngx-lottie';

export function playerFactory() {
  return import(/* webpackChunkName: 'lottie-web' */ 'lottie-web/build/player/lottie_svg');
}

@NgModule({
  imports: [LottieModule.forRoot({ player: playerFactory })],
})
export class AppModule {}

Environment


Libs:
- @angular/core version: 11.2.14
- ngx-lottie version: 6.4.0


Browser:
- [x] Chrome (desktop) version 98
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: 12
- Platform:  Windows

Action inside of complete event does not perform correctly

Sorry for my english

I'm submitting a...

I don't know it's bug in library or I didn't fully understand Angular

  • Bug report

Current behavior

When i click on second button occurs calling mock service that after finish disables button and its ok
on first implementation, button should be disabled after complete event
But it disabled only after click outside of button

Expected behavior

First button should be disabled after complete event

Minimal reproduction of the problem with instructions

Peek 2020-06-16 17-46

Environment

I prepared project that reproduces this bug
https://github.com/andriyor/ngx-lottie-demo

Browser:

  • Chrome (desktop) version 83

div container at Runtime

I'm submitting a...


[ ] Feature request
[ ] Other... Please describe:

Current behavior

I want to convert any div to a lottie player at run time ( without adding lottie player tag ) , so any div can be converted to animating player while data is loading , then after done it convert back to its normal behaviour

I couldn't get such feature in your documentation and wondering if it is exist or not,
can you help please

Unit testing in Angular with ng-lottie element

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[ ] Feature request
[x] Documentation issue or request
[ ] Other... Please describe:

My setup is trivial angular unit testing with karma and jasmine.

What is this request about?

@arturovt Thank you for developing this library. It is really great and easy to work with. Excuse me if my more of a support request does not belong here and should be deleted.

One issue I am facing in my current setup is when I test Lottie in a *ngIf directive. In this case, when the animation should be displayed but really quickly I change the binding of the *ngIf to be false I have the LottieEventFacade calling dispose method which calls destroy on an animatiionItem of null
`private dispose(): void {
if (isPlatformServer(this.platformId)) {
return;
}

// destroy() will remove all events listeners
this.animationItem!.destroy(); // in here this.animationItem is not shown.
this.animationItem = null;

}`
And later in time the loadAnimation method is triggered.

Since I am not proficient with testing and what to mock in this case, I currently have added CUSTOM_ELEMENTS_SCHEMA to the tests so I can go around the issue.
Another way around for me was to Provide the PLATFORM_ID token as "server" because then the destroy is not called.

All in all my question is how is the best approach to test this scenario:

  1. Lottie directive starts
  2. The ng-lottie element is destroyed before it has loaded and initialized the animationItem
  3. An error is thrown that cannot call destroy() of null

'ng-lottie' is not a known element: 1. If 'ng-lottie' is an Angular component, then verify that it is part of this module.

I follow all steps in the documentation but still I m getting an error "'ng-lottie' is not a known element:

  1. If 'ng-lottie' is an Angular component, then verify that it is part of this module." i don't know why
  2. these are my dependancies "@angular/common": "~12.0.1",
    "@angular/core": "~12.0.1",
    "@angular/forms": "~12.0.1",
    "@angular/platform-browser": "~12.0.1",
    "@angular/platform-browser-dynamic": "~12.0.1",
    "@angular/router": "~12.0.1",
    "@capacitor/android": "^3.0.2",
    "@capacitor/app": "1.0.2",
    "@capacitor/clipboard": "^1.0.2",
    "@capacitor/core": "3.0.2",
    "@capacitor/haptics": "1.0.2",
    "@capacitor/keyboard": "1.0.2",
    "@ionic-native/clipboard": "^5.34.0",
    "@ionic/angular": "^5.5.2",
    "@ionic/storage-angular": "^3.0.6",
    "cordova-android": "9.1.0",
    "cordova-clipboard": "^1.3.0",
    "lottie-web": "^5.7.11",
    "ng-lottie": "^0.3.2",
    "ngx-lottie": "^7.0.3",
    "rxjs": "~6.6.0",
    "tslib": "^2.0.0",
    "zone.js": "~0.11.4"

Question: How to bind animation with scrolling

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[x] Feature request
[ ] Documentation issue or request
[x] Other... Please describe:

Current behavior

Expected behavior

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Hey,
I want to implement some kind of animation that interacts to user scrolling and plays an smooth animation when user
is going all down to the website.
In the outer world of angular you can do this with Lottie interactivity package and its working very good but, the problem is that my project implemented by angular and I just tried everything ( everything i was able to try ) and you know, technically I'm junior in angular development.

Is there any hope that I can do this in the future?

Environment


Libs:
- @angular/core version: X.Y.Z
- ngx-lottie version: X.Y.Z


Browser:
- [x] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [x] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: v16.10.0  
- Platform: Linux  

Others:

SVG Animation does not show properly and is requesting images

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Current behavior

I want my svg animation to display on my angular-based website. But instead of showing the svg animation; it shows errors that some images ar missing. The result so far:

image

Expected behavior

If have tested the animation on a regular html page (from: https://github.com/airbnb/lottie-web/blob/master/demo/bodymovin/index.html) thats is working. See:

image

Minimal reproduction of the problem with instructions

image

What is the motivation / use case for changing the behavior?

I want to show the animation :)

Environment


Libs:
  "dependencies": {
    "@angular/animations": "^8.2.5",
    "@angular/cdk": "^8.1.4",
    "@angular/common": "^8.2.5",
    "@angular/compiler": "^8.2.5",
    "@angular/core": "^8.2.5",
    "@angular/fire": "^5.2.1",
    "@angular/flex-layout": "^7.0.0-beta.24",
    "@angular/forms": "^8.2.5",
    "@angular/material": "^8.1.4",
    "@angular/platform-browser": "^8.2.5",
    "@angular/platform-browser-dynamic": "^8.2.5",
    "@angular/platform-server": "^8.2.5",
    "@angular/router": "^8.2.5",
    "@nguniversal/express-engine": "^8.1.1",
    "@nguniversal/module-map-ngfactory-loader": "8.1.1",
    "core-js": "^3.2.1",
    "express": "^4.17.1",
    "firebase": "^6.5.0",
    "hammerjs": "^2.0.8",
    "lottie-web": "^5.5.8",
    "moment": "^2.24.0",
    "ngx-lottie": "^3.0.0",
    "npm-check-updates": "^3.1.21",
    "rxjs": "^6.5.3",
    "tslib": "^1.10.0",
    "zone.js": "~0.10.2"
  },


Browser:
- [x] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: 10.16.0
- Platform:  Mac, Linux, Windows


No provider for AnimationLoader!

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Current behavior

I am using angular material dialog. I tried to show lazy loaded dialog, inside which the ng-lottie component is located and I've got an error "No provider for AnimationLoader!"

Expected behavior

Minimal reproduction of the problem with instructions

https://stackblitz.com/edit/angular-ivy-yakhbc?
click on show dialog

What is the motivation / use case for changing the behavior?

Environment


Libs:
- @angular/core version: ~13.1.0
- ngx-lottie version: 8.0.1


Browser:
- [x] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [x ] Firefox version XX
- [x ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: XX  
- Platform:  
Mac

Others:

Cache causing performance issues

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[x ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Current behavior

I have about 10 different lottie files displayed on my home page. If I activate the cache (with LottieCacheModule.forRoot()), and navigate to a different page (via the router) and back to the home page, I get performance issues. The animations are not smoothed anymore. It gets worse each time I navigate back to the home page. After 3 or 4 times, the page becomes completely unresponsive.
If I deactivate the cache, I don't have any performance issues.

Environment


Libs:
- @angular/core version: 12.0.4
- ngx-lottie version: 7.0.3


Browser:
- [x ] Chrome (desktop) version 93.0.4577.82
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: 14.16.1  
- Platform:  Windows 

Component ng-lottie is not reconized on angular 12.2.0

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Current behavior

I follow all steps in the documentation but I get this error.

Error: src/app/pages/login-page/login-page.component.html:2:1 - error NG8001: 'ng-lottie' is not a known element: 
1. If 'ng-lottie' is an Angular component, then verify that it is part of this module.
2. If 'ng-lottie' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.

Minimal reproduction of the problem with instructions

1- Setting up the lib
2- Run ng server

Environment

Libs:

"dependencies": {
    "@angular/animations": "~12.2.0",
    "@angular/cdk": "^12.2.0",
    "@angular/common": "~12.2.0",
    "@angular/compiler": "~12.2.0",
    "@angular/core": "~12.2.0",
    "@angular/forms": "~12.2.0",
    "@angular/material": "^12.2.0",
    "@angular/platform-browser": "~12.2.0",
    "@angular/platform-browser-dynamic": "~12.2.0",
    "@angular/router": "~12.2.0",
    "lottie-web": "^5.8.1",
    "ngx-lottie": "^7.0.4",
    "rxjs": "~7.4.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.11.4"
  }

On app.module.ts I have this configuration

import { LottieModule } from 'ngx-lottie';

export function playerFactory() {
  return import(/* webpackChunkName: 'lottie-web' */ 'lottie-web');
}

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    LottieModule.forRoot({ player: playerFactory })
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Browser:

  • Chrome (desktop) version XX
  • Chrome (Android) version XX
  • Chrome (iOS) version XX
  • Firefox version XX
  • Safari (desktop) version XX
  • Safari (iOS) version XX
  • IE version XX
  • Edge version XX

For Tooling issues:

  • Node version: v16.13.0
  • Platform: Windows

Ngx-Lottie is not working properly.

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[ ] Feature request
[x] Documentation issue or request
[ ] Other... Please describe:

Current behavior

I have followed the documentation exactly and it is still giving the error.

Screenshot 2019-10-22 at 8 58 19 PM

Expected behavior

It should have worked as per the docs.

Browser:

  • Chrome (desktop) version XX
  • Chrome (Android) version XX
  • Chrome (iOS) version XX
  • Firefox version XX
  • Safari (desktop) version XX
  • Safari (iOS) version XX
  • IE version XX
  • Edge version XX

Please let me know if there is anything missing in the docs.
Or what can be caused by the above error.

These are the dependencies.

"dependencies": {
"@angular/common": "7.2.15",
"@angular/core": "7.2.15",
"@angular/forms": "7.2.15",
"@angular/http": "7.2.15",
"@angular/platform-browser": "7.2.15",
"@angular/platform-browser-dynamic": "7.2.15",
"@angular/router": "7.2.15",
"@ionic-native/app-availability": "5.13.0",
"@ionic-native/appsflyer": "5.13.0",
"@ionic-native/branch-io": "5.13.0",
"@ionic-native/camera": "^5.15.0",
"@ionic-native/clevertap": "5.13.0",
"@ionic-native/clipboard": "5.13.0",
"@ionic-native/code-push": "5.13.0",
"@ionic-native/core": "5.13.0",
"@ionic-native/diagnostic": "5.13.0",
"@ionic-native/firebase": "5.13.0",
"@ionic-native/geolocation": "5.13.0",
"@ionic-native/http": "5.13.0",
"@ionic-native/in-app-browser": "5.13.0",
"@ionic-native/market": "5.13.0",
"@ionic-native/network": "5.13.0",
"@ionic-native/social-sharing": "5.13.0",
"@ionic-native/splash-screen": "5.13.0",
"@ionic-native/status-bar": "5.0.0",
"@ionic/angular": "4.8.1",
"@ionic/storage": "2.2.0",
"@juspay/ec-headless-cordova-plugin": "1.0.8",
"appcenter-cli": "2.2.1",
"branch-cordova-sdk": "3.2.0",
"clevertap-cordova": "2.1.2",
"cordova-android": "^8.0.0",
"cordova-android-support-gradle-release": "3.0.1",
"cordova-browser": "6.0.0",
"cordova-clipboard": "1.3.0",
"cordova-ios": "^5.0.1",
"cordova-plugin-advanced-http": "2.1.1",
"cordova-plugin-androidx": "1.0.2",
"cordova-plugin-androidx-adapter": "1.1.0",
"cordova-plugin-appavailability": "0.4.2",
"cordova-plugin-appsflyer-sdk": "4.4.20",
"cordova-plugin-camera": "4.1.0",
"cordova-plugin-code-push": "1.12.0",
"cordova-plugin-device": "2.0.3",
"cordova-plugin-dialogs": "2.0.1",
"cordova-plugin-enable-multidex": "0.2.0",
"cordova-plugin-file": "6.0.2",
"cordova-plugin-file-transfer": "1.7.1",
"cordova-plugin-firebasex": "6.1.0",
"cordova-plugin-geolocation": "4.0.2",
"cordova-plugin-inappbrowser": "3.1.0",
"cordova-plugin-ionic-keyboard": "2.2.0",
"cordova-plugin-ionic-webview": "4.1.1",
"cordova-plugin-market": "1.2.0",
"cordova-plugin-network-information": "2.0.2",
"cordova-plugin-packagemanager": "0.1.7",
"cordova-plugin-splashscreen": "5.0.3",
"cordova-plugin-statusbar": "2.4.3",
"cordova-plugin-whitelist": "1.3.4",
"cordova-plugin-x-socialsharing": "5.6.0",
"cordova-plugin-zip": "3.1.0",
"cordova-sqlite-storage": "3.3.0",
"cordova.plugins.diagnostic": "3.9.2",
"core-js": "2.6.9",
"es6-promise-plugin": "4.2.2",
"hammerjs": "2.0.8",
"lottie-web": "^5.5.9",
"moment": "2.24.0",
"ngx-lottie": "^5.2.0",
"ngx-moment": "3.4.0",
"rxjs": "6.5.3",
"scroll-into-view": "1.9.7",
"sentry-cordova": "0.15.0",
"tslib": "1.10.0",
"xml2js": "0.4.22",
"zone.js": "0.8.29"
},
"devDependencies": {
"@angular-devkit/architect": "0.13.9",
"@angular-devkit/build-angular": "0.13.9",
"@angular-devkit/core": "7.3.9",
"@angular-devkit/schematics": "7.3.9",
"@angular/cli": "7.3.9",
"@angular/compiler": "7.2.15",
"@angular/compiler-cli": "7.2.15",
"@angular/language-service": "7.2.15",
"@ionic/angular-toolkit": "1.5.1",
"@ionic/lab": "1.0.24",
"@types/jasmine": "2.8.16",
"@types/jasminewd2": "2.0.6",
"@types/node": "10.14.18",
"codelyzer": "4.5.0",
"jasmine-core": "2.99.1",
"jasmine-spec-reporter": "4.2.1",
"karma": "4.1.0",
"karma-chrome-launcher": "2.2.0",
"karma-coverage-istanbul-reporter": "2.0.6",
"karma-jasmine": "1.1.2",
"karma-jasmine-html-reporter": "0.2.2",
"protractor": "5.4.2",
"ts-node": "8.1.1",
"tslint": "5.16.0",
"typescript": "3.1.6"
},

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.