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

vue-awesome-countdown

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-awesome-countdown

Vue countdown plugin.

  • 1.0.19
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.8K
decreased by-33.17%
Maintainers
1
Weekly downloads
 
Created
Source

vue-awesome-countdown

npm version Gzip Size Monthly Downloads License: MIT

Countdown plug-in with high performance and high accuracy for Vue2.5.0+.

Installation

Install

$ npm install vue-awesome-countdown --save
# or
$ yarn add vue-awesome-countdown

ES6


import vueAwesomeCountdown from 'vue-awesome-countdown'

Vue.use(vueAwesomeCountdown, 'vac') // Component name, `countdown` and `vac` by default

CommonJS

var Vue = require('vue');
var vueAwesomeCountdown = require('vue-awesome-countdown').default;

Vue.use(vueAwesomeCountdown);

Browser

<script src="https://unpkg.com/vue@latest"></script>
<script src="https://unpkg.com/vue-awesome-countdown@latest"></script>
<!-- OR -->
<script src="path/to/vue/vue.min.js"></script>
<script src="path/to/vue-awesome-countdown/dist/vue-awesome-countdown.umd.min.js"></script>

Usage

<countdown :end-time="new Date().getTime() + 60000">
  <span
    slot="process"
    slot-scope="anyYouWantedScopName">{{ `Lefttime: ${anyYouWantedScopName.timeObj.ceil.s}` }}</span>
  <span slot="finish">Done!</span>
</countdown>
<vac :end-time="new Date().getTime() + 60000">
  <span
    slot="process"
    slot-scope="{ timeObj }">{{ `Lefttime: ${timeObj.m}:${timeObj.s}` }}</span>
  <span slot="finish">Done!</span>
</vac>

SSR (Nuxt)

<no-ssr>
  <vac :end-time="new Date().getTime() + 60000">
    <span
      slot="process"
      slot-scope="{ timeObj }">{{ `Lefttime: ${timeObj.m}:${timeObj.s}` }}</span>
    <span slot="finish">Done!</span>
  </vac>
</no-ssr>

Example demo

https://vac.js.org

Props

PropRequiredExplainTypeDefault
startTimefalseTime stamp of countdown start[String, Number, Date]null
endTimewhen leftTime undefinedTime stamp of countdown end[String, Number, Date]null
leftTimewhen endTime undefinedRemaining milliseconds of countdown endNumber0
autoStartfalseStart countdown automaticallyBooleantrue
speedfalseUnit: millisecondNumber1000
tagfalseThe wrap tag nameStringspan

Data

The data can get it through slot-scop or methods.

DataExplainDefault
stateThe countdown run state, the states are beforeStart, stoped, paused, process and finisedbeforeStart
attrsThe countdown component tag attributes{}
actualEndTimeActual countdown end timenull
timeObjLook look{}
countdownTimerThe countdown timer function, Do not use as much as possible.null
actualStartTimeActual countdown start time.null
runTimesCountdown run times (The onProcess methods run times)0
usedTimeThe total time consuming from the countdown to the end.0

timeObj

{
    "endTime": 1542634411361,
    "speed": 1000,
    "leftTime": 97019,
    "d": "0",
    "h": "00",
    "m": "01",
    "s": "37",
    "ms": "019",
    "org": {
        "d": 0.001134247685185185,
        "h": 0.02722194444444444,
        "m": 1.6333166666666665,
        "s": 37.998999999999995,
        "ms": 19
    },
    "ceil": {
        "d": 1,
        "h": 1,
        "m": 2,
        "s": 98
    }
}

Slots

Slot process and slot finish will not display at the same time.

nameslot-scopPositionDisplay condition
prevcomponent _self1Defined, Controllable display
beforecomponent _self2On before start, state === 'beforeStart'
processcomponent _self2On process, state === 'process' or state === 'stoped' or state === 'paused'
finishcomponent _self3On finish, state === 'finished'
defaultcomponent _self3Defined, Controllable display

Methods

The methods can be accesse through slot-scop or $refs.

MethodExplainParameters
startCountdownrestart
stopCountdownno
pauseCountdownno
switchCountdownno
finishCountdownno
doCountdownno

Event

EventExplainParameters
startFunctions executed at the beginning of countdownvm
processFunction executed when countdown is performedvm
stopFunction executed when countdown stopsvm
pauseFunction executed when countdown pausedvm
finishFunction executed when countdown finishedvm

MIT License

Keywords

FAQs

Package last updated on 24 Oct 2019

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