Git Product home page Git Product logo

jsdaddy / ngx-loader-indicator Goto Github PK

View Code? Open in Web Editor NEW
51.0 5.0 5.0 7.92 MB

Awesome loader for angular applications. No wrappers only you elements

Home Page: https://jsdaddy.github.io/ngx-loader-indicator/

License: MIT License

JavaScript 0.45% TypeScript 70.94% HTML 15.07% SCSS 13.54%
typescript angular spiner loader website ngx-spiner ngx-loader loading-spinner loading spinner carousel

ngx-loader-indicator's Introduction

NGX LOADER INDICATOR is the best directive to have loader without wrapping your element to additional component

CI npm npm downloads

npm

GitHub contributors

GitHub stars

You can also try our NGX MASK check it. You can also try our NGX COPYPASTE check it.

You can try live demo with examples.

Installing

$ npm install --save ngx-loader-indicator

Quickstart if ngx-loader-indicator version >= 15.0.0

Pay attention this version works for angular >= 14.0.0

Configure for application with provideEnvironmentNgxLoaderIndicator

bootstrapApplication(AppComponent, {
    providers: [
        provideAnimations(),
        provideEnvironmentNgxLoaderIndicator(),
        (...)
    ],
}).catch((err) => console.error(err));

or configure for feature with provideNgxLoaderIndicator and import standalone directive NgxLoaderIndicatorDirective

@Component({
    selector: 'my-feature',
    templateUrl: './my-feature.component.html',
    styleUrls: ['./my-feature.component.css'],
    standalone: true,
    imports: [NgxLoaderIndicatorDirective, (...)],
    providers: [
        (...)
        provideNgxLoaderIndicator({
            img: 'https://avatars2.githubusercontent.com/u/32452610?s=200&v=4',
            loaderStyles: {
                background: 'rgba(255, 255, 255, 0.8)',
            },
            imgStyles: {
                width: '50px',
                background: 'yellow',
            },
            rotate: {
                duration: 5000,
            },
        }),
    ],
})
export class MyFeatureComponent {}

Quickstart if ngx-loader-indicator version < 15.0.0

Pay attention this version works for angular < 12.0.0

Import module in needed module.

import {NgxLoaderIndicatorModule} from 'ngx-loader-indicator'

(...)

@NgModule({
  (...)
  imports: [
    NgxLoaderIndicatorModule.forRoot(options)
  ]
  (...)
})

Usage

<div [loader]="isLoading">Content</div> 

Examples

<form (ngSubmit)="save(form.value)" [formGroup]="form" [loader]="isLoading">
  <h2>Login</h2>
  <input matInput type="email" placeholder="Email" #email formControlName="email">
  <input matInput type="password" placeholder="Password" #name formControlName="password">
  <button mat-button [disabled]="form.invalid">Login</button>
</form>

Options

You can define your custom options

custom img (string) and colors

  {
    img: string,
    imgStyles: {
      width: string, // '30px'
      background: string, // 'yellow' or rgb(255, 255, 0)
    }
  }

custom wrapper layout colors

  {
    loaderStyles: {
      background: string,
    },
  }

animations options for image rotation

    rotate: {
      delay?: number;
      direction?: 'normal' | 'reverse' | 'alternate' | 'alternate-reverse';
      duration: number
      easing?: string;
      endDelay?: number;
      fill?: 'none' | 'forwards' | 'backwards' | 'both' | 'auto';
      id?: string;
      iterationStart?: number;
      iterations?: number;
    },

Usage

import {NgxLoaderIndicatorModule} from 'ngx-loader-indicator'

(...)

@NgModule({
  (...)
  imports: [
    NgxLoaderIndicatorModule.forRoot({
      img: 'https://avatars2.githubusercontent.com/u/32452610?s=200&v=4',
      loaderStyles: {
        background: 'rgba(255, 255, 255, 0.8)',
      },
      imgStyles: {
        width: '100px',
        background: 'yellow',
      },
      rotate: {
        duration: 5000
      },
    }),
  ]
  (...)
})

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.