2
0

prepared gui and service for animation

This commit is contained in:
2018-08-07 15:11:49 +02:00
parent 1ec2f21a25
commit cafc27e2e9
4 changed files with 73 additions and 3 deletions

View File

@@ -94,8 +94,18 @@
</label> </label>
<input type="number" class="form-control" formControlName="spread" min="0" max="40"> <input type="number" class="form-control" formControlName="spread" min="0" max="40">
</div> </div>
<div class="form-group d-flex flex-colmn justify-content-between align-items-center mb-4">
<label class="form-control-label">
Animation
</label>
<div class="btn-group" role="group" aria-label="Basic example">
<button type="button" class="btn" (click)="animationActive = true" [ngClass]="{'btn-outline-primary': !animationActive, 'btn-primary': animationActive}">An</button>
<button type="button" class="btn" (click)="animationActive = false" [ngClass]="{'btn-outline-primary': animationActive, 'btn-primary': !animationActive}">Aus</button>
</div>
</div>
<div class="dropdown-divider mb-4"></div> <div class="dropdown-divider mb-4"></div>
<button type="submit" class="btn btn-lg btn-primary btn-block" [disabled]="configForm.invalid">Aktualisieren</button> <button type="submit" class="btn btn-lg btn-primary btn-block" [disabled]="configForm.invalid">Aktualisieren</button>
<div class="dropdown-divider mt-4"></div>
</form> </form>
<div class="row mt-4"> <div class="row mt-4">
@@ -122,8 +132,8 @@
</span> </span>
</div> </div>
<div> <div>
{{ item.date | amTimeAgo }} {{ item.date | amTimeAgo }}
</div> </div>
</div> </div>
</a> </a>
</div> </div>

View File

@@ -43,6 +43,7 @@ export class AppComponent implements OnInit {
public list: any[]; public list: any[];
public showList: boolean; public showList: boolean;
public restoredHistory: any; public restoredHistory: any;
public animationActive: boolean;
constructor( constructor(
private canvasService: CanvasService, private canvasService: CanvasService,
@@ -54,6 +55,7 @@ export class AppComponent implements OnInit {
this.configForm = ConfigForm; this.configForm = ConfigForm;
this.list = []; this.list = [];
this.showList = true; this.showList = true;
this.animationActive = false;
} }
ngOnInit() { ngOnInit() {

View File

@@ -24,6 +24,7 @@ import { GraphsComponent } from './components/graphs.component';
import { GuillocheDirective } from './directives/guilloche.directive'; import { GuillocheDirective } from './directives/guilloche.directive';
import { CanvasService } from './services/canvas.service'; import { CanvasService } from './services/canvas.service';
import { HistoryService } from './services/history.service'; import { HistoryService } from './services/history.service';
import { AnimationService } from './services/animation.service';
@NgModule({ @NgModule({
declarations: [ declarations: [
@@ -39,7 +40,8 @@ import { HistoryService } from './services/history.service';
], ],
providers: [ providers: [
CanvasService, CanvasService,
HistoryService HistoryService,
AnimationService
], ],
bootstrap: [AppComponent] bootstrap: [AppComponent]
}) })

View File

@@ -0,0 +1,56 @@
/**
* Copyright (C) 2018 Michael Czechowski <mail@dailysh.it>
* 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;
}
}