Ever seen those fancy counter things on websites? You know, those numbers that increase over time and count all the little numbers in between? Well, if you’re looking to do that yourself, you’ve come to the right place. With Vue and Tween.js, we can implement the same sort of thing in a few minutes.
We’ll assume that you have a basic Vue project set up already. If not, it’s pretty easy.
First let’s install tween.js using Yarn or NPM.
# Yarn
$ yarn add @tweenjs/tween.js
# NPM
$ npm install @tweenjs/tween.js
Then let’s create a quick wrapper component to hold all the animating logic. It doesn’t really need to be styled.
We can now use this component like so:
That’s all there is to it! With the help of a few other libraries, you can tween other values too, like strings, arrays, or colors.
For more detailed information, consult the Tween.js and Vue.js docs.
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
While we believe that this content benefits our community, we have not yet thoroughly reviewed it. If you have any suggestions for improvements, please let us know by clicking the “report an issue“ button at the bottom of the tutorial.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!