代码拉取完成,页面将自动刷新
/**
* 气泡漂浮效果
* @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();
});
};
};
});
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。