1.0.2 • Published 5 years ago

@yangzhiwei/v-count-up v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

v-count-up

It's a vue component that will count to a target number at a specified duration

v-count-up is a dependency-free, lightweight vue component that can be overwrited easingFn by yourself. You can set startVal and endVal ,it will automatic judge count up or count down. It is support vue-ssr. It is learn from countUp.js@2.0.4;

How to use?

npm install @yangzhiwei/v-count-up

Example

<template>
  <v-count-up :ev="endVal" :opts="opts"></v-count-up>
</template>

<script>
  import VCountUp from '@yangzhiwe/v-count-up';
  export default {
    components: { VCountUp },
    data () {
      return {
        endVal: 2019,
        opts: {
          startVal: 1000
        }
      }
    }
  }
</script>

Params

PropertyDescriptiontypedefault
endValthe value you want to arrive atNumber0
options?optional configuration object for fine-grain controlObjectnull

Options

PropertyDescriptiontypedefault
startValnumber to start at (0)Number0
decimalPlacesnumber of decimal places (0)Number0
durationanimation duration in seconds (2)Number2
useGroupingexample: 1,000 vs 1000 (true)Booleantrue
useEasingease animation (true)Booleantrue
smartEasingThresholdsmooth easing for large numbers above this if useEasing (999)Number999
smartEasingAmountamount to be eased for numbers above threshold (333)Number333
separatorgrouping separator (',')String,
decimaldecimal ('.')String.
easingFneasingFn: easing function for animation (easeOutExpo)Function(t: number, b: number, c: number, d: number) => number-
formattingFnthis function formats resultFunction(n: number) => string-
prefixtext prepended to resultString''
suffixtext appended to resultString''
numeralsnumeral glyph substitutionstring[][]
autoplaywhen mounted autoplayBooleantrue

notes: when autoplay:true , it will auto start

Functions

Function NameDescription
mountedCallbackwhen mounted will emit mountedCallback
startstart the v-count-up
pauseResumeToggle pause/resume
resetReset the animation
updateUpdate the end value and animate