cipchk / ngx-countdown

Simple, easy and performance countdown for angular
https://cipchk.github.io/ngx-countdown/
MIT License
192 stars 57 forks source link

Notify at a specific time left ? #90

Closed FolabiAhn closed 3 years ago

FolabiAhn commented 3 years ago

Possible Bug Report

I set a 15mn countdown. I would like to notify when 60 sec left. But the notify is trigger at the start of the application.

<countdown [config]="{ leftTime: 900, format: 'mm:ss', notify: [ 840 ] }" (event)="handleCountdownEvent($event)">
</countdown>

I set a stackblitz : https://stackblitz.com/edit/ngx-countdown-setup-twyrr6

Current behavior

Notify is trigger at the start of the application

Expected behavior

Notify when 60 sec left.

Am i missing something ? Thanks

cipchk commented 3 years ago

You need limit event.type is notify, pls refer to https://github.com/cipchk/ngx-countdown#countdownevent.

FolabiAhn commented 3 years ago

Can you please write the code to do it. I follow your example here : https://cipchk.github.io/ngx-countdown/#/

cipchk commented 3 years ago

Like this:

import { Component } from "@angular/core";
import { CountdownEvent } from "ngx-countdown";

@Component({
  selector: "my-app",
  template: `
    <countdown
      [config]="{ leftTime: 10, format: 'mm:ss', notify: [10, 6] }"
      (event)="handleCountdownEvent($event)"
    ></countdown>
  `
})
export class AppComponent {
  handleCountdownEvent(event: CountdownEvent): void {
    if (event.action === 'notify') {
      console.log(event);
    }
    //console.log("60 sec left");
  }
}
FolabiAhn commented 3 years ago

Ooh ok thanks, I get it. Notify type is an array of number, I was setting it to a number.