Delay jQuery countup until in view?

Hi there,

I have the following jQuery countup which works, but would prefer it to start counting up when the user scrolls down and views the numbers rather than starting as son as the page loads.

Is this possible?

This is the fiddle:
https://jsfiddle.net/Lfzgeqr1/

Does anyone know how I can make it start when in view?

May thanks!

1 Like

This may be wide of the mark but you can use Intersection observer to tell when something is in view.

I just borrowed the code so I’m sure one of the js gurus here can double check its correct :slight_smile:

2 Likes

That get the seal of approval from me.

4 Likes

Why put so many <br> tags when you can just use one line off CSS for that?

I guess it was just a quick and dirty demo to move the counter out of view as though real content was in front.

I doubt it was for real world usage where you should not do such a thing:slight_smile:

1 Like