Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ngx-countdown

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngx-countdown

Simple, easy and performance countdown for angular

  • 1.0.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
26K
increased by13.41%
Maintainers
1
Weekly downloads
 
Created
Source

ngx-countdown

Simple, easy and performance countdown for angular

NPM version Build Status

Demo

Live Demo

Usage

1. Install

npm install ngx-countdown --save

import CountdownModule

import { CountdownModule } from 'ngx-countdown';

@NgModule({
    imports: [ BrowserModule, CountdownModule ],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
export class AppModule { }

2、Template

<countdown [config]="config" 
    (start)="onStart()"
    (finished)="onFinished()"
    (notify)="onNotify($event)"></countdown>
NameTypeDefaultSummary
configConfig配置信息,见Config
startFunction开始时触发
finishedonFinished结束时触发
notifyFunction(time: number)通知时触发,需要在 Config 中配置 notify

如何重置计数器

@ViewChild(CountdownComponent) counter: CountdownComponent;
resetTimer(){
    //this.counter.config.leftTime = 5;
    this.counter.restart();
}

当然,也可以通过重新赋值 config 参数,也能达到一样的效果。

Config

NameTypeDefaultSummary
templatestring$!h!时$!m!分$!s!秒自定义模板,如果为空以组件 innerHTML 为准,再不然使用默认值。$!s! 有另一种表示法 $!s-ext! 表示0.1s精度。
sizestringlitelite、medium、large 三种不同风格,见DEMO
leftTimenumber0剩余时间:指的是根据服务端计算剩余时间值进行倒计时,支持0.1s精度,但有可能会出现丢帧的情况。(单位:秒)
stopTimenumber0结束时间:指的是根据本地时间至结束时间进行倒计时。(单位:UNIX时间戳 ms)
varRegularRegExp/\$\{([\-\w]+)\}/g模板解析正则表达式,有时候由于模板结构比较特殊,无法根据默认的表达式进行解析,那就需要修改它。
clockArray时钟控制数组,特殊需求时可以修改,里面是三元组:指针名、进制、位数,可参考大于99小时demo
notifynumber[]第xx秒时调用 notify 函数,值必须是正整数
classNamestring自定义类名
repaintFunction自定义重绘

关于重绘

重绘是指当Timer一次跳动时会执行一次(如果是0.1s精度的,会更频繁);因此,可以制定一些不一样的效果。有关细节可以参考 Flip

Troubleshooting

Please follow this guidelines when reporting bugs and feature requests:

  1. Use GitHub Issues board to report bugs and feature requests (not our email address)
  2. Please always write steps to reproduce the error. That way we can focus on fixing the bug, not scratching our heads trying to reproduce it.

Thanks for understanding!

License

The MIT License (see the LICENSE file for the full text)

Keywords

FAQs

Package last updated on 06 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc