After a fair amount of sweating and cutting together pieces from around the web, I came to this piece of code: https://pastebin.com/GNaJWySu
What it does is take all html elements in the page with a data-value attribute (e.g. <div data-value="50">), check if they're appearing on screen (using the scroll event listener), and run an animation counter inside them from 0 to the number of the data-value attribute.
It's all working, up to this point.
Problem is I need to remove the event for each specific html element after that element has come into view, but all I've tried didn't work.