ngx-loading-fork 17.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +23 -0
- package/README.md +180 -0
- package/esm2022/lib/ngx-loading-config.mjs +25 -0
- package/esm2022/lib/ngx-loading.component.mjs +427 -0
- package/esm2022/lib/ngx-loading.module.mjs +24 -0
- package/esm2022/lib/ngx-loading.service.mjs +23 -0
- package/esm2022/ngx-loading-fork.mjs +5 -0
- package/esm2022/public-api.mjs +8 -0
- package/fesm2022/ngx-loading-fork.mjs +502 -0
- package/fesm2022/ngx-loading-fork.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/ngx-loading-config.d.ts +34 -0
- package/lib/ngx-loading.component.d.ts +29 -0
- package/lib/ngx-loading.module.d.ts +11 -0
- package/lib/ngx-loading.service.d.ts +9 -0
- package/package.json +64 -0
- package/public-api.d.ts +4 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright 2024
|
|
4
|
+
|
|
5
|
+
Original author: Z.C
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
# ngx-loading
|
|
2
|
+
|
|
3
|
+
A customisable loading spinner for Angular applications.
|
|
4
|
+
|
|
5
|
+
[](https://badge.fury.io/js/ngx-loading)
|
|
6
|
+
[]()
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
## Table of contents
|
|
12
|
+
|
|
13
|
+
1. [Demo](#demo)
|
|
14
|
+
2. [Installation](#installation)
|
|
15
|
+
3. [Getting started](#getting-started)
|
|
16
|
+
4. [Input parameters](#input-parameters)
|
|
17
|
+
5. [Config options](#config-options)
|
|
18
|
+
|
|
19
|
+
## Demo
|
|
20
|
+
|
|
21
|
+
Check out the interactive demo on [StackBlitz](https://stackblitz.com/edit/ngx-loading-sample?file=src/app/app.component.html "ngx-loading StackBlitz demo").
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
Install ngx-loading via NPM, using the command below.
|
|
26
|
+
|
|
27
|
+
### NPM
|
|
28
|
+
|
|
29
|
+
```shell
|
|
30
|
+
npm install --save ngx-loading
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
NOTE: Version 17 of this package requires Angular 17 as a dependency. If you are using an older version of Angular, please install the relevant version e.g. 2.0.1 for Angular 2:
|
|
34
|
+
|
|
35
|
+
```shell
|
|
36
|
+
npm install --save ngx-loading@2.0.1
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Getting started
|
|
40
|
+
|
|
41
|
+
Import the `NgxLoadingModule` in your root application module:
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { BrowserModule } from "@angular/platform-browser";
|
|
45
|
+
import { NgModule } from "@angular/core";
|
|
46
|
+
import { CoreModule } from "./core/core.module";
|
|
47
|
+
import { NgxLoadingModule } from "ngx-loading";
|
|
48
|
+
|
|
49
|
+
@NgModule({
|
|
50
|
+
//...
|
|
51
|
+
imports: [
|
|
52
|
+
//...
|
|
53
|
+
NgxLoadingModule.forRoot({}),
|
|
54
|
+
],
|
|
55
|
+
//...
|
|
56
|
+
})
|
|
57
|
+
export class AppModule {}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
You must create a boolean variable (e.g. `loading` below) that is accessible from the component which will contain ngx-loading. This boolean is used as an input into ngx-loading, and will determine when the loading spinner is visible.
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
import { Component, OnInit } from "@angular/core";
|
|
64
|
+
|
|
65
|
+
@Component({
|
|
66
|
+
//...
|
|
67
|
+
})
|
|
68
|
+
export class AppComponent implements OnInit {
|
|
69
|
+
//...
|
|
70
|
+
public loading = false;
|
|
71
|
+
|
|
72
|
+
constructor(private authService: AuthService) {}
|
|
73
|
+
|
|
74
|
+
ngOnInit() {}
|
|
75
|
+
|
|
76
|
+
Login() {
|
|
77
|
+
this.loading = true;
|
|
78
|
+
this.authService.login(this.email, this.password).subscribe(
|
|
79
|
+
(res) => {
|
|
80
|
+
this.loading = false;
|
|
81
|
+
//...
|
|
82
|
+
},
|
|
83
|
+
(err) => {
|
|
84
|
+
this.loading = false;
|
|
85
|
+
//...
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Next, add the ngx-loading component selector to your application component's template. Set the `[show]` input variable of ngx-loading to point to your boolean, which will determine when ngx-loading is visible. Optionally set the `[config]` input variable of ngx-loading to setup custom configuration options. If the `[config]` input variable is not set, the globally configured configuration will be used, if set. If no config options are set, the ngx-loading default config options will be used. See [Config options](#config-options) for further information.
|
|
93
|
+
|
|
94
|
+
You can also optionally define a `[template]` input variable, which can be used to inject your own custom templates into the component.
|
|
95
|
+
|
|
96
|
+
NOTE: ngx-loading will fill the entirety of its parent component. If you wish for ngx-loading to only fill a specific element within your component, ensure that ngx-loading is a child element of that element, and that the containing element has its `position` attribute set to `relative`.
|
|
97
|
+
|
|
98
|
+
```html
|
|
99
|
+
<div class="my-container">
|
|
100
|
+
<ng-template #customLoadingTemplate>
|
|
101
|
+
<div class="custom-class">
|
|
102
|
+
<h3>Loading...</h3>
|
|
103
|
+
<button (click)="showAlert()">Click me!</button>
|
|
104
|
+
</div>
|
|
105
|
+
</ng-template>
|
|
106
|
+
|
|
107
|
+
<ngx-loading
|
|
108
|
+
[show]="loading"
|
|
109
|
+
[config]="{ backdropBorderRadius: '3px' }"
|
|
110
|
+
[template]="customLoadingTemplate"
|
|
111
|
+
></ngx-loading>
|
|
112
|
+
//...
|
|
113
|
+
</div>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Input parameters
|
|
117
|
+
|
|
118
|
+
| Input | Required | Details |
|
|
119
|
+
| -------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
120
|
+
| show | Required | A boolean, which will determine when ngx-loading is visible. |
|
|
121
|
+
| config | Optional | A set of configuration options for ngx-loading. If this is not specified, the globally configured configuration will be used, if set. If no config options are set, the ngx-loading default config options will be used. See [Config options](#config-options). |
|
|
122
|
+
| template | Optional | A TemplateRef, which will be displayed within the ngx-loading component. Use this to inject your own custom templates into the component. |
|
|
123
|
+
|
|
124
|
+
## Config options
|
|
125
|
+
|
|
126
|
+
| Option | Required | Default | Details |
|
|
127
|
+
| ------------------------ | -------- | ------------------------------------ | --------------------------------------------------------------------------------------------------------------- |
|
|
128
|
+
| animationType | Optional | ngxLoadingAnimationTypes.threeBounce | The animation to be used within ngx-loading. Use the ngxLoadingAnimationTypes constant to select valid options. |
|
|
129
|
+
| backdropBorderRadius | Optional | 0 | The border-radius to be applied to the ngx-loading backdrop, e.g. '14px'. |
|
|
130
|
+
| backdropBackgroundColour | Optional | rgba(0, 0, 0, 0.3) | The background-color to be applied to the ngx-loading backdrop, e.g. 'rgba(255, 255, 255, 0.2)'. |
|
|
131
|
+
| fullScreenBackdrop | Optional | false | Set to true to make the backdrop full screen, with the loading animation centered in the middle of the screen. |
|
|
132
|
+
| primaryColour | Optional | #ffffff | The primary colour, which will be applied to the ngx-loading animation. |
|
|
133
|
+
| secondaryColour | Optional | #ffffff | The secondary colour, which will be applied to the ngx-loading animation (where appropriate). |
|
|
134
|
+
| tertiaryColour | Optional | #ffffff | The tertiary colour, which will be applied to the ngx-loading animation (where appropriate). |
|
|
135
|
+
|
|
136
|
+
Config options can be set globally (using the `.forRoot() module import statement`), as well as being passed into each ngx-loading instance, if required. Config options that are passed into an ngx-loading element will override any custom global config options that have been set. A combination of the two can be used together if appropriate. If no config is set, the default ngx-loading config options will be used. Please see below for an example custom configuration setup, using both global and local configurations.
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
import { BrowserModule } from "@angular/platform-browser";
|
|
140
|
+
import { NgModule } from "@angular/core";
|
|
141
|
+
import { CoreModule } from "./core/core.module";
|
|
142
|
+
import { NgxLoadingModule, ngxLoadingAnimationTypes } from "ngx-loading";
|
|
143
|
+
|
|
144
|
+
@NgModule({
|
|
145
|
+
//...
|
|
146
|
+
imports: [
|
|
147
|
+
//...
|
|
148
|
+
NgxLoadingModule.forRoot({
|
|
149
|
+
animationType: ngxLoadingAnimationTypes.wanderingCubes,
|
|
150
|
+
backdropBackgroundColour: "rgba(0,0,0,0.1)",
|
|
151
|
+
backdropBorderRadius: "4px",
|
|
152
|
+
primaryColour: "#ffffff",
|
|
153
|
+
secondaryColour: "#ffffff",
|
|
154
|
+
tertiaryColour: "#ffffff",
|
|
155
|
+
}),
|
|
156
|
+
],
|
|
157
|
+
//...
|
|
158
|
+
})
|
|
159
|
+
export class AppModule {}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
```html
|
|
163
|
+
<div class="my-container">
|
|
164
|
+
<ng-template #customLoadingTemplate>
|
|
165
|
+
<div class="custom-class">
|
|
166
|
+
<h3>Loading...</h3>
|
|
167
|
+
<button (click)="showAlert()">Click me!</button>
|
|
168
|
+
</div>
|
|
169
|
+
</ng-template>
|
|
170
|
+
|
|
171
|
+
<ngx-loading
|
|
172
|
+
[show]="loading"
|
|
173
|
+
[config]="{ animationType: ngxLoadingAnimationTypes.rectangleBounce,
|
|
174
|
+
backdropBackgroundColour: 'rgba(255,255,255,0.3)', backdropBorderRadius: '10px',
|
|
175
|
+
primaryColour: '#ffffff', secondaryColour: '#ffffff', tertiaryColour: '#ffffff' }"
|
|
176
|
+
[template]="customLoadingTemplate"
|
|
177
|
+
></ngx-loading>
|
|
178
|
+
//...
|
|
179
|
+
</div>
|
|
180
|
+
```
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export class NgxLoadingConfig {
|
|
2
|
+
constructor(config = {}) {
|
|
3
|
+
this.backdropBorderRadius = config.backdropBorderRadius;
|
|
4
|
+
this.backdropBackgroundColour = config.backdropBackgroundColour;
|
|
5
|
+
this.fullScreenBackdrop = config.fullScreenBackdrop;
|
|
6
|
+
this.animationType = config.animationType;
|
|
7
|
+
this.primaryColour = config.primaryColour;
|
|
8
|
+
this.secondaryColour = config.secondaryColour;
|
|
9
|
+
this.tertiaryColour = config.tertiaryColour;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export const ngxLoadingAnimationTypes = {
|
|
13
|
+
chasingDots: 'chasing-dots',
|
|
14
|
+
circle: 'sk-circle',
|
|
15
|
+
circleSwish: 'circleSwish',
|
|
16
|
+
cubeGrid: 'sk-cube-grid',
|
|
17
|
+
doubleBounce: 'double-bounce',
|
|
18
|
+
none: 'none',
|
|
19
|
+
pulse: 'pulse',
|
|
20
|
+
rectangleBounce: 'rectangle-bounce',
|
|
21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