个人博客:https://mmmmmm.me

源码:https://github.com/dataiyangu/dataiyangu.github.io

easing介绍

animate默认是有加速度函数的linear(匀速)和swing(开始和结束慢,中间快),其中swing是jquery默认的easing函数,希望有更多的加速度变化,比如匀加速,弹跳等,物理知识,不显摆了~

背景

hexo next左面点击隐藏出现我的sidebar

代码

function header_left() {
  var block = false;
  $(".header_sidebar").click(function () {
    var header_width = '80px';
    if (block == false) {
    //下面的easing完了之后回调,因为在移动端还有东西不显示
      $(".header_left_inner").animate({width:'80px',opacity:"show"},
        {duration:1000, easing:"easeOutBounce",complete:function () {
            $(".header_left_inner .site-nav").css("display", "block");
          }}
        );
      $("body").animate({marginLeft: "80px"},300)
      block = true
    } else {
      $(".header_left_inner").animate({width: "0px",opacity:"hide"},
        {duration:1000, easing:"easeOutBounce",complete:function () {
            $(".header_left_inner .site-nav").css("display", "none");
          }}
      );
      $("body").animate({marginLeft: "0px"},300)
     block = false
    }
  });
}

header_left()

从实例中学习

easing插件下载地址:

https://www.jb51.net/jiaoben/32922.html#downintro2

下载并引用:

注意:下面我用的require,没有用的同学,直接

//
require.config({
  paths: {
    "easing":"/js/src/pjax/easing/jquery.easing.1.3",
  },

  shim: {
    'header_left': {
      deps: [
        'easing'
      ]
    }
  }
});
require(['easing'], function (){
});

如这段代码

 $(".header_left_inner").animate({width:'80px',opacity:"show"},
        {duration:1000, easing:"easeOutBounce"}
        );

{duration:1000, easing:“easeOutBounce”}是easing的调用方式,json格式的。

各个动作函数的实例展示http://www.runoob.com/jqueryui/api-easings.html

晚上发现的问题

在电脑端是没问题的,在移动端出现了问题,动画没问题,里面的内容不显示了,这个时候记得下午google的时候easing函数可以进行callback,于是产生了下面的代码

$(".header_left_inner").animate({width:'80px',opacity:"show"},
        {duration:1000, easing:"easeOutBounce",complete:function () {
            $(".header_left_inner .site-nav").css("display", "block");
          }}
        );

easing格式参考博客地址:http://code.ciaoca.com/jquery/easing/

写给读者的话

看到这篇文章的你,如果文章中有错误的地方,一定要告诉我,大家共同进步!

前端笔记:animate+easing用法(hexo next主题自定义动画)的更多相关文章

  1. hexo next主题深度优化(一),加入pjax功能。

    文章目录 背景: 进入正题 pjax初体验--instantclick 真正的pjax 第一步 第二步 第三步 第四步 专门基于hexo next主题的pjax(将丢失的js效果重现) 将下面讲到的提 ...

  2. jQuery中Animate进阶用法(一)

    jQuery中animate的用法你了解多少呢?如果仅仅是简单的移动位置,显示隐藏,哦!天哪你在浪费资源!因为animate太强大了,你可以有很多意想不到的用法!让我们一起研究一下吧~~ 首先要了解j ...

  3. 1.前端笔记之html

    title: 1.前端笔记之HTML date: 2016-04-04 23:21:52 tags: Python categories: Python --- 作者:刘耀 **出处:http://w ...

  4. jQuery中Animate进阶用法(二)

    Step Type: Function( Number now, Tween tween )每个动画元素的每个动画属性将调用的函数.这个函数为修改Tween 对象提供了一个机会来改变设置中得属性值. ...

  5. hexo next主题中关于pc端点击链接没问题,移动端点击链接页面不显示。

    个人博客:https://mmmmmm.me 源码:https://github.com/dataiyangu/dataiyangu.github.io 背景 hexo next主题,本人diy的时候 ...

  6. 2.前端笔记之css

    title: 1.前端笔记之CSS date: 2016-04-05 23:05:51 tags: 前端 categories: w3c --- 作者:刘耀 **出处:http://www.liuya ...

  7. jQuery animate easing使用方法

    从jQuery API 文档中可以知道,jQuery自定义动画的函数.animate( properties [, duration] [, easing] [, complete] )有四个参数: ...

  8. Hexo 官方主题 landscape-plus 优化

    博主喜欢简洁大方的Hexo主题,看了不下100个主题之后,最终选择了 landscape-plus 主题(针对中国大陆地区,对Hexo官方主题landscape进行优化后的版本).更多Hexo主题资源 ...

  9. 写给后端的前端笔记:浮动(float)布局

    写给后端的前端笔记:浮动(float)布局 这篇文章主要面向后端人员,对前端有深刻了解的各位不喜勿喷. 起因 前一阵子我一个后端的伙伴问我,"前端的左飘怎么做?",我立马就懵了,& ...

随机推荐

  1. FastStone Capture 文件名设置小记录

    我使用的FastStone Capture 的文件名设置 文件名称模板 fs$Y$M$D#####@ 起始于: [1] 重置 [ 选中] 新的一天自动重置为1

  2. vagrant ssh try

    Vagrantfile add Vagrant.configure("2") do |config| config.vm.network "private_network ...

  3. Centos Apache 80 代理Tomcat 8080端口

    运行环境:Centos 6.5 Apache: 2.2.5 开启apache proxy的相应模块 编辑 /etc/httpd/conf/httpd.conf文件 sudo vim /etc/http ...

  4. HTML5布局篇

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title> ...

  5. Nginx被动健康检查和主动健康检查

    1.被动健康检查 Nginx自带有健康检查模块:ngx_http_upstream_module,可以做到基本的健康检查,配置如下: upstream cluster{ server max_fail ...

  6. NX二次开发-关闭信息窗口UF_UI_close_listing_window

    #include <uf.h> #include <uf_ui.h> UF_initialize(); //打开信息窗口 UF_UI_open_listing_window() ...

  7. redis和redis php扩展安装

    redis的源码安装 wget http://download.redis.io/redis-stable.tar.gz tar -zxvf redis-stable.tar.gz cd redis- ...

  8. Git 本地仓库管理

    目录 目录 基本概念 配置 配置个人帐号信息 安装 本地版本库 创建 Git 仓库 Git 仓库版本回退 修改管理 基本概念 工作区(Working Directory): 就是你在电脑里能看到的目录 ...

  9. python的安装与版本共存与卸载

    目录 python3的安装 python3的下载 python3的安装 python3与python2共存 python3的卸载 @ python3的安装 python3的下载 打开网址:python ...

  10. 最短路(sp

    #include<stdio.h> #include<iostream> #include<queue> using namespace std; #define ...