progressbar.js
progressbar.js copied to clipboard
How to start the animation only when the circle appears in browser's view (on scrolling)?
How can i animate circle while scrolling down to page ? My page is quite long and this plugin come just above the footer, but it animate, when page loads and when scroll down, can not see the circle progress effect ?
I have the same doubt! Want the progressBar start the animation when it appears on the screen.
You would need to use an Intersectional Observer
If you're using jQuery, have a look at the jquery-appear plug-in. It will achieve what you're looking for.
@dearsina
If you're using jQuery, have a look at the jquery-appear plug-in. It will achieve what you're looking for.
I saw the plugin. But i don't understand how to integrate with it. Can you write me the code i need?
Try something like this:
// Enable element's appearance to be a triggering event
$.appear('.progress-bar-class-name');
// Set up a listener to the load-more-button appearing
$('.progress-bar-class-name').on('appear', function(event, all_appeared_elements) {
//Put your progressbar initiate code here. Will only trigger once the bar is visible.
});
Try something like this:
// Enable element's appearance to be a triggering event $.appear('.progress-bar-class-name'); // Set up a listener to the load-more-button appearing $('.progress-bar-class-name').on('appear', function(event, all_appeared_elements) { //Put your progressbar initiate code here. Will only trigger once the bar is visible. });
I am failed to work with it.
This may not be the right forum for it, perhaps ask a question on StackOverflow and list what you tried and what errors you're getting. Feel free to tag me and I will try to help.
Like this using sal:
import sal from 'sal.js'
if (document.querySelector('.progress-circle') != null) {
sal({
selector: '.progress-circle'
});
document.addEventListener('sal:in', ({ detail }) => {
let circle = new ProgressBar.Circle(detail.target, {
// options...
}
});
circle.animate();
});
}