Skip to content

Commit

Permalink
fix: fix done value is 0 of fractional seconds (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk authored Nov 10, 2020
1 parent 7fa4ecd commit d70cc42
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 46 deletions.
9 changes: 6 additions & 3 deletions lib/src/countdown.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { CountdownGlobalConfig } from './countdown.config';
})
export class CountdownComponent implements OnInit, OnChanges, OnDestroy {
private frequency = 1000;
private _notify: any = {};
private _notify: { [key: number]: boolean } = {};
private status: CountdownStatus = CountdownStatus.ing;
private isDestroy = false;
i: CountdownItem = {};
Expand Down Expand Up @@ -162,7 +162,10 @@ export class CountdownComponent implements OnInit, OnChanges, OnDestroy {
return;
}

const value = (this.left = this.left - this.frequency * count);
let value = (this.left = this.left - this.frequency * count);
if (value < 1) {
value = 0;
}
this.i = {
value,
text: config.formatDate({ date: value, formatStr: config.format, timezone: config.timezone }),
Expand All @@ -178,7 +181,7 @@ export class CountdownComponent implements OnInit, OnChanges, OnDestroy {
});
}

if (value < 1) {
if (value === 0) {
this.ngZone.run(() => {
this.status = CountdownStatus.done;
this.callEvent('done');
Expand Down
2 changes: 1 addition & 1 deletion lib/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../tsconfig.base.json",
"extends": "../tsconfig.json",
"compilerOptions": {
"alwaysStrict": true,
"sourceMap": true,
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "./tsconfig.base.json",
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": []
Expand Down
26 changes: 0 additions & 26 deletions tsconfig.base.json

This file was deleted.

37 changes: 23 additions & 14 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
/*
This is a "Solution Style" tsconfig.json file, and is used by editors and TypeScript’s language server to improve development experience.
It is not intended to be used to perform a compilation.
To learn more about this file see: https://angular.io/config/solution-tsconfig.
*/
{
"files": [],
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.spec.json"
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"importHelpers": true,
"target": "es2015",
"module": "es2020",
"lib": [
"es2018",
"dom"
],
"paths": {
"ngx-countdown": ["lib/src/index"]
}
]
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true
}
}
2 changes: 1 addition & 1 deletion tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "./tsconfig.base.json",
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/spec",
"types": [
Expand Down

0 comments on commit d70cc42

Please sign in to comment.