bfintal / Counter-Up2

Counter-Up is a lightweight module that counts up to a targeted number when the number becomes visible.
MIT License
193 stars 65 forks source link

How can I use this counter in multiple times ? #20

Open bashar-lskit opened 1 year ago

bashar-lskit commented 1 year ago

This plugin is awesome, but I don't use the counter in multiple times.

octipus commented 1 year ago

yeah! same issue, if i use the same class .counter - it only animates the first elementwith that class.

ArchimidisM commented 1 year ago

Hello guys you can use the following code to modify the given one. Lets say that the class of the counter element is .animated_number__num

Instead of

const el = document.querySelector( '.animated_number__num' ) IO.observe( el )

Use this:

const elements = document.querySelectorAll('.animated_number__num'); elements.forEach(el => { IO.observe(el); });