Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/xiaojundebug/ngx-countdown

An angular countdown component.
https://github.com/xiaojundebug/ngx-countdown

angular countdown ng

Last synced: 21 days ago
JSON representation

An angular countdown component.

Awesome Lists containing this project

README

        

# NgxCountdown

An angular countdown component, inspired by [vant](https://github.com/youzan/vant).

_development environment: angular 8.2.14_


travis

👉 [Demo](https://stackblitz.com/edit/ngx-countdown-demo)

## Install

```bash
npm i @ciri/ngx-countdown
```

## Quick Start

Add it to your module:

```typescript
import { CountdownModule } from '@ciri/ngx-countdown'

@NgModule({
// ...
imports: [
// ...
CountdownModule
],
})
```

Add to view:

```html



s
```

## Millisecond Render

```html

```

## Manual Control

```html
 state: {{ counter.state }}


start 
pause 
reset
```

## Custom Render

```html


{{ data.formattedTime }}


{{ data.fragments[0] }}:
{{ data.fragments[1] }}:
{{ data.fragments[2] }}:
{{ data.fragments[3] }}

remain: {{ data.remain }}ms

```

## Inputs

| Name | Type | Default | Description |
| ----------- | ---------------- | -------- | --------------------------------------------------------- |
| time | number | 60000 | Total time(milliseconds) |
| format | string | HH:mm:ss | Time format, see: [Available Formats](#available-formats) |
| autoStart | boolean | true | Whether to auto start count down |
| millisecond | boolean | false | Whether to enable millisecond render |
| render | TemplateRef | - | Custom render |

## Outputs

| Event | Description | Return value |
| ------ | ---------------------------------- | ------------ |
| finish | Triggered when count down finished | - |
| tick | Triggered when count down changed | Remain time |

## Available Formats

| Event | Description |
| ----- | --------------------- |
| DD | Day |
| HH | Hour |
| mm | Minute |
| ss | Second |
| S | Millisecond, 1-digit |
| SS | Millisecond, 2-digits |
| SSS | Millisecond, 3-digits |

## Public Api

| Name | Type | Description |
| ----- | -------- | ---------------------------------------------------- |
| state | number | Current state: 0 = paused, 1 = playing, 2 = finished |
| start | function | Start count down |
| pause | function | Pause count down |
| reset | function | Reset count down |