0.4.2 • Published 7 years ago

vue-animate-number v0.4.2

Weekly downloads
519
License
MIT
Repository
-
Last release
7 years ago

Animate Number

Demo

How to Use

install

$ npm install vue-animate-number

as a vue plugin

import Vue from 'vue'
import VueAnimateNumber from 'vue-animate-number'
Vue.use(VueAnimateNumber)

examples

<template>
  <div>
    <animate-number
      from="1" 
      to="10" 
      duration="1000" 
      easing="easeOutQuad"
      :formatter="formatter"
    ></animate-number>

    <!-- parseInt as default formatter -->
    <animate-number from="1" to="10"></animate-number>
    
    <!-- manually start animation by click -->
    <animate-number ref="myNum" from="0" to="10" mode="manual" :formatter="formatter"></animate-number><br>
    
    <button type="button" @click="startAnimate()"> animate! </button>
  </div>
</template>

<script>
  export default {
    methods: {
      formatter: function (num) {
        return num.toFixed(2)
      },

      startAnimate: function () {
        this.$refs.myNum.start()
      }
    }
  }
</script>

more easing effects: https://github.com/jeremyckahn/shifty/blob/master/src/easing-functions.js

more examples: https://github.com/wangdahoo/vue-animate-number/blob/master/index.html

API

<animate-number 
  mode="auto"
  duration="1000"
  :from="from" 
  :to="to"
  from-color="#44CC00" 
  to-color="#ec4949"
  :formatter="formatter" 
  :animate-end="animateEnd">
</animate-number>
prop nametypedescriptiondefaultrequired
modestringauto or manual, trigger animation immediately or notautoN
fromnumbervalue, at which animate starts-Y
tonumbervalue, at which animate ends-Y
fromColorstringstart color for gradient, in hex format-N
toColorstringend color for gradient, in hex format-N
formatterFunctionvalue formatter for number in every step during the animationparseIntN
animateEndFunctioncallback after animation-N
0.4.2

7 years ago

0.4.1

7 years ago

0.4.0

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago