Jump to content

Animating Numbers?

Go to solution Solved by tuanphan,

Recommended Posts

  • Replies 6
  • Views 526
  • Created
  • Last Reply

Top Posters In This Topic

I think adjust current number will require a lot of code

You can use a Count up Animation Plugin, like this: 

https://www.will-myers.com/products/p/count-up-animation

use code TUAN to get 10% discount

 

You can also find a free code on Codepen, then share link, we can convert it to Code Block, like this

https://codepen.io/vn38/pen/eYZWeGr

https://codepen.io/nathanlong/pen/NWLWXXx

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
  • Solution
On 8/30/2024 at 9:33 AM, A1Protocol said:

Hey Tuan! I'm trying to avoid using a plug-in for stability purposes. I like either link's animations. Is there a way we can integrate those to my site? Thank you.

With first link, try edit page > Add a Code Block > Paste this code

<nav class="level">
  <div class="level-item has-text-centered">
    <div>
      <p class="heading">Tweets</p>
      <p class="title js-count-up" data-value="3456"></p>
    </div>
  </div>
  <div class="level-item has-text-centered">
    <div>
      <p class="heading">Following</p>
      <p class="title js-count-up" data-value="123"></p>
    </div>
  </div>
  <div class="level-item has-text-centered">
    <div>
      <p class="heading">Followers</p>
      <p class="title js-count-up" data-value="450000"></p>
    </div>
  </div>
  <div class="level-item has-text-centered">
    <div>
      <p class="heading">Likes</p>
      <p class="title js-count-up" data-value="789"></p>
    </div>
  </div>
</nav>
<style>
  .bg {
  background-color: #1e1f26;
  height: 100vh;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.level {
  background-color: #00d1b2;
  padding: 5rem 0;
  color: #ffffff;
  margin: 0 !important;
}

.title {
  color: inherit;
  width: 200px;
  height: 36px;
}
</style>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.9.0/css/bulma.min.css"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/waypoints/4.0.1/noframework.waypoints.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/countup.js/2.0.7/countUp.js"></script>
<script>
  import { CountUp } from 'https://cdnjs.cloudflare.com/ajax/libs/countup.js/2.0.7/countUp.js';

function countStart() {
  const $counters = document.querySelectorAll(".js-count-up"),
  options = {
    useEasing: true,
    useGrouping: true,
    separator: ",",
    decimal: "." };


  $counters.forEach(item => {
    const value = item.dataset.value;
    const counter = new CountUp(item, value, options);
    counter.start();
  });
}

new Waypoint({
  element: document.querySelector('.level'),
  handler: function () {
    countStart();
    //this.destroy() //for once
  },
  offset: '50%' });
</script>

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
On 9/2/2024 at 9:43 PM, A1Protocol said:

Hey Tuan! Thank you for getting back to me!

This just added a green tweet block with followers, tweets and likes overlapping my numbers.

I understand if it's a more complex issue that requires a plug-in. I don't mind leaving my numbers as such.

Can you share link to page where you added code? I will check again

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment


×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.