css3 点击爆炸下落
代码][JavaScript]代码
$(document).ready(function() {
// Generate the clips. In this case I'm using 5 (or 25 pieces)
(genClips = function() {
// For easy use
$t = $('.clipped-box');
// Like I said, we're using 5!
var amount = 5;
// Get the width of each clipped rectangle.
var width = $t.width() / amount;
var height = $t.height() / amount;
// The total is the square of the amount
var totalSquares = Math.pow(amount, 2);
// The HTML of the content
var html = $t.find('.content').html();
var y = 0;
for(var z = 0; z <= (amount*width); z = z+width) {
$('<div class="clipped" >'+html+'</div>').appendTo($t);
if(z === (amount*width)-width) {
y = y + height;
z = -width;
}
if(y === (amount*height)) {
z = 9999999;
}
}
})();
// A quick random function for selecting random numbers
function rand(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
// A variable check for when the animation is mostly over
var first = false,
clicked = false;
// On click
$('.clipped-box div').on('click', function() {
if(clicked === false) {
clicked = true;
$('.clipped-box .content').css({'display' : 'none'});
// Apply to each clipped-box div.
$('.clipped-box div:not(.content)').each(function() {
// So the speed is a random speed between 90m/s and 120m/s. I know that seems like a lot
// But otherwise it seems too slow. That's due to how I handled the timeout.
var v = rand(120, 90),
angle = rand(80, 89), // The angle (the angle of projection) is a random number between 80 and 89 degrees.
theta = (angle * Math.PI) / 180, // Theta is the angle in radians
g = -9.8; // And gravity is -9.8. If you live on another planet feel free to change
// $(this) as self
var self = $(this);
// time is initially zero, also set some random variables. It's higher than the total time for the projectile motion
// because we want the squares to go off screen.
var t = 0,
z, r, nx, ny,
totalt = 15;
// The direction can either be left (1), right (-1) or center (0). This is the horizontal direction.
var negate = [1, -1, 0],
direction = negate[ Math.floor(Math.random() * negate.length) ];
// Some random numbers for altering the shapes position
var randDeg = rand(-5, 10),
randScale = rand(0.9, 1.1),
randDeg2 = rand(30, 5);
// Because box shadows are a bit laggy (by a bit I mean 'box shadows will not work on individual clipped divs at all')
// we're altering the background colour slightly manually, in order to give the divs differentiation when they are
// hovering around in the air.
var color = $(this).css('backgroundColor').split('rgb(')[1].split(')')[0].split(', '),
colorR = rand(-20, 20), // You might want to alter these manually if you change the color
colorGB = rand(-20, 20), // To get the right consistency.
newColor = 'rgb('+(parseFloat(color[0])+colorR)+', '+(parseFloat(color[1])+colorGB)+', '+(parseFloat(color[2])+colorGB)+')';
// And apply those
$(this).css({http://www.huiyi8.com/flashchajian/
'transform' : 'scale('+randScale+') skew('+randDeg+'deg) rotateZ('+randDeg2+'deg)',
'background' : newColorflash插件
});
// Set an interval
z = setInterval(function() {
// Horizontal speed is constant (no wind resistance on the internet)
var ux = ( Math.cos(theta) * v ) * direction;
// Vertical speed decreases as time increases before reaching 0 at its peak
var uy = ( Math.sin(theta) * v ) - ( (-g) * t);
// The horizontal position
nx = (ux * t);
// s = ut + 0.5at^2
ny = (uy * t) + (0.5 * (g) * Math.pow(t, 2));
// Apply the positions
$(self).css({'bottom' : (ny)+'px', 'left' : (nx)+'px'});
// Increase the time by 0.10
t = t + 0.10;
// If the time is greater than the total time clear the interval
if(t > totalt) {
clicked = false;
first = true;
$('.clipped-box').css({'top' : '-1000px', 'transition' : 'none'});
$(self).css({'left' : '0', 'bottom' : '0', 'opacity' : '1', 'transition' : 'none', 'transform' : 'none'});
// Finally clear the interval
clearInterval(z);
}
}, 10); // Run this interval every 10ms. Changing this will change the pace of the animation
});
}
});
r = setInterval(function() {
// This is a bit rough but it does the job
if(first === true) {
// I've just put this in so the deleted box will come down again after its been clicked.
// That way you can keep pressing delete.
$('.clipped-box').css({'top' : '0', 'transition' : ''});
$('.clipped-box div').css({'opacity' : '1', 'transition' : '', 'background-color' : ''});
$('.content').css({'display' : 'block'});
first = false;
}
}, 300);
});
css3 点击爆炸下落的更多相关文章
- HTML5+CSS3点击指定按钮显示某些内容效果
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 超厉害的CSS3图片破碎爆炸效果!
var fx = { buffer : function(obj, cur, target, fnDo, fnEnd, fs){ if(!fs)fs=6; var now={}; var x=0; ...
- 15款效果很酷的最新jQuery/CSS3特效
很久没来博客园发表文章了,今天就分享15款效果很酷的最新jQuery/CSS3特效,废话不说,一起来看看吧. 1.3D图片上下翻牌切换 一款基于jQuery+CSS3实现的3D图片上下翻牌切换效果,支 ...
- 手把手教你玩转CSS3 3D技术
手把手教你玩转 CSS3 3D 技术 要玩转css3的3d,就必须了解几个词汇,便是透视(perspective).旋转(rotate)和移动(translate).透视即是以现实的视角来看屏幕上 ...
- Solidworks如何生成爆炸图
1 自动爆炸 点击"爆炸视图"按钮,然后全部选中装配体(被选中的零件会变为蓝色,全部选中即全部变色)然后在组成偶尔的爆炸窗口中下拉,点击应用. 再点击完成 回到装配体面板, ...
- 10款让WEB前端开发人员更轻松的实用工具
这篇文章介绍10款让Web前端开发人员生活更轻松的实用工具.每个Web开发人员都有自己的工具箱,这样工作中碰到的每个问题都有一个好的解决方案供选择. 对于每一项工作,开发人员需要特定的辅助工具,所以如 ...
- 十款让 Web 前端开发人员更轻松的实用工具
这篇文章介绍十款让 Web 前端开发人员生活更轻松的实用工具.每个 Web 开发人员都有自己的工具箱,这样工作中碰到的每个问题都有一个好的解决方案供选择. 对于每一项工作,开发人员需要特定的辅助工具, ...
- JS实现别踩白块小游戏
最近有朋友找我用JS帮忙仿做一个别踩白块的小游戏程序,但他给的源代码较麻烦,而且没有注释,理解起来很无力,我就以自己的想法自己做了这个小游戏,主要是应用JS对DOM和数组的操作. 程序思路:如图:将游 ...
- 【转】十款让 Web 前端开发人员更轻松的实用工具
这篇文章介绍十款让 Web 前端开发人员生活更轻松的实用工具.每个 Web 开发人员都有自己的工具箱,这样工作中碰到的每个问题都有一个好的解决方案供选择. 对于每一项工作,开发人员需要特定的辅助工具, ...
随机推荐
- PriorityBlockingQueue优先队列的二叉堆实现
转载请注明原创地址http://www.cnblogs.com/dongxiao-yang/p/6293807.html java.util.concurrent.PriorityBlockingQu ...
- jeesite中activiti中的流程表梳理
最近在利用jeesite开发一个小系统,趁着这个机会整理了activiti中的相关表,跟踪流程,然后查看这几个表中数据的变化,可以更好地理解流程的开发.现在整理出来,希望可以帮助更多的人! 表结构 一 ...
- git 和 svn 的比较
Git VS SVN 1 .功能 主体功能 Git SVN 1.从服务器上克隆完整的Git仓库(包括代码和版本信息)到单机上. 1 .SVN是基于关系数据库的(BerkleyDB)或一系列二进制 ...
- Zabbix二次开发_03api列表
基于zabbix 3.0 https://www.zabbix.com/documentation/3.0/manual/api/reference Method reference This sec ...
- Oracle Data Provider for .NET的使用(托管与非托管(一))
目录 简单的概述 简单的使用 非托管系统要求 托管驱动系统要求 其它的注意事项 ODP.NET版本说明 安装ODP.NET 安装非托管驱动 非托管驱动绿色配置 简单的概述 ODP.NET的含义是 Or ...
- python高级-------python2.7教程学习【廖雪峰版】(四)
2017年6月9日17:57:55 任务: 看完高级部分 笔记:1.掌握了Python的数据类型.语句和函数,基本上就可以编写出很多有用的程序了.2.在Python中,代码不是越多越好,而是越少越好. ...
- x^a=b(mod c)求解x在[0,c-1]上解的个数模板+原根求法
/************************************* 求解x^a=b(mod c) x在[0,c-1]上解的个数模板 输入:1e9>=a,b>=1,1e9>= ...
- IO密集型操作时,为什么线程比进程更好?
在IO密集型的操作时,进程线程都不会太占用CPU,但是进程消耗的资源比较多.
- 如何下载symfony
php -r "readfile('https://symfony.com/installer');" > symfony 可能无法下载,:那么你检查一下你的php.ini找 ...
- mac上傻瓜式java安装环境配置
适用于mac新手用户或者黑苹果用户 首先,打开终端 输入 java -version 检查是否已安装好Java运行环境 显示我现在电脑没有安装 如果返回版本号,说明运行环境成功 对于windows用过 ...