In the footer of my site I'm using counUp.js (Link: http://inorganik.github.io/countUp.js/ ) to count up three numbers. I added this code at the bottom of the site:
<script type="text/javascript">
var c1 = new countUp("upnum1", 1, 27, 0, 4);
var c2 = new countUp("upnum2", 1, 10, 0, 4);
var c3 = new countUp("upnum3", 1, 27, 0, 4);
var c4 = new countUp("upnum4", 1, 1000, 0, 4);
window.onload = function() {
c1.start();
c2.start();
c3.start();
c4.start();
}
</script>
This works well, but starts counting once the page is loaded of course. How do I manage to fire this effect when the containing div of the numbers is 'in view' and not when the page is loaded? Tried several jQuery things but can't find a working solution... Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…