npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vuejs-countdown-timer

v2.1.3

Published

Vue 2 countdown and timer component

Downloads

6,544

Readme

Demo 📙 中文文档 📙Changelog

Installation

npm i vuejs-countdown-timer -S

Usage

Support

| Supported Package | Version | | ----------------- | ------- | | Vue | 2.5+ |

Install component and Usage

Import component

// global register at main.js
import VueCountdownTimer from 'vuejs-countdown-timer';
Vue.use(VueCountdownTimer);

Vue default template

<template>
    <vue-countdown-timer
      @start_callback="startCallBack('event started')"
      @end_callback="endCallBack('event ended')"
      :start-time="'2018-10-10 00:00:00'"
      :end-time="1481450115"
      :interval="1000"
      :start-label="'Until start:'"
      :end-label="'Until end:'"
      label-position="begin"
      :end-text="'Event ended!'"
      :day-txt="'days'"
      :hour-txt="'hours'"
      :minutes-txt="'minutes'"
      :seconds-txt="'seconds'">
    </vue-countdown-timer>
</template>

<script >
export default {
  name: 'Timer',
  methods: {
    startCallBack: function(x) {
      console.log(x);
    },
    endCallBack: function(x) {
      console.log(x);
    },
  },
};
</script>

Vue Customized template

<template>
    <vue-countdown-timer
      @start_callback="startCallBack('event started')"
      @end_callback="endCallBack('event ended')"
      :start-time="'2018-10-10 00:00:00'"
      :end-time="1481450115"
      :interval="1000"
      :start-label="'Until start:'"
      :end-label="'Until end:'"
      label-position="begin"
      :end-text="'Event ended!'"
      :day-txt="'days'"
      :hour-txt="'hours'"
      :minutes-txt="'minutes'"
      :seconds-txt="'seconds'">
      <template slot="start-label" slot-scope="scope">
        <span style="color: red" v-if="scope.props.startLabel !== '' && scope.props.tips && scope.props.labelPosition === 'begin'">{{scope.props.startLabel}}:</span>
        <span style="color: blue" v-if="scope.props.endLabel !== '' && !scope.props.tips && scope.props.labelPosition === 'begin'">{{scope.props.endLabel}}:</span>
      </template>

      <template slot="countdown" slot-scope="scope">
        <span>{{scope.props.days}}</span><i>{{scope.props.dayTxt}}</i>
        <span>{{scope.props.hours}}</span><i>{{scope.props.hourTxt}}</i>
        <span>{{scope.props.minutes}}</span><i>{{scope.props.minutesTxt}}</i>
        <span>{{scope.props.seconds}}</span><i>{{scope.props.secondsTxt}}</i>
      </template>

      <template slot="end-label" slot-scope="scope">
        <span style="color: red" v-if="scope.props.startLabel !== '' && scope.props.tips && scope.props.labelPosition === 'end'">{{scope.props.startLabel}}:</span>
        <span style="color: blue" v-if="scope.props.endLabel !== '' && !scope.props.tips && scope.props.labelPosition === 'end'">{{scope.props.endLabel}}:</span>
      </template>

      <template slot="end-text" slot-scope="scope">
        <span style="color: green">{{ scope.props.endText}}</span>
      </template>
    </vue-countdown-timer>
</template>

<script >
export default {
  name: 'Timer',
  methods: {
    startCallBack: function(x) {
      console.log(x);
    },
    endCallBack: function(x) {
      console.log(x);
    },
  },
};
</script>

Slots

| Slot name | Description | | ----------- | --------------------- | | start-label | Timer start label | | countdown | Timer countdown label | | end-label | Timer end label | | end-text | Timer ended text |

start-label Scoped Slot

| Slot scope name | Description | | --------------- | ------------------------------------------------------------------------ | | startLabel | Event begin label text | | endLabel | Event end label text | | tips | Tips true means countdown till start, false means countdown till end | | labelPosition | event label position, 'begin' or 'end' |

countdown Scoped Slot

| Slot scope name | Description | | --------------- | -------------------------------------------------- | | days | Number of days till event | | dayTxt | Day label | | hours | Number of hours till event | | hourTxt | Hours label | | minutes | Number of minutes till event | | minuteTxt | Minutes label | | seconds | Number of seconds till event | | secondTxt | Seconds label | | showDay | display status of day countdown number and text | | showHour | display status of hour countdown number and text | | showMinute | display status of minute countdown number and text |

end-label Scoped Slot

| Slot scope name | Description | | --------------- | ------------------------------------------------------------------------ | | startLabel | Event begin label text | | endLabel | Event end label text | | tips | Tips true means countdown till start, false means countdown till end | | labelPosition | event label position, 'begin' or 'end' |

end-text Scoped Slot

| Slot scope name | Description | | --------------- | ---------------- | | endText | Timer ended text |

Props

start-time

  • type: Number|String
  • required : true

end-time

  • type: Number|String
  • required : true

interval

  • type: Number
  • required : false
  • default : 1000

start-label

  • type: String
  • required : false
  • default : ''

end-label

  • type: String
  • required : false
  • default : ''

label-position - begin (before countdown) / end (after countdown)

  • type: String
  • required : false
  • default : 'begin'

end-text

  • type: String
  • required : false
  • default : 'Event ended!'

day-txt - if pass null, this unit will be hidden

  • type: String
  • required : false
  • default : ':'

hour-txt - if pass null, this unit will be hidden

  • type: String
  • required : false
  • default : ':'

seconds-txt - if pass null, this unit will be hidden

  • type: String
  • required : false
  • default : ':'

seconds-fixed

  • type: String
  • required : false
  • default : ':'

show-zero - display status of 00

  • type: Boolean
  • required : false
  • default : true

Events

start_callback - Event started callback

  • type: Function
  • required : false

end_callback - Event ended callback

  • type: Function
  • required : false

If the end-time prop is dynamically generated or 'computed', the initial value will be NaN. This will trigger the end_callback function, which might not be desirable. This can be solved by declaring it this way:

<template>
  <vue-countdown-timer
    ...
    :end-time="end_at?end_at:endAt"
    ...
    ></vue-countdown-timer>
</template>
<script>
  data() {
      return {
          endAt:  (new Date).getTime()+5000
      }
  }
</script>

Where end_at is the computed value, and endAt is a default value.

Liscense

MIT License