Your problem lies here:
function addHeight() {
$(window).on("scroll", function() {
var i = 0,
line = $(".fuckinLine");
while (i < 209) {
line.css("height", i++ + "px");
event.preventDefault();
console.log("addHeight works");
}
});
}
You had already set an event for $(window).on("scroll", function() {
in the init function. By doing this you were essentially doing the addHeight function twice every time the window scrolled.
This should work for you:
/*========== scrolling function ==========*/
function scrolling() {
console.log(getScrollTop());
addHeight(getScrollTop());
//Great place for logic to addwidth to make the line move horizontally.
}
/*========== ========== ==========*/
/*========== add height to line ==========*/
function addHeight(newHeight) {
$(".fuckinLine").css("height", newHeight + "px");
}
/*========== ========== ==========*/
Notice I also removed the while loop. This will keep the div from growing to the max height after one scroll. We only want this to expand 1px for each pixel down the window scrolled.