I am using a progress bar with Bootstrap and HTML. Below is the code snippet:
$(".progress-bar").each(function () {
var progressBar = $(this);
progressBar.animate({
width: progressBar.data('width') + '%'
}, 1500);
});
<body>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<div class='jumbotron' style='height:1400px' width='auto'>
<h1>please scroll down</h1>
</div>
<div class="alert alert-success">
<div class="skill-name">ON PROGRESS 357/487</div>
<div class="progress">
<div class="progress-bar progress-bar-primary" role="progressbar" data-width="70">
</div>
</div>
</div>
<div class="alert alert-danger">
<div class="skill-name">FAILED 30/487</div>
<div class="progress">
<div class="progress-bar progress-bar-danger" role="progressbar" data-width="30">
</div>
</div>
</div>
</body>
The issue I am facing is that the animation runs when the HTML loads, but I want it to only animate when I scroll down to view the progress bar. How can I achieve this?