+ {{ item.date | amTimeAgo }}
+
diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index f290615..9c1e829 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -43,6 +43,7 @@ export class AppComponent implements OnInit {
public list: any[];
public showList: boolean;
public restoredHistory: any;
+ public animationActive: boolean;
constructor(
private canvasService: CanvasService,
@@ -54,6 +55,7 @@ export class AppComponent implements OnInit {
this.configForm = ConfigForm;
this.list = [];
this.showList = true;
+ this.animationActive = false;
}
ngOnInit() {
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 9811fd9..befb655 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -24,6 +24,7 @@ import { GraphsComponent } from './components/graphs.component';
import { GuillocheDirective } from './directives/guilloche.directive';
import { CanvasService } from './services/canvas.service';
import { HistoryService } from './services/history.service';
+import { AnimationService } from './services/animation.service';
@NgModule({
declarations: [
@@ -39,7 +40,8 @@ import { HistoryService } from './services/history.service';
],
providers: [
CanvasService,
- HistoryService
+ HistoryService,
+ AnimationService
],
bootstrap: [AppComponent]
})
diff --git a/src/app/services/animation.service.ts b/src/app/services/animation.service.ts
new file mode 100644
index 0000000..08a82b5
--- /dev/null
+++ b/src/app/services/animation.service.ts
@@ -0,0 +1,56 @@
+/**
+ * Copyright (C) 2018 Michael Czechowski
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+import { Inject, Injectable, Optional, ViewChild } from '@angular/core';
+import * as Selection from 'd3-selection';
+
+import { Graph } from '../models/graph.model';
+
+@Injectable()
+export class AnimationService {
+
+ public graphs: Graph[];
+ public speed: number;
+ public range: number;
+ public genAnimation: any;
+
+ constructor() {
+ this.resetAnimation();
+ }
+
+ private resetAnimation() {
+ this.genAnimation = this.animateNextStep();
+ }
+
+ private animateNextStep() {
+ while (this.graphs) {
+ return true;
+ }
+ }
+
+ public init(initialGraphs: Graph[]) {
+ this.graphs = initialGraphs;
+ }
+
+ public animate(): Graph[] {
+ return this.genAnimation.next().value;
+ }
+
+ public stop() {
+ this.graphs = null;
+ }
+}
+