2017-01-24 121 views
5

我在寻找类似于这个网站的jquery动画http://cuberto.com/。 到目前为止,我已通过pagePiling.js完成此链接http://codepen.io/mirmibrahim/pen/MJoGBY。任何人都可以帮我完成它在curberto上的方式。我不知道如何加载图像的一半和文本的一半,并打开下一节来自第一张幻灯片上的正方形动画。jquery动画页面打印

<html xmlns="http://www.w3.org/1999/xhtml"> 

<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <title>pagePiling.js plugin - Horizontal scroll</title> 
    <meta name="author" content="Alvaro Trigo Lopez" /> 
    <meta name="description" content="pagePiling.js plugin by Alvaro Trigo." /> 
    <meta name="keywords" content="pile,piling,piling.js,stack,pages,scrolling,stacking,touch,fullpile,scroll,plugin,jquery" /> 
    <meta name="Resource-type" content="Document" /> 

    <link rel="stylesheet" type="text/css" href="../jquery.pagepiling.css" /> 
    <link rel="stylesheet" type="text/css" href="examples.css" /> 

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> 
    <!--script src="../jquery-1.9.1.js"></script--> 


    <script type="text/javascript" src="../jquery.pagepiling.js"></script> 
    <script type="text/javascript"> 
    $(document).ready(function() { 

     /* 
     * Plugin intialization 
     */ 
     $('#pagepiling').pagepiling({ 
     direction: 'horizontal', 
     menu: '#menu', 
     scrollingSpeed: 2000, 
     anchors: ['page1', 'page2', 'page3', 'page4'], 
     sectionsColor: ['black', '#1C252C', '#F27B1D', '#39C'], 
     navigation: { 
      'position': 'right', 
      'tooltips': ['Page 1', 'Page 2', 'Page 3', 'Pgae 4'] 
     }, 
     afterRender: function() { 
      $('#pp-nav').addClass('custom'); 
      console.log("After Render "); 

     }, 
     afterLoad: function(anchorLink, index) { 

      // $.fn.pagepiling.setAllowScrolling(false); 
      console.log("After Load " + index); 
      if (index == 1) { 

      console.log("index " + index); 
      } else if (index == 2) { 

      } 

      if (index > 1) { 
      $('#pp-nav').removeClass('custom'); 
      } else { 
      $('#pp-nav').addClass('custom'); 
      } 
     }, 
     onLeave: function(index, nextIndex, direction) { 
      console.log("After Load " + index); 

      if (index == 1) { 

      /*     $("#block").animate({ 
             width: "100%", 
             opacity: 0.4, 
             marginLeft: "0.6in", 
             fontSize: "12em", 
             borderWidth: "20px" 
             }, 4000 , function() { 
       // Animation complete. 

        //alert("s"); 
       }); 
      */ 

      $("#block").animate({ 
       width: "58%" 
      }, 1000, function() { 
       console.log("animation finished"); 
       $.fn.pagepiling.setScrollingSpeed(500); 

      }); 

      } else if (index == 2 && nextIndex == 1) { 

      $("#block").animate({ 
       width: "0%" 
      }, 3000, function() { 
       console.log("animation finished"); 
       $.fn.pagepiling.setScrollingSpeed(2000); 

      }); 

      } 

     } 

     }); 
    }); 
    </script> 


    <style> 
    #section1 img { 
     margin: 20px 0; 
     opacity: 0.7; 
    } 
    /* colors 
    * --------------------------------------- */ 

    #colors2, 
    #colors3 { 
     position: absolute; 
     height: 163px; 
     width: 362px; 
     z-index: 1; 
     background-repeat: no-repeat; 
     left: 0; 
     margin: 0 auto; 
     right: 0; 
    } 

    #colors2 { 
     background-image: url(imgs/colors2.gif); 
     top: 0; 
    } 

    #colors3 { 
     background-image: url(imgs/colors3.gif); 
     bottom: 0; 
    } 
    /* Overwriting fullPage.js tooltip color 
    * --------------------------------------- */ 

    #pp-nav.custom .pp-tooltip { 
     color: #AAA; 
    } 
    </style> 

</head> 

<body> 
    <ul id="menu"> 
    <li data-menuanchor="page1" class="active"><a href="#page1">Page 1</a></li> 
    <li data-menuanchor="page2"><a href="#page2">Page 2</a></li> 
    <li data-menuanchor="page3"><a href="#page3">Page 3</a></li> 
    </ul> 


    <div id="pagepiling"> 
    <div class="section" id="section1"> 
     <!--img src="imgs/pagePiling-plugin.gif" alt="pagePiling" /--> 

     <div class="intro"> 
     <div> 
      <div style="background:#F6303F;border-left: thick solid #F6303F; height:150px; width:8px; margin-left:42%;" id="block"> 


      </div> 
      <h1 style="color: white;">DIGITAL</h1> 
      <p style="color: white;">CREATIVE AGENCY</p> 

     </div> 


     </div> 

    </div> 
    <div class="section"> 
     <div class="intro"> 
     <h1>Simple to use</h1> 
     <p>Just use the option direction: 'horizontal' to have it working!</p> 
     </div> 
    </div> 
    <div class="section" id="section3"> 
     <div class="intro"> 
     <h1>Isn't it great?</h1> 
     <p>Just as you expected!</p> 
     <div id="colors2"></div> 
     <div id="colors3"></div> 
     </div> 
    </div> 
    </div> 

</body> 

</html> 
+0

你的codepen看起来对我来说工作正常,你的要求是什么? –

+0

如果你能看到第一页,红线扩展应该打开其中的一半,下半部分出现在左边的动画中,我被困在它上面。 – ibrahim

+0

基于BuiltWith搜索,它们似乎使用skrollr,历史记录js和greensock。 – rawnewdlz

回答

0

我想pagepiling.js可能是错误的方向,因为它只是一个动画页面上,而不是两个页面之间的动画。

我过去处理过的东西的方式是使用PJAX插件,如Barba.JS,它允许您在站点导航事件之间添加动画过渡。 Barba通过手动更改URL,为新页面抓取新内容以及在旧页面和新页面之间执行转换(您可以为Cuberto这样的元素创建动画)来劫持页面更改。

让我知道这是否有用,或者如果我错过了这一点,我会尝试相应地更新我的答案!

编辑:刚才意识到这是一个七个月的问题,但希望这对别人有帮助!