你也可以做一个小米魅族网站(WOW.js:WOW.js – 在页面滚动时展现动感的元素动画效果)

可视区域动画:

aos.js        :http://www.jq22.com/jquery-info8150

scrollReveal.js                :http://top.css88.com/archives/384


下载地址:http://download.csdn.net/detail/cometwo/9602591

简介

有的页面在向下滚动的时候,有些元素会产生细小的动画效果。虽然动画比较小,但却能吸引你的注意。比如刚刚发布的 iPhone 6 的页面(查看)。如果你希望你的页面也更加有趣,那么你可以试试 WOW.js。

WOW.js 依赖 animate.css,所以它支持 animate.css 多达 60 多种的动画效果,能满足您的各种需求。

浏览器兼容

这里写图片描述

使用方法

1、引入文件

<code class="hljs xml has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-tag" style="color: rgb(0, 102, 102); box-sizing: border-box;"><<span class="hljs-title" style="box-sizing: border-box; color: rgb(0, 0, 136);">link</span> <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(102, 0, 102);">rel</span>=<span class="hljs-value" style="box-sizing: border-box; color: rgb(0, 136, 0);">"stylesheet"</span> <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(102, 0, 102);">href</span>=<span class="hljs-value" style="box-sizing: border-box; color: rgb(0, 136, 0);">"css/animate.min.css"</span>></span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

2、HTML

<code class="hljs applescript has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">div</span> <span class="hljs-type" style="box-sizing: border-box;">class</span>=<span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"wow slideInLeft"</span>></<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">div</span>>
<<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">div</span> <span class="hljs-type" style="box-sizing: border-box;">class</span>=<span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"wow slideInRight"</span>></<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">div</span>></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>

可以加入 data-wow-duration(动画持续时间)和 data-wow-delay(动画延迟时间)属性,如:

<code class="hljs lasso has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;"><</span>div class<span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">=</span><span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"wow slideInLeft"</span> <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">data</span><span class="hljs-attribute" style="box-sizing: border-box;">-wow</span><span class="hljs-attribute" style="box-sizing: border-box;">-duration</span><span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">=</span><span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"2s"</span> <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">data</span><span class="hljs-attribute" style="box-sizing: border-box;">-wow</span><span class="hljs-attribute" style="box-sizing: border-box;">-delay</span><span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">=</span><span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"5s"</span><span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">><</span>/div<span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">></span>
<span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;"><</span>div class<span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">=</span><span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"wow slideInRight"</span> <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">data</span><span class="hljs-attribute" style="box-sizing: border-box;">-wow</span><span class="hljs-attribute" style="box-sizing: border-box;">-offset</span><span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">=</span><span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"10"</span>  <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">data</span><span class="hljs-attribute" style="box-sizing: border-box;">-wow</span><span class="hljs-attribute" style="box-sizing: border-box;">-iteration</span><span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">=</span><span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"10"</span><span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">><</span>/div<span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">></span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>

3、JavaScript

<code class="hljs cs has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">new</span> WOW().init();</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

要自定义配置,可如下使用:

<code class="hljs cs has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">var</span> wow = <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">new</span> WOW({
    boxClass: <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">'wow'</span>,
    animateClass: <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">'animated'</span>,
    offset: <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>,
    mobile: <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">true</span>,
    live: <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">true</span>
});
wow.init();</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li></ul>

配置

这里写图片描述

演示地址1:http://www.dowebok.com/demo/131/

src="http://www.dowebok.com/demo/131/" width="100%" height="500px" border="0" style="box-sizing: border-box; color: rgb(85, 85, 85); font-family: "microsoft yahei"; font-size: 14px; line-height: 35px;">

演示地址2:http://www.yyyweb.com/demo/inner-show/wow-js.html

src="http://www.yyyweb.com/demo/inner-show/wow-js.html" width="100%" height="500px" border="0" style="box-sizing: border-box; color: rgb(85, 85, 85); font-family: "microsoft yahei"; font-size: 14px; line-height: 35px;">

演示地址3-仿oppo首页:http://www.dowebok.com/demo/131/index2.html

下载地址:http://www.400gb.com/file/73017626







插件描述:aos.js是一款效果超赞的页面滚动元素动画jQuery动画库插件。该动画库可以在页面滚动时提供28种不同的元素动画效果,以及多种easing效果。在页面往回滚动时,元素会恢复到原来的状态。

简要教程

aos.js是一款效果超赞的页面滚动元素动画jQuery动画库插件。该动画库可以在页面滚动时提供28种不同的元素动画效果,以及多种easing效果。在页面往回滚动时,元素会恢复到原来的状态。

安装

可以通过bower来安装aos动画库插件。

bower install aos --save
使用方法

在页面中引入aos.css文件,jquery和aos.js文件

<link rel="stylesheet" href="dist/aos.css" />
<script src="js/jquery.min.js"></script>
<script src="dist/aos.js"></script>
HTML结构

要使用aos动画库,你需要做的就是在需要动画的元素上添加aos属性,例如:

<div aos="animation_name">

aos脚本将会在页面滚动时,在该元素上触发相应的动画。

在元素上还可以添加以下一些属性:

属性 属性 属性 默认值
aos-offset 是立刻触发动画还是在指定时间之后触发动画 200 120
aos-duration 动画持续时间 600 400
aos-easing 动画的easing动画效果 ease-in-sine ease
aos-delay 动画的延迟时间 300 0
aos-anchor 锚元素。使用它的偏移来取代实际元素的偏移来触发动画 #selector null
aos-anchor-placement 锚位置,触发动画时元素位于屏幕的位置 top-center top-bottom
aos-once 动画是否只会触发一次,或者每次上下滚动都会触发 true false

注意,aos-duration的动画持续时间的范围从50-3000毫秒,如果你想设置更大的值,可以在页面中添加下面的CSS代码:

body[aos-duration='4000'] [aos], [aos][aos][aos-duration='4000']{
  transition-duration: 4000ms;
}

上面的代码将动画的持续时间修改为4000毫秒。

示例代码:
<div aos="fade-zoom-in" aos-offset="200" aos-easing="ease-in-sine" aos-duration="600">
<div aos="flip-left" aos-delay="100" aos-anchor=".example-selector">
<div aos="fade-up" aos-anchor-placement="top-center">

如果你担心HTML5校验的问题,可以为上面的属性添加data-前缀。

<div data-aos="animation_name" data-aos-offset="200" data-aos-easing="ease-in-sine">
全局配置

如果你不想单独每个元素做一个动画配置,你可以通过init()方法来统一配置所有元素的动画效果。

AOS.init({
  offset: 200,
  duration: 600,
  easing: 'ease-in-sine',
  delay: 100,
});
额外配置

AOS提供了2个额外的配置方法,这些方法只能够在初始化时使用。

配置 描述 示例值 默认值
disable AOS被禁用的条件 mobile false
startEvent AOS被初始化的事件名称 exampleEvent DOMContentLoaded

禁用AOS:

如果你项在小屏幕设备中禁用AOS,可以:

AOS.init({
  disable: 'mobile'
});

你可以传入3种设备的类型:mobile、phone或tablet。

你也可以设置自己的禁用条件,例如在屏幕小于1024像素时禁用AOS:

disable: window.innerWidth < 1024

或者传入一个函数,返回true或false。

disable: function () {
    var maxWidth = 1024;
    return window.innerWidth < maxWidth;
}
开始动画的事件:

如果你不想滚动动画从页面加载(DOMContentLoaded)后就开始执行,可以使用startEvent来设置自己的事件,AOS会在document上监听这个事件:

AOS.init({
  startEvent: 'someCoolEvent'
});
API

AOS对象有2个可用的方法:

  • init

  • refresh

AOS.refresh();

上面的代码会重新计算元素的位置和偏移。

动画和锚位置

动画

淡入淡出动画:

  • fade-up

  • fade-down

  • fade-left

  • fade-right

  • fade-up-right

  • fade-up-left

  • fade-down-right

  • fade-down-left

翻转动画:

  • flip-up

  • flip-down

  • flip-left

  • flip-right

滑动动画:

  • slide-up

  • slide-down

  • slide-left

  • slide-right

缩放动画:

  • zoom-in

  • zoom-in-up

  • zoom-in-down

  • zoom-in-left

  • zoom-in-right

  • zoom-out

  • zoom-out-up

  • zoom-out-down

  • zoom-out-left

  • zoom-out-right

锚位置

  • top-bottom

  • top-center

  • top-top

  • center-bottom

  • center-center

  • center-top

  • bottom-bottom

  • bottom-center

  • bottom-top

easing动画

你可以使用以下的一些easing动画效果:

  • linear

  • ease

  • ease-in

  • ease-out

  • ease-in-out

  • ease-in-back

  • ease-out-back

  • ease-in-out-back

  • ease-in-sine

  • ease-out-sine

  • ease-in-out-sine

  • ease-in-quad

  • ease-out-quad

  • ease-in-out-quad

  • ease-in-cubic

  • ease-out-cubic

  • ease-in-out-cubic

  • ease-in-quart

  • ease-out-quart

  • ease-in-out-quart


  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值