代码][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 点击爆炸下落
时间: 2024-10-07 19:35:26
css3 点击爆炸下落的相关文章
基于jQuery+CSS3点击动画弹出表单代码
分享一款基于jQuery+CSS3点击动画弹出表单代码是一款鼠标点击图标按钮动画弹出表单特效代码.效果图如下: 在线预览 源码下载 实现的代码. html代码: <div class="buttonCollection"> <div class="qutton" id="qutton_upload"> <div class="qutton_dialog" id="uploadDial
超厉害的CSS3图片破碎爆炸效果!
Java代码 var fx = { buffer : function(obj, cur, target, fnDo, fnEnd, fs){ if(!fs)fs=6; var now={}; var x=0; var v=0; if(!obj.__last_timer)obj.__last_timer=0; var t=new Date().getTime(); if(t-obj.__last_timer>20) { fnMove(); obj.__last_timer=t; } cle
css3点击涟漪效果
代码如下: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> @import url(http://fonts.googleapis.com/css?family=Roboto:400,300,100,500); html { backgroun
Solidworks如何生成爆炸图
1 自动爆炸 点击"爆炸视图"按钮,然后全部选中装配体(被选中的零件会变为蓝色,全部选中即全部变色)然后在组成偶尔的爆炸窗口中下拉,点击应用. 再点击完成 回到装配体面板,右击该装配体,点击动画解除爆炸 随后即可形成动画,但是效果很不理想,零件只是做简单的平移而已,没有考虑干涉. 回到爆炸视图,我们可以查看爆炸步骤(从图中可以发现只有一条链,几个组和几个零件,比如组2有两个螺钉,组1也是两个螺钉) 2 手动爆炸,我们点击了爆炸视图之后,左侧的爆炸步骤是空的,我们选中四个螺钉(不是所有零
爆炸倒计时 代码
<html> 里面要链入JQ <script src="js/jquery.min.js"></script> <!-- 1. 添加一个按钮,用来点击爆炸 --><input type="button" class="btn" name="" value="点我!3 2 1 砰!炸了" /> <div class="big"
手把手教你玩转CSS3 3D技术
手把手教你玩转 CSS3 3D 技术 要玩转css3的3d,就必须了解几个词汇,便是透视(perspective).旋转(rotate)和移动(translate).透视即是以现实的视角来看屏幕上的2D事物,从而展现3D的效果.旋转则不再是2D平面上的旋转,而是三维坐标系的旋转,就包括X轴,Y轴,Z轴旋转.平移同理. 当然用理论来说明,估计你还不明白.下面是3个gif: 沿着X轴旋转 沿着Y轴旋转 沿着Z轴旋转 旋转应该没问题了,那理解平移起来就比较容易了,就是在在X轴.Y轴.z轴移动. 你可能
博客装饰---鼠标移动、点击效果
昨天看别人博客的时候有很炫酷的效果,我很喜欢,于是决定自己也来弄一哈~这个是需要申请js权限的~没想到昨天申请今天就通过了,非常感谢! 第一个:鼠标随意晃一下都是爱你的形状~~ /*鼠标跟随效果*/ <style type="text/css"> .draw { position: fixed; width: 1px; line-height: 1px; pointer-events: none; } @keyframes floatOne { 0% { opacity:1
【转】十款让 Web 前端开发人员更轻松的实用工具
这篇文章介绍十款让 Web 前端开发人员生活更轻松的实用工具.每个 Web 开发人员都有自己的工具箱,这样工作中碰到的每个问题都有一个好的解决方案供选择. 对于每一项工作,开发人员需要特定的辅助工具,所以如果下面这些工具对于你来说都是新的领域,那么这篇文章是非常有用的,因为这些实用的工具将让你的工作更有效率. Spritepad 借助 SpritePad,你可以在几分钟甚至几秒钟内创建你的 CSS 精灵.只需拖放您的图片,立即可以生成 PNG 精灵图片以及 CSS 代码.不需要在 Photosh
android源码大放送(实战开发必备),免费安卓demo源码,例子大全文件详细列表
免费安卓demo源码,例子大全文件详细列表 本列表源码永久免费下载地址:http://www.jiandaima.com/blog/android-demo 卷 yunpan 的文件夹 PATH 列表 卷序列号为 0000-73EC E:. │ jiandaima.com文件列表生成.bat │ 例子大全说明.txt │ 本例子永久更新地址~.url │ 目录列表2016.03.10更新.txt │ ├─前台界面 │ ├─3D标签云卡片热门 │ │ Android TagCloudView云标签