码迷,mamicode.com
首页 > Web开发 > 详细

JQuery插件之Animate.css和 jquery-aniview

时间:2017-04-23 16:50:00      阅读:266      评论:0      收藏:0      [点我收藏+]

标签:动画特效   应该   ready   head   快速   lint   function   lin   rom   

Animate.css 一款强大的预设css3动画库

简介

animate.css 是一个来自国外的 CSS3 动画库,它预设了抖动(shake)、闪烁(flash)、弹跳(bounce)、翻转(flip)、旋转(rotateIn/rotateOut)、淡入淡出(fadeIn/fadeOut)等多达 60 多种动画效果,几乎包含了所有常见的动画效果。

虽然借助 animate.css 能够很方便、快速的制作 CSS3 动画效果,但还是建议看看 animate.css 的代码,也许你能从中学到一些东西。

兼容

浏览器兼容:当然是只兼容支持 CSS3 animate 属性的浏览器,他们分别是:IE10+、Firefox、Chrome、Opera、Safari。

使用方法

1、引入文件

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

2、HTML 及使用

<div class="animated bounce" id="dowebok"></div>

给元素加上 class 后,刷新页面,就能看到动画效果了。animated 类似于全局变量,它定义了动画的持续时间;bounce 是动画具体的动画效果的名称,你可以选择任意的效果。

如果动画是无限播放的,可以添加 class infinite。

你也可以通过 JavaScript 或 jQuery 给元素添加这些 class,比如:

$(function(){
    $(‘#dowebok‘).addClass(‘animated bounce‘);
});

有些动画效果最后会让元素不可见,比如淡出、向左滑动等等,可能你又需要将 class 删除,比如:

$(function(){
    $(‘#dowebok‘).addClass(‘animated bounce‘);
    setTimeout(function(){
        $(‘#dowebok‘).removeClass(‘bounce‘);
    }, 1000);
});

animate.css 的默认设置也许有些时候并不是我们想要的,所以你可以重新设置,比如:

#dowebok {
    animate-duration: 2s;    //动画持续时间
    animate-delay: 1s;    //动画延迟时间
    animate-iteration-count: 2;    //动画执行次数
}

文档转载与插件下载:http://www.dowebok.com/demo/2014/98/

 


 

jQuery页面滚动元素进入视口发生动画特效插件: jquery-aniview

简要教程 jquery-aniview是一款非常实用的页面滚动元素进入视口发生动画特效jQuery插件。该插件基于animate.css,你可以使用animate.css中所有的动画过渡效果。该插件会检测指定元素是否进入视口,在元素进入视口时则执行指定的动画效果。

使用方法

使用jquery-aniview插件需要引入animate.cssjQueryjquery.aniview.min.js文件。

<link type="text/css" rel="stylesheet" href="css/animate.min.css">
<script language="JavaScript" src="js/jquery-1.10.2.js">
</script><script type="text/javascript" src="js/jquery.aniview.min.js"></script>

HTML结构

可以使用一个<div> 来作为动画元素的包裹元素。 为该元素设置class为aniview,av-animation用于设置animate.css的动画过渡效果的class名称:

<div class="aniview" av-animation="slideInRight"></div>  

一个典型页面的例子应该像下面这样:

  1. <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>My AniView Page</title>
        <link type="text/css" rel="stylesheet" href="animate.css">
        <script type="text/javascript" src="jquery.min.js"></script>
        <script type="text/javascript" src="jquery.aniview.min.js"></script>
        <script>
            $(document).ready(function(){
                $(.aniview).AniView();
            });
        </script>
    </head>
    <body>
        <div>
            <p class="aniview" av-animation="slideInRight">
                This is my awesome animated element!
            </p>
        </div>
    </body>
    </html> 

初始化插件

在页面DOM元素加载完毕之后,可以通过下面的方法来初始化该插件。

$(‘.aniview‘).AniView();   

 


或者在初始化的时候设置一些配置参数:

var options = {
    animateThreshold: 100,
    scrollPollInterval: 50
}
$(‘.aniview‘).AniView(options); 

配置参数

参数 类型 描述 默认值
animateThreshold int 正数值表示元素进入视口指定的像素值之后才会触发动画序列,负数值表示在元素进入视口之前多少像素就触发动画序列 0
scrollPollInterval int 测试用户滚动的频率。单位毫秒,这是jQuery内置的"scroll"事件的延伸 20

 

 

 

注意:任何在页面加载时就处于视口当中的元素会立刻被触发动画序列。


文档转载与插件下载:http://www.htmleaf.com/jQuery/Layout-Interface/201509092547.html


 

JQuery插件之Animate.css和 jquery-aniview

标签:动画特效   应该   ready   head   快速   lint   function   lin   rom   

原文地址:http://www.cnblogs.com/Lv2017/p/6752828.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!