mackebryrsig
9/25/2017 - 4:09 PM

Section Scrolling effects

A simple javascript to smoothly scroll in pieces of the site when they get visible in the monitor.

$(document).on("scroll", function () {
  var pageTop = $(document).scrollTop(),
      pageBottom = pageTop + $(window).height(),
      tags = $("section");

  for (var i = 0; i < tags.length; i++) {
    var tag = tags[i];

    if ($(tag).position().top < pageBottom) {
      $(tag).addClass("visible");
    } else {
      $(tag).removeClass("visible");
    }
  }
});