Skip to content

Commit d70cc42

Browse files
authored
fix: fix done value is 0 of fractional seconds (#86)
1 parent 7fa4ecd commit d70cc42

File tree

6 files changed

+32
-46
lines changed

6 files changed

+32
-46
lines changed

lib/src/countdown.component.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import { CountdownGlobalConfig } from './countdown.config';
3535
})
3636
export class CountdownComponent implements OnInit, OnChanges, OnDestroy {
3737
private frequency = 1000;
38-
private _notify: any = {};
38+
private _notify: { [key: number]: boolean } = {};
3939
private status: CountdownStatus = CountdownStatus.ing;
4040
private isDestroy = false;
4141
i: CountdownItem = {};
@@ -162,7 +162,10 @@ export class CountdownComponent implements OnInit, OnChanges, OnDestroy {
162162
return;
163163
}
164164

165-
const value = (this.left = this.left - this.frequency * count);
165+
let value = (this.left = this.left - this.frequency * count);
166+
if (value < 1) {
167+
value = 0;
168+
}
166169
this.i = {
167170
value,
168171
text: config.formatDate({ date: value, formatStr: config.format, timezone: config.timezone }),
@@ -178,7 +181,7 @@ export class CountdownComponent implements OnInit, OnChanges, OnDestroy {
178181
});
179182
}
180183

181-
if (value < 1) {
184+
if (value === 0) {
182185
this.ngZone.run(() => {
183186
this.status = CountdownStatus.done;
184187
this.callEvent('done');

lib/tsconfig.lib.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "../tsconfig.base.json",
2+
"extends": "../tsconfig.json",
33
"compilerOptions": {
44
"alwaysStrict": true,
55
"sourceMap": true,

tsconfig.app.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* To learn more about this file see: https://angular.io/config/tsconfig. */
22
{
3-
"extends": "./tsconfig.base.json",
3+
"extends": "./tsconfig.json",
44
"compilerOptions": {
55
"outDir": "./out-tsc/app",
66
"types": []

tsconfig.base.json

Lines changed: 0 additions & 26 deletions
This file was deleted.

tsconfig.json

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
1-
/*
2-
This is a "Solution Style" tsconfig.json file, and is used by editors and TypeScript’s language server to improve development experience.
3-
It is not intended to be used to perform a compilation.
4-
5-
To learn more about this file see: https://angular.io/config/solution-tsconfig.
6-
*/
71
{
8-
"files": [],
9-
"references": [
10-
{
11-
"path": "./tsconfig.app.json"
12-
},
13-
{
14-
"path": "./tsconfig.spec.json"
2+
"compileOnSave": false,
3+
"compilerOptions": {
4+
"baseUrl": "./",
5+
"outDir": "./dist/out-tsc",
6+
"sourceMap": true,
7+
"declaration": false,
8+
"downlevelIteration": true,
9+
"experimentalDecorators": true,
10+
"moduleResolution": "node",
11+
"importHelpers": true,
12+
"target": "es2015",
13+
"module": "es2020",
14+
"lib": [
15+
"es2018",
16+
"dom"
17+
],
18+
"paths": {
19+
"ngx-countdown": ["lib/src/index"]
1520
}
16-
]
21+
},
22+
"angularCompilerOptions": {
23+
"fullTemplateTypeCheck": true,
24+
"strictInjectionParameters": true
25+
}
1726
}

tsconfig.spec.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* To learn more about this file see: https://angular.io/config/tsconfig. */
22
{
3-
"extends": "./tsconfig.base.json",
3+
"extends": "./tsconfig.json",
44
"compilerOptions": {
55
"outDir": "./out-tsc/spec",
66
"types": [

0 commit comments

Comments
 (0)