Code Monkey home page Code Monkey logo

vue-countdown's Introduction

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

vue-countdown's People

Contributors

maksimovicdanijel avatar

Watchers

athiwatp avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.