Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
Fizz!
css
html, body { margin: 0; padding: 0; height: 100%; } #fizz { width: 100%; height: 100%; } .title { position: absolute; left: 0; right: 0; top: 30%; text-align: center; color: white; opacity: 0.7; font-family: 'Knewave', cursive; font-size: 84px; }
JavaScript
(function() { this.Bubble = (function() { class Bubble { constructor(x, y, r, createdAt) { this.x = x; this.y = y; this.r = r; this.createdAt = createdAt; } velocity() { return this.r / 20 * Bubble.MAX_V; } grow(now) { if (!this.rising && this.r <= Bubble.MAX_R) { return this.r += Bubble.GROWTH_RATE * (now - this.createdAt); } } move(now) { if (this.rising) { return this.y -= (now - this.startedRisingAt) * this.velocity(); } } rise() { if (!this.rising && this.r > 2) { this.rising = Math.random() < 0.15 * (this.r / Bubble.MAX_R); if (this.rising) { return this.startedRisingAt = new Date().getTime(); } } } }; Bubble.MAX_R = 20; Bubble.MAX_V = 0.02; Bubble.GROWTH_RATE = 0.00005; return Bubble; }).call(this); this.RisingBubbles = (function() { var rand, randInt; class RisingBubbles { constructor(id, maxBubbles) { var elem, i, j, ref; this.maxBubbles = maxBubbles; this.canvas = document.getElementById(id); elem = $('#' + id); elem.css('background-color', '#3d8835'); elem.click(() => { var b, j, len, ref, results, ts; ts = new Date().getTime(); ref = this.bubbles; results = []; for (j = 0, len = ref.length; j < len; j++) { b = ref[j]; if (!b.rising) { b.rising = true; results.push(b.startedRisingAt = ts); } else { results.push(void 0); } } return results; }); this.canvas.width = this.canvas.clientWidth; this.canvas.height = this.canvas.clientHeight; this.ctx = this.canvas.getContext('2d'); this.ctx.fillStyle = '#FFFFFF'; this.bubbles = []; this.lastFrame = new Date().getTime(); for (i = j = 1, ref = randInt(0, this.maxBubbles); 1 <= ref ? j <= ref : j >= ref; i = 1 <= ref ? ++j : --j) { this.bubbles.push(new Bubble(randInt(0, this.canvas.width), randInt(0, this.canvas.height), rand(0, Bubble.MAX_R), new Date().getTime())); } } draw() { return this.run(new Date().getTime()); } run(now) { var bubble, j, len, ref; this.update(now); this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); ref = this.bubbles; for (j = 0, len = ref.length; j < len; j++) { bubble = ref[j]; this.ctx.moveTo(bubble.x, bubble.y); this.ctx.beginPath(); this.ctx.arc(bubble.x, bubble.y, bubble.r, 0, 2 * Math.PI); this.ctx.fill(); } return requestAnimationFrame(() => { return this.run(new Date().getTime()); }); } update(now) { var b, i, j, k, len, ref, ref1, results; ref = this.bubbles; for (j = 0, len = ref.length; j < len; j++) { b = ref[j]; b.grow(now); b.rise(); b.move(now); } this.bubbles = (function() { var k, len1, ref1, results; ref1 = this.bubbles; results = []; for (k = 0, len1 = ref1.length; k < len1; k++) { b = ref1[k]; if (b.y + b.r >= 0) { results.push(b); } } return results; }).call(this); if (this.maxBubbles - this.bubbles.length > 0) { results = []; for (i = k = 1, ref1 = randInt(0, this.maxBubbles - this.bubbles.length); 1 <= ref1 ? k <= ref1 : k >= ref1; i = 1 <= ref1 ? ++k : --k) { results.push(this.bubbles.push(new Bubble(randInt(0, this.canvas.width), randInt(0, this.canvas.height), 1, new Date().getTime()))); } return results; } } }; randInt = function(min, max) { return Math.floor(Math.random() * (max - min) + min); }; rand = function(min, max) { return Math.floor(Math.random() * (max - min) + min); }; return RisingBubbles; }).call(this); $((function() { var fizz; fizz = new RisingBubbles('fizz', 500); return fizz.draw(); })); }).call(this);
粒子
时间
文字
hover
canvas
3d
游戏
音乐
火焰
水波
轮播图
鼠标跟随
动画
css
加载动画
导航
菜单
按钮
滑块
tab
弹出层
统计图
svg
×
Close
在线代码下载提示
开通在线代码永久免费下载,需支付20jQ币
开通后,在线代码模块中所有代码可终身免费下!
您已开通在线代码永久免费下载,关闭提示框后,点下载代码可直接下载!
您已经开通过在线代码永久免费下载
对不起,您的jQ币不足!可通过发布资源 或
直接充值获取jQ币
取消
开通下载
<!doctype html> <html> <head> <meta charset="utf-8"> <title>气泡动画-jq22.com</title> <script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script> <style>
</style> </head> <body>
<script>
</script>
</body> </html>
2012-2021 jQuery插件库版权所有
jquery插件
|
jq22工具库
|
网页技术
|
广告合作
|
在线反馈
|
版权声明
沪ICP备13043785号-1
浙公网安备 33041102000314号