Skip to main content
1 of 2
amon
  • 12.7k
  • 37
  • 67

Gah! Thanks for comming here.

Essentially, all your if-statements have the following structure:

if (scrolled > (($wheresThisAt)+(N * 20))){
    $('#salamander-(N + 1)').css('opacity', '1');

So we can comfortably roll that into a loop:

for (var i = 0; i < 35; i++) {
    if (scrolled <= ($wheresThisAt + i * 20)) {
        break;
    }
    $("#salamander-" + (i + 1)).css('opacity', '1');
}
amon
  • 12.7k
  • 37
  • 67