1 Star 0 Fork 0

/ jquery.flotage.js

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
jquery.flotage.js 2.12 KB
一键复制 编辑 原始数据 按行查看 历史
提交于 2016-06-08 09:47 . 2016/06/08
/**
* 气泡漂浮效果
* @author 陆楚良 <lu_chuliang@sina.com>
* @version 1.0
* https://git.oschina.net/luchg/jquery.flotage.js
* 依赖:
* 需要jQuery和Animate<https://git.oschina.net/luchg/CL_Animate.js>的支持
*/
!function (window, factory) {
if (typeof exports === 'object'){
module.exports = factory();
} else if (typeof define === 'function') {
define(factory);
} else {
factory()(jQuery);
}
}(this, function () {
return function($){
$.fn.flotage = $.fn.flotage || function(option){
var default_option = $.extend({
min_x: -20,
min_y: -20,
max_x: +20,
max_y: +20
}, option || {});
var random = function(Min, Max) {
var Range = Max - Min;
var Rand = Math.random();
return (Min + Math.round(Rand * Range));
};
this.each(function(){
var $this = $(this)
, option= $.extend({}, default_option)
, A = new Animate()
, pos = {x:0, y:0}
;
var animate = function(){
var x = random(0, 10)
, y = random(0, 10)
, ox = pos.x
, oy = pos.y
;
x = ox + (Math.floor(Math.random()*10) < 5 ? -x : x);
y = oy + (Math.floor(Math.random()*10) < 5 ? -y : y);
x = x < option.min_x ? option.min_x : (x > option.max_x ? option.max_x : x);
y = y < option.min_y ? option.min_y : (y > option.max_y ? option.max_y : y);
x -= ox;
y -= oy;
A.stop().init(2000 + random(0, 500)).run(function(p){
pos.x = ox + x * p;
pos.y = oy + y * p;
$this.css("transform", "translate("+pos.x+"px,"+pos.y+"px)");
},function(){ animate() });
};
animate();
});
};
};
});
JavaScript
1
https://gitee.com/luchg/jquery.flotage.js.git
git@gitee.com:luchg/jquery.flotage.js.git
luchg
jquery.flotage.js
jquery.flotage.js
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891