-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only counts the first element with the class "counter" #13
Comments
I've also found this issue. Using this with Wordpress ACF Repeater Fields and I have 4 columns in a loop. Only the first is using the counter, the rest do not. |
Same |
Had the same issue, used the following code to make it work-
|
Please check my last message. |
From the example in the readme file with Intersection Obersver:
This only targets one element. If you want to add to multiple elements you need to add a loop inside the if statement. Say you have the following in HTML:
Then your javascript goes as follows:
This should work for you. |
@joelveloso Thanks, that makes all elements with .counter count, however they count all simultaneously and not when each an one of the elements come into viewport. Any hints how to accomplish that? |
To use on multiple elements throughout a page, give each a new class name (e.g. 'counter2, counter3, etc.) and amend the bottom of the initialization script like this: const el = document.querySelector( '.counter' ); |
I'd also be keen on this, could anyone provide an example please? |
The solution by @joelveloso works for me however on pages that do not have the counter I get the following error: Uncaught TypeError: Failed to execute 'observe' on 'IntersectionObserver': parameter 1 is not of type 'Element'. Any ideas on how to address this? |
I have three numbers next to each other I want to count up, but only the first one is counting. I tested this with adding an fourth one on top and only that one was counted.
How can I archive that all numbers with the "counter" class get counted up?
I was using the previevs version "counterUp" and all numbers where counted but, but I had an issue that the final numbers change after scrolling, that is why I switched to "counterUp 2.
The text was updated successfully, but these errors were encountered: