1.1.3 • Published 2 months ago

ngx-scroll-animations v1.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

npm version NPM monthly downloads NPM total downloads License: MIT Issues Web Demo

Table of contents

This minimalistic Angular directive, free from external dependencies, empowers you to effortlessly implement CSS animations on elements. These animations trigger when an element comes into view through scrolling on the page. It seamlessly integrates with your choice of CSS animations.

Installation

npm install ngx-scroll-animations

Optionally include prebuilt animations

/* angular-cli file: src/styles.css */
@import "node_modules/ngx-scroll-animations/styles/animations.min.css";

Standalone component

import { Component } from '@angular/core';
import { NgxScrollAnimationsModule } from 'ngx-scroll-animations';

@Component({
  selector: 'app-root',
  standalone: true,
  templateUrl: './app.component.html',
  styleUrl: './app.component.scss',
  imports: [ NgxScrollAnimationsModule ],
})
export class AppComponent {}

Or for Module

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';

import { NgxScrollAnimationsModule } from 'ngx-scroll-animations';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    NgxScrollAnimationsModule,
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

Inputs

OptionTypeDefaultComment
ngxScrollAnimatestringfade-in-upName of the animation (as example 'fade-in')
easingstringeaseDefines how the animation accelerates and decelerates during its runtime.
speednumber300The speed at which the animation runs in milliseconds.
delaynumber0Delays the start of the animation. Accepts the delay time in milliseconds.
aosnumber0.8 (when thresholdMode is set to 'pixel', the value is 20)The threshold for triggering the animation when an element scrolls into the viewport.
thresholdMode'percent' / 'pixel'percentDefines the mode for calculating the threshold: 'percent' or 'pixel'.
oncebooleantrueIf true, triggers the animation only once when the element scrolls into the viewport.
disabledbooleanfalseA boolean value to enable or disable the animation.

Outputs

OptionTypeComment
startAnimationEventEmitterEmits an event at the start of the animation.
endAnimationEventEmitterEmits an event at the end of the animation.

Prebuild animations

  • 'fade-in'
  • 'fade-in-right'
  • 'fade-in-left'
  • 'fade-in-up'
  • 'fade-in-up-scale'
  • 'fade-in-down'
  • 'slide-in-up'
  • 'scale-in'
  • 'bounce'
  • 'rotate'

Simple example

<img
  ngxScrollAnimate
  src="https://picsum.photos/300"
  alt="demo-image"
/>

Complete example demonstrating all properties

<img
  ngxScrollAnimate="fade-in-up"
  easing="ease"
  speed="300"
  delay="0"
  aos="0.8"
  thresholdMode="percent"
  once="true"
  disabled="false"
  (endAnimation)="endAnimation()"
  (startAnimation)="startAnimation()"
  src="https://picsum.photos/300"
  alt="demo-image"
/>

Custom animation

@keyframes my-special-animation {
    from {
        opacity: 0;
        background: red;
    }
    to {
        opacity: 1;
        background: blue;
    }
}
<img
  ngxScrollAnimate="my-special-animation"
  src="https://picsum.photos/300"
  speed="2000"
  alt="demo-image"
/>

Contributing

I welcome contributions from the open-source community to make this project even better. Whether you want to report a bug, suggest a new feature, or contribute code, I appreciate your help.

Bug Reports and Feature Requests

If you encounter a bug or have an idea for a new feature, please open an issue on my GitHub Issues page. I will review it and discuss the best approach to address it.

Code Contributions

If you'd like to contribute code to this project, please follow these steps:

  1. Fork the repository to your GitHub account.
  2. Clone your forked repository to your local machine.
git clone https://github.com/hm21/ngx-scroll-animations.git
1.1.3

2 months ago

1.1.2

2 months ago

1.1.1

3 months ago

1.1.0

3 months ago

1.0.9

4 months ago

1.0.8

4 months ago

1.0.7

4 months ago

1.0.6

5 months ago

1.0.5

5 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago