데굴데굴

animated number counter 본문

Programming/자투리

animated number counter

aemaaeng 2023. 6. 24. 18:23

백준 사이트

웹을 구경하다가 자주 보게되는 이것

라이브러리를 쓸 수 있지만 동작하는 원리가 궁금해서 아래 글을 참고하며 간단하게 만들어보았다.

 

 

How to Build an Animated Counter with JavaScript - Studytonight

I am sure at some point in your life, while browsing the web, you have found a web page that shows an animated counter. A counter that starts from 0 and goes all the way up to some given number. Here is an example of how such a counter looks. In this artic

www.studytonight.com

 

 

처음에 함수를 실행해도 숫자가 올라가지 않아서 의아했는데 `target_num`이 `speed`보다 작아서 `increment`가 0이 되어버렸던 것이 문제였다. `speed`를 목표 숫자에 맞게 잘 설정해주는 것이 중요했다.

Comments