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

Animate in accordion #205

Open
jmashcroft opened this issue Oct 15, 2018 · 1 comment
Open

Animate in accordion #205

jmashcroft opened this issue Oct 15, 2018 · 1 comment

Comments

@jmashcroft
Copy link

jmashcroft commented Oct 15, 2018

I'm using this with a jquery accordion. each section in the accordion has a chart but i only want the chart to animate on opening of the section it resides in. is this possible?

@MarioPerini
Copy link

MarioPerini commented Dec 5, 2018

You have to initialize them on the accordion event.
I had the same "issue" on TAB's so i initialize some charts "on load" and some on the Tab callback event.
To start on load i add the class '.onload'.

So my initialization looks like this:

$(function () {
    function startAnimateCharts(inside) {
        if (inside===undefined) {
            $('.percentage.onload').each(function () {
                initChart(this);
            });
        }else {
            $(inside).find('.percentage').each(function () {
                initChart(this);
            });
        }
    }
    function initChart(elem) {
        $(elem).easyPieChart({
            animate: 1000,
        });
    }
    startAnimateCharts();
    $('a[data-toggle="tab"]').on('show.bs.tab', function () {
        startAnimateCharts($(this).attr('href'))
    });
});

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

2 participants