ngx-teximate
Version:
Angular text animations component
154 lines (114 loc) • 5.4 kB
Markdown
<p align="center">
<img height="150px" width="150px" style="text-align: center;" src="https://cdn.rawgit.com/MurhafSousli/ng-teximate/9acbe5dd/assets/logo.svg">
<h1 align="center">Angular text animation plugin</h1>
</p>
[](https://murhafsousli.github.io/ngx-teximate)
[](https://www.npmjs.com/package/ngx-teximate)
[](https://travis-ci.org/MurhafSousli/ngx-teximate)
[](https://www.npmjs.com/package/ngx-teximate)
[](https://bundlephobia.com/result?p=ngx-teximate)
[](https://github.com/MurhafSousli/ngx-teximate/blob/master/LICENSE)
___
A text animation plugin built on top of Angular animation engine
## Installation
**NPM**
```
npm install -S ngx-teximate ng-animate
```
**YARN**
```
yarn add ngx-teximate ng-animate
```
> **NOTE:** `ng-animate` package is just a collection of reusable animations and it is not required for Teximate to work
## Usage
Import **TeximateModule** in your root module
```ts
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { TeximateModule } from 'ngx-teximate';
```
1. Add `<teximate>` component into your template
2. Create a `TextAnimation` object and pass it to on of these inputs `[enter]` `[leave]` `[animation]`.
3. Pick the animation you like from `ng-animate` and set it in the `TextAnimation` object
#### Example:
```ts
import { Component } from '@angular/core';
import { TextAnimation } from 'ngx-teximate';
import { fadeInDown } from 'ng-animate';
export class AppComponent {
text = 'Lorem ipsum dolor sit amet.';
enterAnimation: TextAnimation = {
animation: fadeInDown,
delay: 50,
type: 'letter'
};
}
```
There are 3 main animations inputs `[enter]`, `[leave]` and `[animation]`, but you can still register more animations
#### Example:
```ts
import { Component, ViewChild, AfterViewInit } from '@angular/core';
import { TextAnimation } from 'ngx-teximate';
import { fadeInDown } from 'ng-animate';
export class AppComponent implements AfterViewInit {
: teximate: Teximate;
text = 'Lorem ipsum dolor sit amet.';
ngAfterViewInit() {
const customAnimation: TextAnimation = {
id: 'custom',
animation: fadeInDown,
delay: 50,
type: 'letter'
};
this.teximate.registerAnimation(customAnimation);
}
play() {
if (this.teximate.players.has('custom')) {
this.teximate.players.get('custom').play();
}
}
}
```
## API
| Name | type | Description |
| ------------------------ |-------------- | ---------------------------------------------------------------- |
| **[text]** | string | Text to animate |
| **[animation]** | TextAnimation | Default animation, played using `teximate.defaultPlayer.play()` |
| **[enter]** | TextAnimation | Enter animation, played on init |
| **[leave]** | TextAnimation | Leave animation, played on destroy (WIP) |
| **(play)** | string | Stream that emits when text animation is played |
| **(finish)** | string | Stream that emits when text animation is finished |
| **(paragraphClick)** | MouseEvent | Stream that emits when a paragraph is clicked |
| **(wordClick)** | MouseEvent | Stream that emits when a word is clicked |
| **(letterClick)** | MouseEvent | Stream that emits when a letter is clicked |
| **(paragraphHover)** | MouseEvent | Stream that emits when a paragraph is hovered |
| **(wordHover)** | MouseEvent | Stream that emits when a word is hovered |
| **(letterHover)** | MouseEvent | Stream that emits when a letter is hovered |
See the [stackblitz demo](https://stackblitz.com/edit/ngx-teximate).
## Issues
If you identify any errors in this module, or have an idea for an improvement, please open an [issue](https://github.com/MurhafSousli/ngx-teximate/issues).
## Support
Please give **Teximate** a :star:
[](https://www.patreon.com/bePatron?u=5594898)
## Author
**Murhaf Sousli**
- [github/murhafsousli](https://github.com/MurhafSousli)
- [twitter/murhafsousli](https://twitter.com/MurhafSousli)