Home

Awesome

NgxFadeComponent

The NgxFadeComponent is a versatile Angular component that provides a smooth fading and sliding effect for its content as it enters or leaves the viewport. This component uses the IntersectionObserver API to detect when the component is in view and apply the defined transition effects. It's fully customizable with different transition directions, durations, and easing functions.

Features

Installation

Install the component via npm:

npm install @omnedia/ngx-fade

Usage

Import the NgxFadeComponent in your module or component:

import { NgxFadeComponent } from '@omnedia/ngx-fade';

@Component({
  ...
  imports: [
    NgxFadeComponent,
    ...
  ],
  ...
})
export class YourComponent {}

Add the component to your template:

<om-fade [direction]="'up'" [transitionDuration]="'1s'" [transitionFunction]="'ease-out'">
  <p>Fading content from the bottom</p>
</om-fade>

Inputs

Custom Transforms

If you want more control over how the element is transformed, you can use the customTransform input, which allows you to specify any CSS transform, such as rotating or scaling the element. This input overrides the direction setting.

<om-fade [customTransform]="'rotate(45deg)'" [transitionDuration]="'1s'">
  <p>Custom rotated content</p>
</om-fade>

In this example, instead of sliding the content in from a direction, it will appear with a 45-degree rotation.

Example

<om-fade [direction]="'left'" [transitionDuration]="'2s'" [transitionFunction]="'ease-in'">
    <h2>Fading In from Left</h2>
</om-fade>
<om-fade [customTransform]="'scale(0.5)'" [transitionDuration]="'1.5s'">
  <h2>Custom Scaling Effect</h2>
</om-fade>

How It Works

Contributing

Contributions are welcome! Please submit a pull request or open an issue to discuss your ideas.

License

This project is licensed under the MIT License.