图片/图形

超酷3D网格照片墙动画jQuery特效

阿里云


这是一组效果非常炫酷的 jQuery 3D 网格照片墙动画特效。这组 3D 网格照片墙共 4 种不同的效果,它们都是使用 jQuery .delay(),jQuery easing 插件和 CSS3 动画过渡来在网格中制作缩略图的动画特效。该 3D 网格照片墙动画特效依赖于 jQuery easing 插件,在点击“animate”按钮之后,缩略图会随机消失,并带有波动效果。然后会以 3D 旋转的方式快速恢复到原来的位置上,效果非常炫酷。

HTML 结构

该 3D 网格照片墙动画特效的 HTML 结果非常简单:使用一个<div>作为网格容器,和一个按钮来触发动画效果。

也想出现在这里?联系我们
创客主机
  1. <div class="grid"></div>
  2. <span class="animate">Animate</span>

CSS 样式

在网格容器上设置了固定的宽度和高度,为了制作 3D 效果,还设置了 perspective: 500px;。每一张图片也设置了固定的宽度和高度,并且均为左浮动。

  1. * {margin: 0; padding: 0;}
  2. body {text-align: center; /*overflow: hidden;*/}
  3.  
  4. .grid {
  5.   width: 600px; height: 300px; margin: 100px auto 50px auto;
  6.   perspective: 500px; /*For 3d*/
  7. }
  8. .grid img {width: 60px; height: 60px; display: block; float: left;}
  9.  
  10. .animate {
  11.   font: 12px Montserrat; text-transform: uppercase;
  12.   background: rgb(0, 100, 0); color: white;
  13.   padding: 10px 20px; border-radius: 5px;
  14.   cursor: pointer;
  15. }
  16. .animate:hover {background: rgb(0, 75, 0);}

JavaScript

网格中的图片是在 js 代码中动态添加的。.animate 按钮上添加了 click 事件监听,在按钮被点击的时候,网格中的每一张图片都使用 jQuery.delay()函数来设置一个随机的延迟值,并使用 animate()动画来使图片的透明度降低为 0。接着在所有图片都消失之后,promise()方法返回一个 Promise 对象,用来观察当某种类型的所有行动绑定到集合,排队与否还是已经完成。最后在 done()方法中执行缩略图的 3D 旋转动画,类似龙卷风的效果。

  1. var images = "", count = 50;
  2. for(var i = 1; i <= count; i++)
  3.   images += '<img class="grid-image" src="img/'+i+'.jpg" />';
  4.  
  5. //图片添加到网格中
  6. $(".grid").append(images);
  7.  
  8. var d = 0; //延迟
  9. var ry, tz, s; //转换参数
  10.  
  11. //animation time
  12. $(".animate").on("click", function(){
  13.   //fading out the thumbnails with style
  14.   $("img.grid-image").each(function(){
  15.     d = Math.random()*1000; //1ms to 1000ms delay
  16.     $(this).delay(d).animate({opacity: 0}, {
  17.       step: function(n){
  18.         s = 1-n; //scale - will animate from 0 to 1
  19.         $(this).css("transform", "scale("+s+")");
  20.       }, 
  21.       duration: 1000, 
  22.     })
  23.   }).promise().done(function(){
  24.     //after *promising* and *doing* the fadeout animation we will bring the images back
  25.     storm();
  26.   })
  27. })
  28. //bringing back the images with style
  29. function storm()
  30. {
  31.   $("img.grid-image").each(function(){
  32.     d = Math.random()*1000;
  33.     $(this).delay(d).animate({opacity: 1}, {
  34.       step: function(n){
  35.         //rotating the images on the Y axis from 360deg to 0deg
  36.         ry = (1-n)*360;
  37.         //translating the images from 1000px to 0px
  38.         tz = (1-n)*1000;
  39.         //applying the transformation
  40.         $(this).css("transform", "rotateY("+ry+"deg) translateZ("+tz+"px)");
  41.       }, 
  42.       duration: 3000, 
  43.       easing: 'easeOutQuint', 
  44.     })
  45.   })
  46. }

超酷 3D 网格照片墙动画 jQuery 特效

已有 658 人购买
查看演示升级 VIP立刻购买

演示地址 下载地址
收藏
(1)

发表回复

热销模板

Ashade - 作品展示摄影相册WordPress汉化主题
LensNews

本站承接 WordPress / PbootCMS / DedeCMS 等
系统建站、仿站、开发、定制等业务!