cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              //Cache reference to window and animation items
// .animation-elements will be applied to any elements to animate
var $animation_elements = $('.animation-element');
var $window = $(window);

//The dollar sign in front of the variables is a convention to indicate that they hold a jQuery object, or collection of objects.

// Event handler to listen to scroll and resizing events
$window.on('scroll resize', check_if_in_view);

// detection function called initially when the DOM is ready and then every time we resize or scroll. 
function check_if_in_view() {
  // current height and top and bottom position of window to get the area we are looking at
  var window_height = $window.height();
  var window_top_position = $window.scrollTop();
  var window_bottom_position = (window_top_position + window_height);

  $.each($animation_elements, function() {
    var $element = $(this);
    // For each of these elements we collect its height and top and bottom position so we know where it is on the page
    var element_height = $element.outerHeight();
    var element_top_position = $element.offset().top;
    var element_bottom_position = (element_top_position + element_height);

    //check to see if this current container is within viewport
    if ((element_bottom_position >= window_top_position) &&
      (element_top_position <= window_bottom_position)) {
      $element.addClass('in-view');
    } else {
      $element.removeClass('in-view');
    }
  });
}

$window.on('scroll resize', check_if_in_view);
$window.trigger('scroll');
/* Use the jQuery trigger method to trigger a scroll event as soon as the DOM is ready. If any of the elements which should be animated are within the viewport, they will be detected as in view and the animation applied as if we had scrolled. */
            
          
!
999px
Loading ..................

Console