Chartjs-Chart.js animation loading

0👍

Try this way:

var vis=0;
$( document ).scroll(function() {
    if(isScrolledIntoView(document.getElementById('your-element'))){
        if(vis==0){

        //your code            

        vis=1;
        }
    }
});

function isScrolledIntoView(el) {
    var rect = el.getBoundingClientRect();
    var elemTop = rect.top;
    var elemBottom = rect.bottom;

    var isVisible = (elemTop >= 0) && (elemBottom <= window.innerHeight);
    return isVisible;
}

Leave a comment