I have a progress bar that animates when the page loads, but I want it to be animated when the user scrolls to it, since it will be in the middle of the page. Right now, if the page loads, the user does not see the animation.
Thus, the animation should be paused until the user scrolls to a certain point, as soon as the panel appears, the animation starts.
Here is the Javascript that I have so far:
$(function() { $(".meter > span").each(function() { $(this) .data("origWidth", $(this).width()) .width(0) .animate({ width: $(this).data("origWidth") }, 1200); }); });
Here is a more detailed jsfiddle: http://jsfiddle.net/YAZJb/
source share