Sha256: 7706161f26292519f644dcaa1610ffdbbb5125d0c421ce8119b3d4f4ff8d3563

Contents?: true

Size: 886 Bytes

Versions: 5

Compression:

Stored size: 886 Bytes

Contents

$(document).ready(function() {
  var element = document.getElementById("js-fadeInElement");
  $(element).addClass('js-fade-element-hide');

  $(window).scroll(function() {
    if( $("#js-fadeInElement").length > 0 ) {
      var elementTopToPageTop = $(element).offset().top;
      var windowTopToPageTop = $(window).scrollTop();
      var windowInnerHeight = window.innerHeight;
      var elementTopToWindowTop = elementTopToPageTop - windowTopToPageTop;
      var elementTopToWindowBottom = windowInnerHeight - elementTopToWindowTop;
      var distanceFromBottomToAppear = 300;

      if(elementTopToWindowBottom > distanceFromBottomToAppear) {
        $(element).addClass('js-fade-element-show');
      }
      else if(elementTopToWindowBottom < 0) {
        $(element).removeClass('js-fade-element-show');
        $(element).addClass('js-fade-element-hide');
      }
    }
  });
});

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
refills-0.2.0 source/javascripts/refills/fade_in.js
breezeblocks-0.0.4 source/javascripts/breezeblocks/fade_in.js
breezeblocks-0.0.2 source/javascripts/breezeblocks/fade_in.js
breezeblocks-0.0.1 source/javascripts/breezeblocks/fade_in.js
refills-0.1.0 source/javascripts/refills/fade_in.js