Skip to content

integralvision/jquery.fade-on-scroll

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

jquery.fade-on-scroll

By default, this plugin doesn't provide any animations or CSS to load elements. This plugin only toggle classes on elements.

Load plugin and its' dependencies.

<!-- Place somewhere in the <head> of your document -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script src="jquery.fade-on-scroll.js"></script>

Examples

Fade a single element

<div class="fade-on-scroll">
  <img src="http://placehold.it/350x150" />
</div>
$(document).ready(function() {
  $('.fade-on-scroll').fadeContentOnScroll();
});
</script>

Fade elements in a block

<div class="fade-on-scroll-multiple">
  <div class="fade-element">
    <img src="http://placehold.it/350x150" />
  </div>
  <div class="fade-element">
    <img src="http://placehold.it/350x150" />
  </div>
  <div class="fade-element">
    <img src="http://placehold.it/350x150" />
  </div>
</div>
$(document).ready(function() {
  $('.fade-on-scroll-multiple').fadeContentOnScroll({
    elements: '.fade-element'
  });
});
</script>

Config through attributes

<div class="fade-on-scroll-multiple" data-fade-elements=".fade-element">
  <div class="fade-element">
    <img src="http://placehold.it/350x150" />
  </div>
  <div class="fade-element">
    <img src="http://placehold.it/350x150" />
  </div>
  <div class="fade-element">
    <img src="http://placehold.it/350x150" />
  </div>
</div>
$(document).ready(function() {
  $('.fade-on-scroll-multiple').fadeContentOnScroll();
});
</script>

Auto init configured by attributes

<div data-toggle="fade-on-scroll" data-fade-elements=".fade-element">
  <div class="fade-element">
    <img src="http://placehold.it/350x150" />
  </div>
  <div class="fade-element">
    <img src="http://placehold.it/350x150" />
  </div>
  <div class="fade-element">
    <img src="http://placehold.it/350x150" />
  </div>
</div>

Settings

settings type default description
elements `string null` null
startClass string 'fade-start' This class will be added to the element to animate. Marks "this element will be animated"
readyClass string false This class will be added when loading animation is ready.
threshold 0 <= {number} >= 1 0.4 Start class will be removed when this percentage of the element's height is visible.
length number 400 The length of animation in milliseconds.
delay number 250 The delay between fading elements when multiple element should be loaded.

Setup with attributes

settings attribute name
elements data-fade-elements
startClass data-fade-start-class
readyClass data-fade-ready-class
threshold data-fade-threshold
length data-fade-length
delay data-fade-delay

Events triggered

Event name description
fade-on-scroll.init Triggered on the element the plugin is initialized when plugin preparation is ready.
fade-on-scroll.init-element Triggered on the fading elements when the plugin preparation is ready.
fade-on-scroll.loading Triggered on the fading elements when loading starts (when startClass is removed).
fade-on-scroll.loaded Triggered on the fading elements when loading ready (after startClass is removed delayed by length).

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published