Skip to content

Commit a29f26d

Browse files
authored
Merge pull request #65 from t-ho/dev
fix(core): Be able to set minTime < 300ms
2 parents 8d8c0ba + 8cb97df commit a29f26d

File tree

9 files changed

+97
-99
lines changed

9 files changed

+97
-99
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
[![npm version](https://badge.fury.io/js/ngx-ui-loader.svg)](https://badge.fury.io/js/ngx-ui-loader)
1+
[![npm](https://img.shields.io/npm/v/ngx-ui-loader)](https://www.npmjs.com/package/ngx-ui-loader)
2+
[![GitHub stars](https://img.shields.io/github/stars/t-ho/ngx-ui-loader?color=00bcd4)](https://github.com/t-ho/ngx-ui-loader/stargazers)
23
[![demo](https://img.shields.io/badge/demo-StackBlitz-blueviolet.svg)](https://stackblitz.com/edit/ngx-ui-loader)
34
[![Build Status](https://travis-ci.org/t-ho/ngx-ui-loader.svg?branch=master)](https://travis-ci.org/t-ho/ngx-ui-loader)
45
[![codecov](https://codecov.io/gh/t-ho/ngx-ui-loader/branch/master/graph/badge.svg)](https://codecov.io/gh/t-ho/ngx-ui-loader)

package-lock.json

+58-66
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@
1515
"private": true,
1616
"dependencies": {
1717
"@angular/animations": "~9.0.4",
18-
"@angular/cdk": "~9.1.0",
18+
"@angular/cdk": "^9.1.3",
1919
"@angular/common": "~9.0.4",
2020
"@angular/compiler": "~9.0.4",
2121
"@angular/core": "~9.0.4",
2222
"@angular/flex-layout": "^9.0.0-beta.29",
2323
"@angular/forms": "~9.0.4",
24-
"@angular/material": "^9.1.0",
24+
"@angular/material": "^9.1.3",
2525
"@angular/platform-browser": "~9.0.4",
2626
"@angular/platform-browser-dynamic": "~9.0.4",
2727
"@angular/router": "~9.0.4",
2828
"@schuchard/prettier": "^3.1.0",
2929
"ngx-color-picker": "^9.0.0",
3030
"rxjs": "~6.5.4",
3131
"tslib": "^1.10.0",
32-
"zone.js": "~0.10.2"
32+
"zone.js": "~0.10.3"
3333
},
3434
"devDependencies": {
3535
"@angular-devkit/build-angular": "~0.900.4",
@@ -39,7 +39,7 @@
3939
"@angular/language-service": "~9.0.4",
4040
"@types/jasmine": "~3.5.0",
4141
"@types/jasminewd2": "~2.0.3",
42-
"@types/node": "^12.11.1",
42+
"@types/node": "^12.12.30",
4343
"codelyzer": "^5.1.2",
4444
"husky": "^4.2.3",
4545
"jasmine-core": "~3.5.0",

projects/ngx-ui-loader/src/lib/core/ngx-ui-loader.service.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const FOREGROUND = true;
1717
const IS_BOUND = true;
1818
const IS_MASTER = true;
1919
const LOADER_ID_01 = 'loader-id-01';
20-
const MIN_TIME = 300;
20+
const MIN_TIME = 0;
2121
const MAX_TIME = 8000;
2222
const NOT_EXISTING_LOADER_ID = 'not-existing-loader-id';
2323
const NOT_EXISTING_TASK_ID = 'not-existing-task-id';
@@ -927,7 +927,7 @@ describe(`NgxUiLoaderService (loaderId == ${DEFAULT_MASTER_LOADER_ID})`, () => {
927927
}).not.toThrowError(`[ngx-ui-loader] - taskId "${DUPLICATED_TASK_ID}" is duplicated.`);
928928
});
929929

930-
it(`#check duplicate task id - 2 - should not throw any error`, () => {
930+
it(`#check duplicate task id - 2 - should throw an error`, () => {
931931
loaderService.startBackgroundLoader(DEFAULT_MASTER_LOADER_ID, DUPLICATED_TASK_ID);
932932
expect(() => {
933933
loaderService.startLoader(DEFAULT_MASTER_LOADER_ID, DUPLICATED_TASK_ID);
@@ -941,7 +941,7 @@ describe(`NgxUiLoaderService (loaderId == ${DEFAULT_MASTER_LOADER_ID})`, () => {
941941
}).not.toThrowError(`[ngx-ui-loader] - taskId "${DUPLICATED_TASK_ID}" is duplicated.`);
942942
});
943943

944-
it(`#check duplicate task id - 4 - should not throw any error`, () => {
944+
it(`#check duplicate task id - 4 - should throw an error`, () => {
945945
loaderService.startBackground(DUPLICATED_TASK_ID);
946946
expect(() => {
947947
loaderService.start(DUPLICATED_TASK_ID);

projects/ngx-ui-loader/src/lib/core/ngx-ui-loader.service.ts

+4-12
Original file line numberDiff line numberDiff line change
@@ -330,15 +330,9 @@ export class NgxUiLoaderService {
330330
* @docs-private
331331
*/
332332
private clearTimers(task: Task): void {
333-
if (task.delayTimer) {
334-
clearTimeout(task.delayTimer);
335-
}
336-
if (task.maxTimer) {
337-
clearTimeout(task.maxTimer);
338-
}
339-
if (task.minTimer) {
340-
clearTimeout(task.minTimer);
341-
}
333+
clearTimeout(task.delayTimer);
334+
clearTimeout(task.maxTimer);
335+
clearTimeout(task.minTimer);
342336
}
343337

344338
/**
@@ -465,9 +459,7 @@ export class NgxUiLoaderService {
465459
private setMaxTimer(task: Task, loaderId: string): void {
466460
if (task.maxTime > task.minTime) {
467461
// restart the task, reset maxTimer
468-
if (task.maxTimer) {
469-
clearTimeout(task.maxTimer);
470-
}
462+
clearTimeout(task.maxTimer);
471463
task.maxTimer = setTimeout(() => {
472464
if (task.isForeground) {
473465
this.stopLoader(loaderId, task.taskId);

projects/ngx-ui-loader/src/lib/utils/constants.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const DEFAULT_TIME: Time = {};
2020

2121
export const MIN_DELAY = 0;
2222

23-
export const MIN_TIME = 300;
23+
export const MIN_TIME = 0;
2424

2525
export const CLOSING_TIME = 1001;
2626

@@ -169,5 +169,5 @@ export const DEFAULT_CONFIG: NgxUiLoaderConfig = {
169169
textColor: '#FFFFFF',
170170
textPosition: POSITION.centerCenter,
171171
maxTime: -1,
172-
minTime: 500
172+
minTime: 300
173173
};

0 commit comments

Comments
 (0)