Home

Awesome

NgxFadeComponent

<a href="https://ngxui.com" target="_blank" style="display: flex;gap: .5rem;align-items: center;cursor: pointer; padding: 0 0 0 0; height: fit-content;"> <img src="https://ngxui.com/assets/img/ngxui-logo.png" style="width: 64px;height: 64px;"> </a>

This Library is part of the NGXUI ecosystem. <br> View all available components at https://ngxui.com

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.