animate.css动画默认为fadein

时间:2017-10-26 04:22:59

标签: javascript jquery animation handlebars.js animate.css

我有一个我想要动画的标题。我正在添加类'动画'和'bounceInUp'来实现我想要的。但是,出于某种原因,我正在动画的元素没有执行正确的动画。他们都默认为'fadeIn'动画。我使用快速和把手来渲染视图,然后我使用jQuery来操作所述视图。以下是我的观点:

<div class='heading'>
  <div class='container-fluid'>

    <h1 class='cool-heading'>
      <span>P</span>
      <span>h</span>
      <span>r</span>
      <span>e</span>
      <span>s</span>
      <span>h</span>
      <span>N</span>
      <span>e</span>
      <span>w</span>
      <span>s</span>
    </h1>

  </div>
</div>

<div class='articles'>
  <div class='articles-inner container'>
    <!-- articles will go here -->
  </div>
</div>

{{#each scripts}}
  <script type="text/javascript" src="{{script}}"></script>
{{/each}}

这是我的js:

$(document).ready(function(){
  var count = 1;
  $('.cool-heading').children('span').each(function(){
    var delay = (count / ( $('.cool-heading').children('span').length) ) + 's';
    $(this).css({'-webkit-animation-delay': delay,'animation-delay': delay});
    $(this).attr('class','animated bounceInUp');
    count++;
  });
});

如果有人能发现错误,我也有一个main.handlebars布局:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Mongo Scraper</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css">
    <link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet">
    <link rel="stylesheet" href="css/style.css">
  </head>
  <body>

    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>


    {{{body}}}




  </body>
</html>

1 个答案:

答案 0 :(得分:0)

原来,spans(内联元素)无法正确设置动画。我向css添加了'display:inline-block'以获得所需的功能。