From e089aac0da6f225fd29a4c08378de2d91508b205 Mon Sep 17 00:00:00 2001 From: Alejandro Martin Date: Fri, 9 Jun 2017 11:41:20 +0200 Subject: [PATCH] Add duration config --- src/odometer/odometer.component.ts | 7 +++++++ src/odometer/odometer.config.ts | 2 ++ 2 files changed, 9 insertions(+) diff --git a/src/odometer/odometer.component.ts b/src/odometer/odometer.component.ts index 82a23c6..0eb7cee 100644 --- a/src/odometer/odometer.component.ts +++ b/src/odometer/odometer.component.ts @@ -61,6 +61,7 @@ export class Ng2OdometerComponent implements OnInit, OnDestroy, AfterViewInit { @Input() format: string = undefined; @Input() theme: string = undefined; @Input() value: number = undefined; + @Input() duration: number = undefined; private subscription: Subscription; private odometer: OdometerModel; @@ -84,6 +85,7 @@ export class Ng2OdometerComponent implements OnInit, OnDestroy, AfterViewInit { el: this.container.nativeElement, animation: this.config.animation, value: this.config.value, + duration: this.config.duration, format: this.config.format, theme: this.config.theme, }); @@ -113,6 +115,11 @@ export class Ng2OdometerComponent implements OnInit, OnDestroy, AfterViewInit { this.config.value = this.value; } + // Duration + if (!_.isUndefined(this.duration)) { + this.config.duration = this.duration; + } + // Validate theme. If not part of the // available themes array, use the default if (!_.includes(this.themes, this.config.theme)) { diff --git a/src/odometer/odometer.config.ts b/src/odometer/odometer.config.ts index 74c0c3a..6aff01e 100644 --- a/src/odometer/odometer.config.ts +++ b/src/odometer/odometer.config.ts @@ -10,6 +10,7 @@ export interface Ng2OdometerConfigModel { format?: string; theme?: string; value?: number; + duration?: number; } export class Ng2OdometerConfig implements Ng2OdometerConfigModel { @@ -17,4 +18,5 @@ export class Ng2OdometerConfig implements Ng2OdometerConfigModel { format: string = '(,ddd)'; theme?: string = 'default'; value?: number = 0; + duration?: number = 2000; }