<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>photo</title>
</head>
<style>
#imgWrap{
width: 550px;
height: 450px;
margin: 0 auto;
perspective: 550px;
}
img{
float: left;
width: 80px;
height: 80px;
}
#btn{
width: 100px;
text-align: center;
font:16px/40px "微软雅黑";
color: #fff;
padding: 0 20px;
background: rgb(0,100,0);
margin: 0 auto;
border-radius: 5px;
box-shadow: 2px 2px 5px rgba(0,0,0,0.5);
margin: 0 auto;
cursor: pointer;
}
</style>
<body>
<div id="imgWrap">
<img src="img/1.jpg" alt="" />
<img src="img/2.jpg" alt="" />
<img src="img/3.jpg" alt="" />
<img src="img/4.jpg" alt="" />
<img src="img/5.jpg" alt="" />
<img src="img/6.jpg" alt="" />
<img src="img/7.jpg" alt="" />
<img src="img/8.jpg" alt="" />
<img src="img/9.jpg" alt="" />
<img src="img/10.jpg" alt="" />
<img src="img/11.jpg" alt="" />
<img src="img/12.jpg" alt="" />
<img src="img/13.jpg" alt="" />
<img src="img/14.jpg" alt="" />
<img src="img/15.jpg" alt="" />
<img src="img/16.jpg" alt="" />
<img src="img/17.jpg" alt="" />
<img src="img/18.jpg" alt="" />
<img src="img/19.jpg" alt="" />
<img src="img/20.jpg" alt="" />
<img src="img/21.jpg" alt="" />
<img src="img/22.jpg" alt="" />
<img src="img/23.jpg" alt="" />
<img src="img/24.jpg" alt="" />
<img src="img/25.jpg" alt="" />
<img src="img/26.jpg" alt="" />
<img src="img/27.jpg" alt="" />
<img src="img/28.jpg" alt="" />
<img src="img/29.jpg" alt="" />
<img src="img/30.jpg" alt="" />
</div>
<div id="btn">
显示效果
</div>
</body>
<script>
window.οnlοad=function(){
var btn=document.getElementById("btn");
var imgs=document.querySelectorAll("img");
var on = true;
//给btn添加点击事件
btn.οnclick=function(){
if(!on){
return;
}
on=false;
var endNum=0;
var allEnd=0;
for (var i=0;i<imgs.length;i++) {
(function(i){
setTimeout(function(){
montion(imgs[i],'1s',function(){
this.style.transform='scale(0)';
},function(){
montion(this,'1s',function(){
this.style.transform='scale(1)';
this.style.opacity=0;
},function(){
endNum++;
if(endNum==imgs.length){
toBig();
}
});
});
},Math.random()*1000);//随机变化
})(i)
}
function toBig(){
for (var i=0;i<imgs.length;i++) {
imgs[i].style.transition='';
imgs[i].style.transform='rotateY(0deg) translateZ(-'+Math.random()*500+'px)';
(function(i){
setTimeout(function(){
montion(imgs[i],'2s',function(){
this.style.opacity=1;
this.style.transform='rotateY(-360deg) translateZ(0)';
},function(){
allEnd++;
if(allEnd==imgs.length){
on=true;
}
});
},Math.random()*1000);
})(i);
}
}
};
//运动函数(运动的对象,运动的时间,运动的属性函数,运动完要做的事情)
function montion(obj,time,doFn,callBack){
obj.style.transition=time;
doFn.call(obj);
var called=false;
obj.addEventListener('transitionend',function(){
if(!called){
callBack&&
callBack.call(obj);
called=true;
}
},false);
}
};
</script>
</html>
<html>
<head>
<meta charset="utf-8" />
<title>photo</title>
</head>
<style>
#imgWrap{
width: 550px;
height: 450px;
margin: 0 auto;
perspective: 550px;
}
img{
float: left;
width: 80px;
height: 80px;
}
#btn{
width: 100px;
text-align: center;
font:16px/40px "微软雅黑";
color: #fff;
padding: 0 20px;
background: rgb(0,100,0);
margin: 0 auto;
border-radius: 5px;
box-shadow: 2px 2px 5px rgba(0,0,0,0.5);
margin: 0 auto;
cursor: pointer;
}
</style>
<body>
<div id="imgWrap">
<img src="img/1.jpg" alt="" />
<img src="img/2.jpg" alt="" />
<img src="img/3.jpg" alt="" />
<img src="img/4.jpg" alt="" />
<img src="img/5.jpg" alt="" />
<img src="img/6.jpg" alt="" />
<img src="img/7.jpg" alt="" />
<img src="img/8.jpg" alt="" />
<img src="img/9.jpg" alt="" />
<img src="img/10.jpg" alt="" />
<img src="img/11.jpg" alt="" />
<img src="img/12.jpg" alt="" />
<img src="img/13.jpg" alt="" />
<img src="img/14.jpg" alt="" />
<img src="img/15.jpg" alt="" />
<img src="img/16.jpg" alt="" />
<img src="img/17.jpg" alt="" />
<img src="img/18.jpg" alt="" />
<img src="img/19.jpg" alt="" />
<img src="img/20.jpg" alt="" />
<img src="img/21.jpg" alt="" />
<img src="img/22.jpg" alt="" />
<img src="img/23.jpg" alt="" />
<img src="img/24.jpg" alt="" />
<img src="img/25.jpg" alt="" />
<img src="img/26.jpg" alt="" />
<img src="img/27.jpg" alt="" />
<img src="img/28.jpg" alt="" />
<img src="img/29.jpg" alt="" />
<img src="img/30.jpg" alt="" />
</div>
<div id="btn">
显示效果
</div>
</body>
<script>
window.οnlοad=function(){
var btn=document.getElementById("btn");
var imgs=document.querySelectorAll("img");
var on = true;
//给btn添加点击事件
btn.οnclick=function(){
if(!on){
return;
}
on=false;
var endNum=0;
var allEnd=0;
for (var i=0;i<imgs.length;i++) {
(function(i){
setTimeout(function(){
montion(imgs[i],'1s',function(){
this.style.transform='scale(0)';
},function(){
montion(this,'1s',function(){
this.style.transform='scale(1)';
this.style.opacity=0;
},function(){
endNum++;
if(endNum==imgs.length){
toBig();
}
});
});
},Math.random()*1000);//随机变化
})(i)
}
function toBig(){
for (var i=0;i<imgs.length;i++) {
imgs[i].style.transition='';
imgs[i].style.transform='rotateY(0deg) translateZ(-'+Math.random()*500+'px)';
(function(i){
setTimeout(function(){
montion(imgs[i],'2s',function(){
this.style.opacity=1;
this.style.transform='rotateY(-360deg) translateZ(0)';
},function(){
allEnd++;
if(allEnd==imgs.length){
on=true;
}
});
},Math.random()*1000);
})(i);
}
}
};
//运动函数(运动的对象,运动的时间,运动的属性函数,运动完要做的事情)
function montion(obj,time,doFn,callBack){
obj.style.transition=time;
doFn.call(obj);
var called=false;
obj.addEventListener('transitionend',function(){
if(!called){
callBack&&
callBack.call(obj);
called=true;
}
},false);
}
};
</script>
</html>