Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to start the animation only when the circle appears in browser's view (on scrolling)? #265

Open
asif-jalil opened this issue May 22, 2020 · 8 comments

Comments

@asif-jalil
Copy link

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 ?

@christopher-alves-dev
Copy link

I have the same doubt! Want the progressBar start the animation when it appears on the screen.

@roryaherne
Copy link

You would need to use an Intersectional Observer

@dearsina
Copy link

If you're using jQuery, have a look at the jquery-appear plug-in. It will achieve what you're looking for.

@asif-jalil
Copy link
Author

@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?

@dearsina
Copy link

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.
    });

@asif-jalil
Copy link
Author

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.

@dearsina
Copy link

dearsina commented Jun 7, 2020

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.

@nicolaskopp
Copy link

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();
        });
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants