阅读排行
- 中国标准城市区域码
- postgresql 截取日期字符串 的函数
- OkHttp 官方中文文档
- 关于java中“使用了未经检查或不安全的操作、有关详细信息,请使用 ——X临潼:unchecked重新编译”
- 什么值得买自动签到自动评论定时任务
- chrome://plugins 无法打开的解决方法,同时解决“该网页已屏蔽插件-adobe flash player”
- 如何在GPT格式下创建EFI和MSR分区(安装WIN10/WIN8.1)
- 联想X270——正版Win10换win7之BIOS配置及系统安装
- 几款开源的堡垒机
- code128条码生成与显示
- Java操作Excel,设置某些单元格不可编辑(HSSFWorkbook ,XSSFWorkbook )
- 第04章-VTK基础(6)
- 通达OA用户操作手册(一)
- postgresql——字符串函数
- (转)C#进行图像处理的几种方法(Bitmap,BitmapData,IntPtr)
- 5.EVE-NG关联SecureCRT,VNC,Wireshark
- Stream 操作 合并两个list
- Unity 利用UGUI打包图集,动态加载sprite资源
- elasticsearch 数据丢失的分析
- win7&win10安装AD管理工具
WoW.js插件
时间:2017.11.02----2017.11.04
author: gaoxuerong
先上效果图点击这里
这是我在看WoW.js源码的时候写的,自己也是不理解,所以是边看,边百度,把自己查的资料整理下,由于本人能力有限,不能很好的讲解,就只是粗略的写了下,
开始总体看起来是(function(){}).call(this)讲解详见https://segmentfault.com/q/1010000002519489
- 其实[].indexOf和
- function(item) {
- for (var i = 0, l = this.length; i < l; i++) {
- if (i in this && this[i] === item)
- return i;
- }return -1;
- };的作用是一样的;你懂得;
- Util = (function() {return Util;})()//立即执行函数
- function Util() {}
- Util.prototype.extend = function(custom, defaults) {
- var key, value;
- for (key in defaults) {
- value = defaults[key];
- if (custom[key] == null) {
- custom[key] = value;
- }
- }
- return custom;
- };
- WeakMap=this.WeakMap || this.MozWeakMap || (WeakMap = (function() {return WeakMap;})())
- function WeakMap() {
- this.keys = [];
- this.values = [];
- }
- 然后在WeakMap原型上扩展了get set方法;
- WeakMap.prototype.get(key)返回key关联对象, 或者 undefined(没有key关联对象时)。WeakMap.prototype.set(key, value)在WeakMap中设置一组key关联对象,返回这个 WeakMap对象。关于WeakMap详见http://es6.ruanyifeng.com/#docs/set-map
- MutationObserver =(MutationObserver = (function() {
- function MutationObserver() {}
- return MutationObserver;
- getComputedStyle = this.getComputedStyle || function(el, pseudo) {
- return this;
- }
- Window.getComputedStyle() 方法给出应用活动样式表后的元素的所有CSS属性的值,并解析这些值可能包含的任何基本计算。关于getComputedStyle详见https://developer.mozilla.org/zh-CN/docs/Web/API/Window/getComputedStyle
- this.WOW = (function() {
- return WOW;
- })()
- WOW.prototype.defaults = {
- boxClass: ‘wow‘,
- animateClass: ‘animated‘,
- offset: 0,
- mobile: true,//手机是否支持
- live: true,
- callback: null,
- scrollContainer: null
- };
- function WOW(options) {
- if (options == null) {
- options = {};
- }
- this.scrollCallback = bind(this.scrollCallback, this);
- this.scrollHandler = bind(this.scrollHandler, this);
- this.resetAnimation = bind(this.resetAnimation, this);
- this.start = bind(this.start, this);
- this.scrolled = true;
- this.config = this.util().extend(options, this.defaults);
- if (options.scrollContainer != null) {
- this.config.scrollContainer = document.querySelector(options.scrollContainer);
- }
- this.animationNameCache = new WeakMap();
- this.wowEvent = this.util().createEvent(this.config.boxClass);
- }
- 然后在Wow.prototype上扩展了方法init[初始化]; start ;stop ;sync[同步] ;doSync; show;applyStyle;animate;resetStyle;resetAnimation;customStyle;vendorSet;vendorCSS;animationName;cacheAnimationName;cachedAnimationName;scrollHandler;scrollCallback;offsetTop;isVisible;util;disabled;
WoW.js基本用法

具体动画效果,详见animate.css
具体css3动画效果详见:http://css.doyoe.com/
自己可以根据animate.css源码分析,只要了解css3动画的用法就好;
例如:1. fadeInDown
在animate.css中有:

透明度从opacity:0到opacity:1;在外轴上平移:从-20px到0;
2.bounceInDown

3.rollIn

4.lightSpeedIn

5.bounceInRight

6.flipInX

7.shake

8.swing

9.bounceInUp

10.pulse

11.bounce

12.flip
- @keyframes flip {
- 0% {
- -webkit-transform: perspective(400px) translateZ(0) rotateY(0) scale(1);
- -ms-transform: perspective(400px) translateZ(0) rotateY(0) scale(1);
- transform: perspective(400px) translateZ(0) rotateY(0) scale(1);
- -webkit-animation-timing-function: ease-out;
- animation-timing-function: ease-out;
- }
- 40% {
- -webkit-transform: perspective(400px) translateZ(150px) rotateY(170deg) scale(1);
- -ms-transform: perspective(400px) translateZ(150px) rotateY(170deg) scale(1);
- transform: perspective(400px) translateZ(150px) rotateY(170deg) scale(1);
- -webkit-animation-timing-function: ease-out;
- animation-timing-function: ease-out;
- }
- 50% {
- -webkit-transform: perspective(400px) translateZ(150px) rotateY(190deg) scale(1);
- -ms-transform: perspective(400px) translateZ(150px) rotateY(190deg) scale(1);
- transform: perspective(400px) translateZ(150px) rotateY(190deg) scale(1);
- -webkit-animation-timing-function: ease-in;
- animation-timing-function: ease-in;
- }
- 80% {
- -webkit-transform: perspective(400px) translateZ(0) rotateY(360deg) scale(.95);
- -ms-transform: perspective(400px) translateZ(0) rotateY(360deg) scale(.95);
- transform: perspective(400px) translateZ(0) rotateY(360deg) scale(.95);
- -webkit-animation-timing-function: ease-in;
- animation-timing-function: ease-in;
- }
- 100% {
- -webkit-transform: perspective(400px) translateZ(0) rotateY(360deg) scale(1);
- -ms-transform: perspective(400px) translateZ(0) rotateY(360deg) scale(1);
- transform: perspective(400px) translateZ(0) rotateY(360deg) scale(1);
- -webkit-animation-timing-function: ease-in;
- animation-timing-function: ease-in;
- }
- }
13.tada
- @keyframes tada {
- 0% {
- -webkit-transform: scale(1);
- -ms-transform: scale(1);
- transform: scale(1);
- }
- 10%, 20% {
- -webkit-transform: scale(0.9) rotate(-3deg);
- -ms-transform: scale(0.9) rotate(-3deg);
- transform: scale(0.9) rotate(-3deg);
- }
- 30%, 50%, 70%, 90% {
- -webkit-transform: scale(1.1) rotate(3deg);
- -ms-transform: scale(1.1) rotate(3deg);
- transform: scale(1.1) rotate(3deg);
- }
- 40%, 60%, 80% {
- -webkit-transform: scale(1.1) rotate(-3deg);
- -ms-transform: scale(1.1) rotate(-3deg);
- transform: scale(1.1) rotate(-3deg);
- }
- 100% {
- -webkit-transform: scale(1) rotate(0);
- -ms-transform: scale(1) rotate(0);
- transform: scale(1) rotate(0);
- }
- }
文章来自:http://www.cnblogs.com/gaoxuerong123/p/7782695.html