I have a simple question as I'm not to deep into JS coding.
What is wrong with the following code-snippet and why isn't it executing as expected. (-> loading the charts as soon as they come into view)
var waypoint = new Waypoint({
element: document.querySelector("#chartcontainer"),
handler: function() {
$(".chart").easyPieChart({
scaleColor: false,
lineWidth: 20,
lineCap: "butt",
barColor: "#9b0000",
trackColor: "#ecf0f1",
size: 160,
animate: 1500
});
$(".count").each(function() {
var $this = $(this);
$({ Counter: 0 }).animate({
Counter: $this.text()
},{
duration: 1500,
easing: "swing",
step: function() {
$this.text(Math.ceil(this.Counter));
}
});
});
}
});
I don't understand what I have done wrong with my script. An explanation would be helpful for (maybe) future problems.
For the whole snippet and all the used libraries & frameworks, check out the corresponding codepen: https://codepen.io/toxicterror/pen/EJPjEQ