Skip to content

Commit

Permalink
Add play/pause buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
vvmk committed Sep 3, 2018
1 parent edef673 commit 8ff838f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/app/runner/drill-runner/drill-runner.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ <h5 class="my-3 text-center routine-duration">
<span class="mt-5 p-0 text-center drill-tick">
{{drillTick}}
</span>
<div class="mb-2 mt-auto running-controls">
<button class="btn btn-link btn-lg pause-button" (click)="pauseDrills()" *ngIf="!paused">
<fa-icon class="text-dark" [icon]="faPause"></fa-icon>
</button>
<button class="btn btn-link btn-lg resume-button" (click)="resumeDrills()" *ngIf="paused">
<fa-icon class="text-dark" [icon]="faPlay"></fa-icon>
</button>
</div>
</div>
</div>
</div>
Expand Down
16 changes: 16 additions & 0 deletions src/app/runner/drill-runner/drill-runner.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export class DrillRunnerComponent implements OnInit {
private drillTick: number;

running = false;
paused = false;

breakTime = 5;
oneSecond = 1100;

Expand Down Expand Up @@ -131,6 +133,20 @@ export class DrillRunnerComponent implements OnInit {
}
}

pauseDrills() {
this.paused = true;
clearTimeout(this.clock);

console.log('pause');
}

resumeDrills() {
this.paused = false;
this.countdown(this.drillTick + 3);

console.log('resume');
}

setProps(data): void {
this.routine = data['routine'];
this.drills = this.routine.drills;
Expand Down

0 comments on commit 8ff838f

Please sign in to comment.