All Projects β†’ maximelafarie β†’ ngx-smart-loader

maximelafarie / ngx-smart-loader

Licence: MIT License
Smart loader handler to manage loaders everywhere in Angular apps.

Programming Languages

typescript
32286 projects
HTML
75241 projects
CSS
56736 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to ngx-smart-loader

Ngx Smart Modal
Modal/Dialog component crafted for Angular
Stars: ✭ 256 (+814.29%)
Mutual labels:  yarn, angular2, npm-package, angular4, angular-cli, angular5
Nebular
πŸ’₯ Customizable Angular UI Library based on Eva Design System 🌚✨Dark Mode
Stars: ✭ 7,368 (+26214.29%)
Mutual labels:  angular2, angular4, angular-cli, angular5
AuthGuard
Example repo for guarding routes post
Stars: ✭ 42 (+50%)
Mutual labels:  angular2, angular4, angular-cli, angular5
Angular4-seed
Angular 4 Seed for Angular Forms
Stars: ✭ 37 (+32.14%)
Mutual labels:  angular2, angular4, angular-cli, angular5
Ng Http Loader
🍑 Smart angular HTTP interceptor - Intercepts automagically HTTP requests and shows a spinkit spinner / loader / progress bar
Stars: ✭ 327 (+1067.86%)
Mutual labels:  angular2, loader, angular4, angular5
Angular5 Seed
Angular5 Seed for Application
Stars: ✭ 222 (+692.86%)
Mutual labels:  angular2, angular4, angular-cli, angular5
Angular2
Angular 2 Seed
Stars: ✭ 75 (+167.86%)
Mutual labels:  angular2, angular4, angular-cli, angular5
Angular File Uploader
Angular file uploader is an Angular 2/4/5/6/7/8/9/10 + file uploader module with Real-Time Progress Bar, Responsive design, Angular Universal Compatibility, localization and multiple themes which includes Drag and Drop and much more.
Stars: ✭ 92 (+228.57%)
Mutual labels:  angular2, npm-package, angular4, angular5
ncg-crud-ngx-md
Angular 4+ Material Design CRUD/Admin app by NinjaCodeGen http://DNAfor.NET
Stars: ✭ 36 (+28.57%)
Mutual labels:  angular2, angular4, angular-cli
ngx-redux-core
The modern redux integration for Angular 6+
Stars: ✭ 32 (+14.29%)
Mutual labels:  angular2, angular4, angular5
laravel5Angular4
Laravel 5.4 & Angular 4.3.4
Stars: ✭ 37 (+32.14%)
Mutual labels:  angular2, angular4, angular-cli
spring-websocket-angular6
Example for using Spring Websocket and Angular with Stomp Messaging
Stars: ✭ 18 (-35.71%)
Mutual labels:  angular2, angular4, angular5
ng2-timezone-selector
A simple Angular module to create a timezone selector using moment-timezone.
Stars: ✭ 12 (-57.14%)
Mutual labels:  angular2, angular4, angular5
Ng Select
⭐ Native angular select component
Stars: ✭ 2,781 (+9832.14%)
Mutual labels:  angular2, angular4, angular5
Ng Drag Drop
Drag & Drop for Angular - based on HTML5 with no external dependencies. πŸŽ‰
Stars: ✭ 233 (+732.14%)
Mutual labels:  angular2, angular4, angular5
Angular4 Docker Example
Efficiently Dockerized Angular CLI example app
Stars: ✭ 212 (+657.14%)
Mutual labels:  angular2, angular4, angular-cli
angular-progress-bar
This component allow you to easy incorporate progress-bar to angular/ionic project, providing binding and color options
Stars: ✭ 26 (-7.14%)
Mutual labels:  angular2, angular4, angular5
ngx-loader-indicator
Awesome loader for angular applications. No wrappers only you elements
Stars: ✭ 44 (+57.14%)
Mutual labels:  loader, loading, ngx-loader
ionic-modal-custom-transitions
Add Custom Transitions to Ionic Modals.
Stars: ✭ 22 (-21.43%)
Mutual labels:  angular2, angular4, angular5
angular-rollbar-source-maps
Angular 2+ implementation to upload sourcemaps to Rollbar
Stars: ✭ 17 (-39.29%)
Mutual labels:  angular2, angular4, angular5

ngx-smart-loader

Greenkeeper badge Build Status npm version npm downloads codecov Codacy Badge

ngx-smart-loader is a lightweight and very complete Angular component for managing loaders inside any Angular project. It was built for modern browsers using TypeScript, HTML5 and Angular >=2.0.0.

Demo

https://maximelafarie.com/ngx-smart-loader/

Powerful and so easy to use! πŸ€™

Managing loaders has always been a big deal, mostly if you want to manage several loaders at the same time. With this library, it has never been so easy to do: a complete API to manage absolutely everything in your app.

ngx-smart-loader also comes with a fancy default loader (demo default page's loader) in case you don't want to add your own.

Check out the documentation & demos for more information and tutorials!

See the changelog for recent changes.

Features

  • Handle large quantity of loaders anywhere in your app
  • Customize the style of your loaders through custom CSS classes
  • No external CSS library is used so you can easily add yours
  • Manipulate groups of loader at the same time
  • Events on start and stop for each loader
  • Manage all your loaders stack with very fast methods
  • Very smart z-index computation
  • Check for loader(s) activity
  • AoT compilation support

Setup

To use ngx-smart-loader in your project install it via npm:

npm i ngx-smart-loader --save

or

yarn add ngx-smart-loader

Then add NgxSmartLoaderModule (with .forRoot() or .forChild() depending if the module which you import the library into is the main module of your project or a nested module) and NgxSmartLoaderService to your project's NgModule

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { NgxSmartLoaderModule, NgxSmartLoaderService } from 'ngx-smart-loader';

import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    NgxSmartLoaderModule.forRoot()
  ],
  providers: [ NgxSmartLoaderService ],
  bootstrap: [ AppComponent ]
})
export class AppModule { }

And import ngx-smart-loader.scss or ngx-smart-loader.css in a global style file (e.g. styles.scss or styles.css in classic Angular projects or any other scss/css file it imports): Example with styles.scss:

/* You can add global styles to this file, and also import other style files */
@import "~ngx-smart-loader/ngx-smart-loader";
@import "app/app.component";
...

Parameters / Options

ngx-smart-loader comes with some parameters / options in order to make it fit your needs. The following parameters / options needs to be used like this: <ngx-smart-loader [parameter-or-option-name]="value"></ngx-smart-loader>

The below documentation will use the following pattern:

parameter/option name (type) | default value | required? ― description

  • identifier (string) | undefined | REQUIRED ― The identifiant of the loader instance. Retrieve a loader easily by its identifier.

  • force (boolean) | false ― If true and if you declare another loader instance with the same identifier that another, the service will override it by the new you declare in the loader stack. By default, it allows you to declare multiple loaders with same identifier in order to manipulate them at once.

  • customClass (string) | '' ― All the additional classes you want to add to the loader (e.g.: for your custom loaders). You can add several classes by giving a string with space-separated classnames

  • delayIn (number) | 0 ― In milliseconds. Define the time after which you want to display your loader. The .active class only append to loader after this time. The .enter class append to the loader instantly and disappears after this delay.

  • delayOut (number) | 0 ― In milliseconds. Define the time after which you want to hide your loader. The .active class only disappears from the loader after this time. The .leave class append to the loader instantly and disappears after this delay.

Manipulate loaders

First, you need to add a loader to any template at any level in your app (all examples will use the default library built-in loader).

<ngx-smart-loader identifier="myLoader">
  <div class="loader">
    <div class="circle"></div>
  </div>
</ngx-smart-loader>

At this point, the loader instance is stored in the NgxSmartLoaderService. You can do absolutely what you want with it, anywhere in your app. For example, from a component (here we're starting the loader automatically after one second):

import { Component, OnInit } from '@angular/core';

import { NgxSmartLoaderService } from 'ngx-smart-loader';

@Component({
  ...
})
export class HomeComponent implements OnInit {

  constructor(public loader: NgxSmartLoaderService) {
  }

  ngOnInit() {
    this.loader.start('myLoader');
  }
}

Http calls

Following the same example as above, you can use the NgxSmartLoaderService to start a loader. Here's a more concrete example:

Let's imagine you have a function that makes an Http request to retrieve a user list (this example uses the rxjs Observable. This is an example, you need to adapt it to your needs):

public users: User[] = [];

getUsers (): User[] {
  this.loader.start('myLoader');
  return this.http.get<User[]>('api/v2/users')
    .subscribe(
      users => this.users = users,
      err => console.error('something wrong occurred: ' + err),
      () => this.loader.stop('myLoader');
    );
}

As you can see above, we're starting the loader before Http request. Then in the subscribe() we're stopping when the request finished.

Handle events

ngx-smart-loader comes with built-in events: onStart, onStop and onVisibleChange.

  • onStart: loader has been opened
  • onStop: loader has been closed
  • onVisibleChange: loader has been opened or closed

You can handle events directly from the view...

<ngx-smart-loader identifier="myLoader" (onStart)="onStart($event)" (onStop)="onStop($event)" (onVisibleChange)="onVisibleChange($event)">
  <div class="loader">
    <div class="circle"></div>
  </div>
</ngx-smart-loader>

...and execute component functions:

@Component({
  ...
})
export class AppComponent {
  constructor() {
  }

  public onStart(event) {
  }

  public onStop(event) {
  }

  public onVisibleChange(event) {
  }
}

Contribute

Firstly fork this repo, then clone it and go inside the root of the freshly forked project. ng serve to start the angular-cli demo. To modify the package, go into ./src/ngx-smart-loader and do some code! πŸ€“ When you finished commit and push it to your fork repo, make a PR! Thank you for your support, you rock! 🀘🎸

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].