2016-04-18 10 views
0

Skrollr.jsで作業しています。そして、私はこのアニメーションを上下からスクロールするときに持っています:Skrollr.jsはスクロールアップ時に別のアニメーションを開始します

<div 
    class="flight-icon-d __d" 
    data-anchor-target=".section.__flight" 
    data-top-top="top: 126px; transform: translateX(-50%) rotate(-135deg) scale(0.35);" 
    data--50-top="transform: translateX(-50%) rotate(0deg) scale(0.35);" 
    data--150-top="top: 425px; transform: translateX(-50%) rotate(0deg) scale(1);" 
    data--550-top="top: 745px; transform: translateX(-50%) rotate(0deg) scale(1);" 
    data--780-top="top: 980px; transform: translateX(-50%) rotate(0deg) scale(0.35);"></div> 

私が上にスクロールすると、アニメーションが後方に移動します。スクロールアップでアニメーションを変更するにはどうすればよいですか?

答えて

0

animate.cssで以下のjsを使用できます。

JS

/* Check Which Section Visible on screen*/ 
    $(document).ready(function() { 
     var $animation_elements = $('.animate-box'); 
     var $window = $(window);  
     function check_if_in_view() { 
      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); 
       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');     
        var cls = ".in-view .animated"; 
        $(cls).each(function() { 
         var animationName = $(this).attr("animate");      
         if (animationName !== undefined) { 
          /* Chrome & Safari */ 
          $(this).css('-webkit-animation-duration', $(this).attr("duration")); 
          /*Mozila*/ 
          $(this).css('-moz-animation-duration', $(this).attr("duration")); 
          /*Opera*/ 
          $(this).css('-o-animation-duration', $(this).attr("duration")); 
          /* Chrome & Safari */ 
          $(this).css('-webkit-animation-delay', $(this).attr("delay")); 
          /*Mozila*/ 
          $(this).css('-moz-animation-delay', $(this).attr("delay")); 
          /*Opera*/ 
          $(this).css('-o-animation-delay', $(this).attr("delay")); 
          var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend'; 
          $(this).addClass(animationName).one(animationEnd, function() { 
           $(this).removeClass('animated ' + animationName) 
          }); 
         } 
        }); 
       } else { 
        $element.removeClass('in-view'); 
       } 
      }); 
     } 
     $window.on('scroll resize', check_if_in_view); 
     $window.trigger('scroll'); 
    }); 

HTMLのCODE:

<section id="section2" class="bg bg-2 animate-box">     
       <div class="box animated" animate="fadeIn" duration="2s" delay="1s" > ... </div> 
</section> 

DEMOのURL

http://plugins.auratechmind.net/scrolltoanimate 
関連する問題