Advertisement
Guest User

counter javascript

a guest
Aug 22nd, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1.  
  2. //---------------- COUNTER LOGIC----------------------
  3. function runAnimtion() {
  4. anime({
  5. targets: '.counter-1',
  6. textContent: [0, 42],
  7. round: 1,
  8. easing: 'linear',
  9. duration: 1000
  10. });
  11. }
  12.  
  13. const observer = new IntersectionObserver(
  14. entries => {
  15. entries.forEach(entry => {
  16. if (entry.intersectionRatio >= 0.7) {
  17. runAnimtion();
  18. observer.disconnect();
  19. }
  20. });
  21. }, {
  22. threshold: 0.7
  23. }
  24. );
  25.  
  26. observer.observe(document.querySelector('.target-section'));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement