Pages

Simple scrollorama alternative

Simple scrollorama alternative with Jquery and CSS 3 Animations for Biginners and everyone with add and remove classes

<script type="text/javascript">
(function($) {
  $.fn.visible = function(partial) {
    
      var $t            = $(this),
          $w            = $(window),
          viewTop       = $w.scrollTop(),
          viewBottom    = viewTop + $w.height(),
          _top          = $t.offset().top,
          _bottom       = _top + $t.height(),
          compareTop    = partial === true ? _bottom : _top,
          compareBottom = partial === true ? _top : _bottom;
    
    return
((compareBottom <= viewBottom) && (compareTop >= viewTop));
  };
    
})(jQuery);
$(window).scroll(function(event) {
if($("#mobidien").css("display") == "none"){
  
  $(".grid_4").each(function(i, el) {
    var el = $(el);
    if (el.visible(true)) {
      el.addClass("fadeIn"); 
    } 
 else{
 el.removeClass("fadeIn"); 
 }
  });
  
  $(".rightx").each(function(i, el) {
    var el = $(el);
    if (el.visible(true)) {
      el.addClass("fadeIn"); 
    } 
 else{
 el.removeClass("fadeIn"); 
 }
  });  
}});
  </script>

No comments:

Post a Comment

Search This Blog