@dmaksimovic/vue-countdown

VueJS 2.0 countdown component
1,409 12
Install
npm install @dmaksimovic/vue-countdown
Latest Version:1.0.0
Vue:2
License:MIT
Last Updated:Sep 25, 2018
Links: GitHub  ·  npm
Maintainer: maksimovic

Build Status Coverage Status

Countdown component for VueJS

Component that creates countdown based on provided number of seconds or date in future. Install it by running:

npm install @dmaksimovic/vue-countdown --save

Example usage

Component.vue

<template>
    <div>
        <vue-countdown v-on:time-expire="handleTimeExpire" :seconds="10" :start="start"></vue-countdown>

        <button v-on:click="startTimer">Start timer</button>
    </div>
</template>

<script>
import VueCountdown from '@dmaksimovic/vue-countdown';

export default {
    name: 'my-component',
    data () {
        return {
            start: false
        };
    },
    components: {
        'vue-countdown': VueCountdown
    },
    methods () {
        handleTimeExpire () {
            alert('Time is up!');
        },
        startTimer () {
            this.start = true;
        }
    }
}

</script>

This will create a simple component that will output countdown that starts from 10 and counts until 0.

Options

seconds - number of seconds to start counter from (type number)

date - date in future as a string. Any string that can be parsed by Date.parse() is considered valid. Takes precedence over seconds parameter

message - message to display when counter finishes

units - array that represents units which will form the counter. Possible values are 'hours', 'minutes', 'seconds'

start - boolean value whether to start timer or not

Events

time-expire - triggered when timer finishes

Contributing

Building

npm run build

Testing

npm test

Licence

MIT

Related Packages

vue2-flip-countdown

A simple flip countdown timer component for Vue 2.x

64,576 228
@smithalan2/vue-countdown

A simple countdown timer component for Vue 3 written using the composition API.

2,070 3
@vuecs/countdown

A package containing a countdown component.

12,377 4
@vue-layout/countdown

A package containing a countdown component.

2,864 4
vue-awesome-countdown

Countdown plug-in with high performance and high accuracy for Vue 2.5.0+ and Vue...

95,975 191

Version History

Version Released Vue License
1.0.0 ^2.4.2 MIT
0.1.2 ^2.4.2 MIT
0.1.1 ^2.4.2 MIT
0.1.0 ^2.4.2 MIT
0.0.1 ^2.4.2 MIT