vue-countup-directive
Version:
Vue Directive that creates a countup animation
20 lines (17 loc) • 364 B
JavaScript
import CountUpJS from 'countup.js'
export default ({ startValue = 0, endValue, el, options = {} }) => {
const { decimals = 0, duration = 2 } = options
const counter = new CountUpJS(
el,
startValue,
endValue,
decimals,
duration,
options
)
if (!counter.error) {
counter.start()
} else {
console.error(counter.error)
}
}