简体   繁体   English

将animate.css库与jquery mobile一起使用以实现页面转换

[英]using animate.css library with jquery mobile to achieve page transitions

Hello folks at Stack Overflow from all over the world! 来自世界各地的Stack Overflow大家好! hope you´re all doing great! 希望大家都做得很好! I just have one inquiry today. 我今天只有一个查询。 I just found out about an awesome css3 library called animate.css http://daneden.github.io/animate.css/ which I am trying to implement with jquery mobile to custome my apps page transitions. 我刚刚发现了一个很棒的css3库,名为animate.css http://daneden.github.io/animate.css/ ,我正在尝试使用jquery mobile实现该自定义我的应用程序页面转换。 I'm trying to go from one page to another with an animate.css class applied to the page div but after the fancy transition occured the page remains on same page and does not reach the targeted page. 我试图通过将animate.css类应用于页面div从一个页面转到另一个页面,但是在发生花哨的过渡之后,该页面仍保留在同一页面上,并且没有到达目标页面。 If anyone out there has any clue on how to achieve this, please let me know. 如果有人对如何实现这一目标有任何线索,请告诉我。 Thanks Here the code: 谢谢这里的代码:

CSS: CSS:

<link href="./css/animate.css" rel="stylesheet" / > <link href="./css/animate.css" rel="stylesheet" / >

Javascript: 使用Javascript:

<script language="javascript">
    $(function() {
        $("a#home").click(function() {
            animate(".box-a", 'rotateOutDownRight');
            return false;
        });

    });

    function animate(element_ID, animation) {
        $(element_ID).addClass(animation);
        var wait = window.setTimeout( function(){
            $(element_ID).removeClass(animation)}, 1300
        );
    }
</script>

HTML: HTML:

<!------- HOME PAGE ----------------------------------------> 

<div data-role="page" id="home" data-theme="c" class="box-a animated"> <!--Inicia pagina home -->
  <div data-role="header"><h1>Animate</h1></div>  

  <div data-role="content">

    <p><a id="home" href="#pagina2">Box A will flash, click here!</a></p>

    <a id="home" href="#pagina2" data-role="button">PAGE 2 W/ANIMATION.CSS</a>
    <a href="#pagina2" data-role="button">PAGE 2 W/O ANIMATION.CSS</a>            
  </div>      <!-- End of div content -->

  <div data-role="footer" data-position="fixed"><h3>Animate</h3></div>         
</div>

<!----- PAGE  2  -----------------------> 

<div data-role="page" id="pagina2" data-theme="c"> <!--Inicia pagina home -->
  <div data-role="header"><h1>Animate</h1></div>  

  <div data-role="content">

    <p>PAGE 2</p>    

  </div>  <!-- End of div content -->

  <div data-role="footer" data-position="fixed"><h3>Animate</h3></div>         
</div>

URL: see an example here: http://apps.alfonsopolanco.com 网址:在此处查看示例: http//apps.alfonsopolanco.com

jQM allows you to define custom transition ( http://demos.jquerymobile.com/1.2.0/docs/pages/page-customtransitions.html ). jQM允许您定义自定义过渡( http://demos.jquerymobile.com/1.2.0/docs/pages/page-customtransitions.html )。 Using animate.css for this is no problem. 为此使用animate.css没问题。

Add 2 css rules that reference the desired transition from animate.css: 添加2个CSS规则,这些规则引用从animate.css进行的所需过渡:

.customRotate.in {
    -webkit-transform: translateX(0);
    -moz-transform: translateX(0);
    -webkit-animation-name: rotateInUpRight;
    -moz-animation-name: rotateInUpRight;
}
.customRotate.out {
    -webkit-transform: translateX(0);
    -moz-transform: translateX(0);
    -webkit-animation-name: rotateOutDownRight;
    -moz-animation-name: rotateOutDownRight;
}

Then simply set the data-transition attribute on the anchor tag to the name of your new transition: 然后只需将anchor标签上的data-transition属性设置为新过渡的名称:

<a id="home" href="#pagina2" data-role="button" data-transition="customRotate">PAGE 2 W/ANIMATION.CSS</a>

Here is a DEMO 这是一个演示

UPDATE: To control the speed of the transition: 更新:要控制转换的速度:

.in {
    -webkit-animation-timing-function: ease-out;
    -webkit-animation-duration: 750ms;
    -moz-animation-timing-function: ease-out;
    -moz-animation-duration: 750ms;
}

.out {
    -webkit-animation-timing-function: ease-in;
    -webkit-animation-duration: 555ms;
    -moz-animation-timing-function: ease-in;
    -moz-animation-duration: 555;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM