2.0.0 • Published 2 years ago

vue-circular-count-down-timer v2.0.0

Weekly downloads
317
License
MIT
Repository
github
Last release
2 years ago

Circular count down timer

This library is a count down timer for Vue js framework. You can add as many as timers you need and fully customize them.

fully customized timer mode

Installation

npm install vue-circular-count-down-timer

After installation, you can import component and register it in the main.js:

import Vue from 'vue';
import CircularCountDownTimer from 'vue-circular-count-down-timer';
Vue.use(CircularCountDownTimer);

Examples

You can see some sample implementations in this page. You can also check out the live demo in this link.

How to use

You should pass an array of circles configurations to the component as props. You can also pass circle's configs directly to the component in order to apply them to all circles.

Each circle must have an id, You should also determine id of main circle using main-circle-id props. This is the circle that counting starts with that.

Dependent circles

By default, circles are independent of each other, if you want to make them related (minutes, seconds, ... for example) you should set id of related circles in dependentCircles field of a circle.

Circles arrangement

By default, circles will be placed in a row (flex row), but if you want to change default arrangement, you can pass container-classes and circle-classes props and change their styles.

Stop conditions

If you want to stop counting after reaching a certain value, you can use stop-conditions props. It is an object that contains values for each circle. For example consider you have two circles with id circle-1 and circle-2, you want to stop counting when circle-1 reaches to 5 and circle-2 reaches to 12:

stop-conditions = { 'circle-1': 5, 'circle-2': 12 }

After finish counting, a finish event will be emitted.

Incremental or decremental

By default, counting is incremental, but if you want to make it counting downward, pass a negative value for stepLength field of circle.

Props

PropsDescriptionPossible valuesDefault value
circlesA list of circles config objectsCircle[]
intervalTimer change interval in msA positive number1000
main-circle-idId of the circle that counting should start with thatA string
sizeWidth and height of circles in pxA positive numberContainer size
container-classesA list of classes to set to circles container elementAn array of strings[]
circle-classesA list of classes to set to a circle elementAn array of strings[]
stop-conditionsAn object that contains values for each circle to stop timer after reaching to those valuesAn object with circle ids as key, and a number as value{}
trigger-updateEmit an event for each value change or notA booleantrue
stroke-widthThickness of circle strokes in pxA positive number10
stroke-colorCircle stroke colorA color string#9d989b
underneath-stroke-colorStroke color of empty parts of circlesA color string#eee
fill-colorCircle background colorA color string#ffffff
value-font-sizeFont size of counter value in pxA positive number20
label-font-sizeFont size of counter label in pxA positive number15
label-positionPosition of counter labelbottom or topbottom
show-valueWhether to show counter value or notA booleantrue

Circle props

PropsDescriptionPossible valuesDefault value
idId of circleA string
classListA list of classes to set to the circle elementAn array of strings[]
startValueThe number to start counting from, after reaching to the en of circleA numberzero
valueInitial value of circleA numberzero
sizeWidth and height of circles in pxA positive numberContainer size
strokeWidthThickness of circle strokes in pxA positive number10
strokeColorCircle stroke colorA color string#9d989b
underneathStrokeColorStroke color of empty parts of circleA color string#eee
fillColorCircle background colorA color string#ffffff
valueFontSizeFont size of counter value in pxA positive number20
labelFontSizePosition of counter labelA positive number15
stepsThe number circle partitionsA positive number
stepLengthHow many step should be passed in each moveA non zero number1
labelLabel of circleA string
labelPositionPosition of labelbottom or topbottom
showValueWhether to show counter value or notA booleantrue

events

EventsDescription
finishFires when counter reaches to stop conditions.
updateFires on each counting.