初识Velocity动画,感觉它并没有那么强大,但是渐渐感觉它的ui动画可以让我们简易的使用到我们的项目中。

Velocity动画的简介:

  下载地址:http://www.julian.com/research/velocity/

  兼容性:IE8 和 Android2.3

  官网的配置代码:

  

require.config({
    paths: {
        "jquery": "/path/to/jquery-x.x.x",
        "velocity": "path/to/velocity",
        // Optional, if you're using the UI pack:
        "velocity-ui": "path/to/velocity.ui"
    },
    shim: {
        "velocity": {
            deps:
[ "jquery" ]
        },
        // Optional, if you're using the UI pack:
        "velocity-ui": {
            deps:
[ "velocity" ]
        }
    }
});

require([ "jquery", "velocity", "velocity-ui" ], function ($, Velocity) {
    /* Your
app code here. */
    $("body").velocity({ opacity: 0.5 });
});

Velocity.js的基本用法:

    1.引入jQuery.js库

    2.引入velocity.min.js库

    3.引入velocity.ui.min.js库

    官网用法代码:

$element.velocity({
    width: "500px",
    property2: value2
}, {
    /* Velocity's default options */
    duration: 400,
    easing: "swing",
    queue: "",
    begin: undefined,
    progress: undefined,
    complete: undefined,
    display: undefined,
    visibility: undefined,
    loop: false,
    delay: false,
    mobileHA: true
});

  第一个参数 为 CSS属性

  第二个参数为 velocity 配置选项

  

  duration : 400 动画时长

  easing : “swing”

  queue : “”

  begin: undefined

  progress: undefined

  complete: undefined

  display: undefined

  visibility: undefined

  loop: false

  delay: false 动画延迟时间

  mobileHA: true

制作动画序列的三种方法:

  前面两种省略。

  我想把最好的方式推荐给大家:

  官网的示例代码:

  var mySequence = [

    {e: $element1, p: {translateX: 100}, o:{duration: 1000}},

    {e: $element2, p: {translateX: 200}, o:{duration: 1000, sequenceQueue: false}},

    {e: $element3, p: {translateX: 300}, o:{duration: 1000}}

  ];

  $.Velocity.RunSequence(mySequence);

  1.创建一个动画序列

  var seq = [

    {

      elements : $('#div1'),

      properties : { width: '300px' },

      options : { duration : 1000 }

    },

    {

      elements : $('#div1'),

      properties : { width: '300px' },

      options : { duration : 1000 }

    },

    {

      elements : $('#div1'),

      properties : { width: '300px' },

      options : { duration : 1000 }

    }

  ];

  2.运行动画序列 seq

    $.Velocity.RunSequence(seq);

预定义动画和自定义动画:

  1.预定义动画

    $('#div1').on('mouseover',function(){

      $(this).velocity('callout.shake');

    });

  还有很多预定义动画,这里我根据官网一一列举一下:

callout.bounce

callout.shake

callout.flash

callout.pulse

callout.swing

Callout.tada

transition.fadeIn

transition.fadeOut

transition.flipXIn

transition.flipXOut

transition.flipYIn

transition.flipYOut

transition.flipBounceXIn

transition.flipBounceXOut

transition.flipBounceYIn

transition.flipBounceYOut

transition.swoopIn

transition.swoopOut

transition.whirlIn

transition.whirlOut

transition.shrinkIn

transition.shrinkOut

transition.expandIn

transition.expandOut

transition.bounceIn

transition.bounceOut

transition.bounceUpIn

transition.bounceUpOut

transition.bounceDownIn

transition.bounceDownOut

transition.bounceLeftIn

transition.bounceLeftOut

transition.bounceRightIn

transition.bounceRightOut

transition.slideUpIn

transition.slideUpOut

transition.slideDownIn

transition.slideDownOut

transition.slideLeftIn

transition.slideLeftOut

transition.slideRightIn

transition.slideRightOut

transition.slideUpBigIn

transition.slideUpBigOut

transition.slideDownBigIn

transition.slideDownBigOut

transition.slideLeftBigIn

transition.slideLeftBigOut

transition.slideRightBigIn

transition.slideRightBigOut

transition.perspectiveUpIn

transition.perspectiveUpOut

transition.perspectiveDownIn

transition.perspectiveDownOut

transition.perspectiveLeftIn

transition.perspectiveLeftOut

transition.perspectiveRightIn

transition.perspectiveRightOut

  2.自定义动画:

    官网推荐代码:

    $.Velocity.RegisterEffect(name,{

      defaultDuration : duration ,

      calls : [

        [ { property : value }, durationPercentage, {options} ],

        [ { property : value }, durationPercentage, {options} ]

      ],

      reset : { property : value, property : value }

    });

  下面是我写的代码:

  $.Velocity.RegisterEffect ( 'jiangbo.pulse', {

    defaultDuration : 300,

    calls : [

      [ { scaleX : 1.1 }, 0.5 ],

      [ { scaleX : 1.0 }, 0.5 ]

    ]

  } );

  $('#div1').on('mouseover',function(){

    $(this).velocity('jiangbo.pulse');

  });

jQuery-velocity.js 插件的简易使用的更多相关文章

  1. 【PC端】jQuery+PHP实现浏览更多内容(jquery.more.js插件)

    参数说明: 'amount' : '10', //每次显示记录数 'address' : 'comments.php', //请求后台的地址 'format' : 'json', //数据传输格式 ' ...

  2. jQuery.cookie.js插件了解及使用方法

    jquery.cookie.js插件实现浏览器的cookie存储,该插件是基于jquery开发,方便cookie使用. jquerycookie.js的下载地址 http://plugins.jque ...

  3. 购物车增加、减少商品时动画效果:jQuery.Fly.js插件使用方法

    某些电商网站加入购物车和减少购物车商品数量时,有个小动画,以抛物线形式增减,如图:      这里用到了第三方jQuery.Fly.js插件(底层依赖Jquery库,地址:https://github ...

  4. jquery.autocomplete.js 插件的自定义搜索规则

    这二天开始用jquery.autocomplete这个自动完成插件.功能基本比较强大,但自己在实际需求中发现还是有一处不足!问题是这样:当我定义了一个本地数据JS文件时,格式为JSON式的数组.如下: ...

  5. 异步上传图片,光用jquery不行,得用jquery.form.js插件

    异步上传图片,光用jquery不行,得用jquery.form.js插件,百度一下下载这个插件,加jquery,引入就可以了 <form id="postbackground" ...

  6. 整屏滚动效果 jquery.fullPage.js插件+CSS3实现

    最近很流行整屏滚动的效果,无论是在PC端还是移动端,本人也借机学习了一下,主要通过jquery.funnPage.js插件+CSS3实现效果. 本人做的效果: PC端:http://demo.qpdi ...

  7. ajax请求执行完成后再执行其他操作(jQuery.page.js插件使用为例)

    就我们做知,ajax强大之处在于它的异步请求,但是有时候我们需要ajax执行彻底完成之后再执行其他函数或操作 这个时候往往我们用到ajax的回调函数,但是假如你不想或者不能把接下来的操作写在回调函数中 ...

  8. jquery.validate.js插件的使用方法

    近期做项目.须要用到 jQuery.validate.js插件,于是记录一下工作中的一些经验,以便日后学习. [样例例如以下] 1.前台页面 <form id="form1" ...

  9. jQuery通过jquery.form.js插件使用AJAX提交Form表单

    我简单使用了一下,jQuery Form插件有一下优点:  1.支持提交前验证. 2.支持提交后回调. 3.采用AJAX方式,有很好的用户体验 4.提交方式是灵活.只要指定要提交的form ID即可. ...

随机推荐

  1. 用CSS里的 viewport-fit 标签应对iPhone X 的刘海

    iPhone X 配备一个覆盖整个手机的全面屏,顶部的“刘海”为相机和其他组件留出了空间.然而结果就是会出现一些尴尬的情景:网站被限制在一个“安全区域”,在两侧边缘会出现白条儿.移除这个白条儿也不难, ...

  2. G - 生日蛋糕

    7月17日是Mr.W的生日,ACM-THU为此要制作一个体积为Nπ的M层生日蛋糕,每层都是一个圆柱体. 设从下往上数第i(1 <= i <= M)层蛋糕是半径为Ri, 高度为Hi的圆柱.当 ...

  3. MacTex TexStudio Configuration 配置

    在Mac上使用Latex的话主流是安装MacTex,对于IDE的选择有很多,像什么自带的TexShop,或者是TexStudio,Latexian,Texpad,Texmaker等,甚至可以直接使用一 ...

  4. ssh 管理 linux登录远程服务器

    使用 ssh 免秘登录方式 客户端:1. 生成公钥和私钥 ssh-keygen 一般不需要对私钥设置口令(passphrase),如果担心私钥的安全,这里可以设置一个. 运行结束以后,在$HOME/. ...

  5. linux 常用 掌握要点 详细终结

    linux 命令大全 每个开发者应该了解的 10 个 Linux 命令 1.查看正在执行的进程(Process) ps命令 Process Status 进程状态 语法: ps  [option]   ...

  6. python如何去掉字符串‘\xa0’

    发现问题: 最近在用爬虫爬取网页信息时,在网页源码中遇到了“&nbsp"字符串,经查阅,发现该字符是不间断空格符.我们通常所用的空格是 \x20 ,是在标准ASCII可见字符 0x2 ...

  7. bochs

    ● 制作一个硬盘 ./bximage 步骤与制作软盘的相似,完成后将bochs软件提示的最后一句话,添加到自己的配置文件里: dd if=loader.bin of=~/Softwares/bochs ...

  8. 卓越研发之路 MOT技术管理者课堂

    引言:从2018年11月起,在北京.大连.上海.南京.杭州.武汉.成都.西安.深圳.广州等地巡回举办的技术沙龙.活动旨在交流软件研发及互联网技术的实战经验,分享优秀的案例实践,通过平台结识更多友人,挖 ...

  9. HDU 6229 - Wandering Robots - [概率题]

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6229 转载: https://blog.csdn.net/Anna__1997/article/det ...

  10. FFmpeg制作+x264+faac

    https://blog.csdn.net/leixiaohua1020/article/details/47071547  雷神的博客 https://www.jianshu.com/p/3f023 ...