-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
555b7da
commit e3c1039
Showing
18 changed files
with
141 additions
and
160 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
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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
{ | ||
"name": "lottie", | ||
"name": "@fivethree/lottie", | ||
"version": "0.0.1", | ||
"peerDependencies": { | ||
"@angular/common": "^7.2.0", | ||
"@angular/core": "^7.2.0" | ||
"@angular/common": "^7.0.0", | ||
"@angular/core": "^7.0.0", | ||
"lottie-web": "^5.4.3" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,19 +1,58 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { | ||
Component, | ||
OnInit, | ||
ViewChild, | ||
ElementRef, | ||
Output, | ||
EventEmitter, | ||
Input | ||
} from '@angular/core'; | ||
import * as lottie from 'lottie-web'; | ||
import { LottieParams, LottieAnimation } from './symbols'; | ||
|
||
@Component({ | ||
selector: 'fiv-lottie', | ||
template: ` | ||
<p> | ||
lottie works! | ||
</p> | ||
<div #lottieContainer [ngStyle]="{'width': viewWidth, 'height': viewHeight, 'overflow':'hidden', 'margin': '0 auto'}"> | ||
</div> | ||
`, | ||
styles: [] | ||
}) | ||
export class LottieComponent implements OnInit { | ||
|
||
@Input() params: LottieParams; | ||
@Input() width: number; | ||
@Input() height: number; | ||
|
||
@Output() animationCreated = new EventEmitter<LottieAnimation>(); | ||
|
||
@ViewChild('lottieContainer') lottieContainer: ElementRef; | ||
|
||
public viewWidth: string; | ||
public viewHeight: string; | ||
|
||
private _params: LottieParams; | ||
|
||
constructor() { } | ||
|
||
ngOnInit() { | ||
this._params = { | ||
autoplay: this.params.autoplay, | ||
animationData: this.params.animationData, | ||
container: this.params.container || this.lottieContainer.nativeElement, | ||
loop: this.params.loop, | ||
name: this.params.name, | ||
path: this.params.path || '', | ||
renderer: this.params.renderer || 'svg', | ||
rendererSettings: this.params.rendererSettings | ||
}; | ||
|
||
const animation = lottie.loadAnimation(this._params); | ||
|
||
this.viewWidth = this.width + 'px' || '100%'; | ||
this.viewHeight = this.height + 'px' || '100%'; | ||
|
||
this.animationCreated.emit(animation); | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { NgModule } from '@angular/core'; | ||
import { LottieComponent } from './lottie.component'; | ||
|
||
@NgModule({ | ||
declarations: [LottieComponent], | ||
imports: [ | ||
], | ||
imports: [CommonModule], | ||
exports: [LottieComponent] | ||
}) | ||
export class LottieModule { } |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,68 @@ | ||
export interface LottieParams { | ||
autoplay?: boolean; | ||
animationData?: any; | ||
container?: any; | ||
loop?: boolean | number; | ||
name?: string; | ||
path: string; | ||
renderer?: 'svg' | 'canvas' | 'html'; | ||
rendererSettings?: LottieRenderSettings; | ||
} | ||
|
||
export interface LottieRenderSettings { | ||
context: any; | ||
scaleMode: 'noScale' | string; | ||
clearCanvas: boolean; | ||
progressiveLoad: boolean; | ||
hideOnTransparent: boolean; | ||
className: string; | ||
} | ||
|
||
export interface LottieAnimation { | ||
/** | ||
* @param name to target a specific animation | ||
*/ | ||
play(name?: string): void; | ||
/** | ||
* @param name to target a specific animation | ||
*/ | ||
pause(name?: string): void; | ||
/** | ||
* @param name to target a specific animation | ||
*/ | ||
stop(name?: string): void; | ||
destroy(): void; | ||
/** | ||
* @param href usually pass as location.href. Its useful when you experience mask issue in safari where your url does not have # symbol. | ||
*/ | ||
setLocationHref(href: string); | ||
/** | ||
* @param speed 1 is normal speed, plays reverse if minus | ||
* @param name to target a specific animation | ||
*/ | ||
setSpeed(speed: number, name?: string); | ||
/** | ||
* @param value frame value | ||
* @param isFrame defines if first argument is a time based value or a frame based (default false) | ||
*/ | ||
goToAndStop(value: number, isFrame?: boolean); | ||
/** | ||
* @param value frame value | ||
* @param isFrame defines if first argument is a time based value or a frame based (default false) | ||
*/ | ||
goToAndPlay(value: number, isFrame?: boolean); | ||
/** | ||
* @param direction 1 is forward, -1 is reverse | ||
*/ | ||
setDirection(direction: 1 | -1); | ||
/** | ||
* @param inFrames If true, returns duration in frames, if false, in seconds | ||
*/ | ||
getDuration(inFrames?: boolean): number; | ||
/** | ||
* @param segments Can contain 2 numeric values that will be used as first and last frame of the animation. | ||
* Or can contain a sequence of arrays each with 2 numeric values. | ||
* @param forceFlag If set to false, it will wait until the current segment is complete. If true, it will update values immediately. | ||
*/ | ||
playSegments(segments: any[], forceFlag?: boolean); | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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