图片/图形

炫酷堆叠卡片切换动画特效

阿里云


这是一组非常有创意的堆叠卡片切换动画特效。这些堆叠卡片切换效果通过点击“确定”或“取消”按钮,以不同的方式将最上面的卡片切换到底部。这 14 最后卡片切换动画创意十足,效果非常炫酷。

HTML 结构

在第一种效果中,它的 HTML 结构如下:<ul>元素中的图片将被制作为一个堆栈结构,所有图片以绝对定位的方式互相堆叠在一起。div.controls 是两个控制按钮。当点击“Accept”或“Reject”按钮的时候,当前图片堆栈顶部的图片会被添加 accept 或 reject class。

也想出现在这里?联系我们
创客主机
  1. <ul id="stack_yuda" class="stack stack--yuda">
  2.   <li class="stack__item"><img src="img/1.png" alt="Tree 1" /></li>
  3.   <li class="stack__item"><img src="img/2.png" alt="Tree 2" /></li>
  4.   <li class="stack__item"><img src="img/3.png" alt="Tree 3" /></li>
  5.   <li class="stack__item"><img src="img/4.png" alt="Tree 4" /></li>
  6.   <li class="stack__item"><img src="img/5.png" alt="Tree 5" /></li>
  7.   <li class="stack__item"><img src="img/6.png" alt="Tree 6" /></li>
  8. </ul>
  9. <div class="controls">
  10.   <button class="button button--sonar button--reject" data-stack="stack_yuda">
  11.     <i class="fa fa-times"></i>
  12.     <span class="text-hidden">Reject</span>
  13.   </button>
  14.   <button class="button button--sonar button--accept" data-stack="stack_yuda">
  15.     <i class="fa fa-check"></i>
  16.     <span class="text-hidden">Accept</span>
  17.   </button>
  18. </div>

JavaScript

对于这个例子中,main.js 文件中提供了一些函数来实现各种功能。动画的实现使用的是 dynamics.js 动画库。而移动卡片的动画则是通过 CSS3 动画来实现的。插件有一些的一些参数选项:

  1. Stack.prototype.options = {
  2.   // stack的透视值
  3.   perspective: 1000,
  4.  
  5.   // stack的透视原点
  6.   perspectiveOrigin : '50% -50%',
  7.  
  8.   // stack的可见项目数量
  9.   visible : 3,
  10.  
  11.   // 无限循环
  12.   infinite : true,
  13.  
  14.   // callback: 当到达栈顶时触发
  15.   onEndStack : function() {return false;},
  16.  
  17.   // animation settings for the items' movements in the stack when the items rearrange
  18.   // object that is passed to the dynamicsjs animate function (see more at http://dynamicsjs.com/)
  19.   // example:
  20.   // {type: dynamics.spring,duration: 1641,frequency: 557,friction: 459,anticipationSize: 206,anticipationStrength: 392}
  21.   stackItemsAnimation : {
  22.     duration : 500,
  23.     type : dynamics.bezier,
  24.     points : [{'x':0,'y':0,'cp':[{'x':0.25,'y':0.1}]},{'x':1,'y':1,'cp':[{'x':0.25,'y':1}]}]
  25.   },
  26.  
  27.   // delay for the items' rearrangement / delay before stackItemsAnimation is applied
  28.   stackItemsAnimationDelay : 0,
  29.  
  30.   // animation settings for the items' movements in the stack before the rearrangement
  31.   // we can set up different settings depending on whether we are approving or rejecting an item
  32.   stackItemsPreAnimation : {
  33.     reject : {
  34.       // if true, then the settings.properties parameter will be distributed through the items in a non equal fashion
  35.       // for instance, if we set settings.properties = {translateX:100} and we have options.visible = 4, 
  36.       // then the second item in the stack will translate 100px, the second one 75px and the third 50px
  37.       elastic : true,
  38.       // object that is passed into the dynamicsjs animate function - second parameter -  (see more at http://dynamicsjs.com/)
  39.       animationProperties : {},
  40.       // object that is passed into the dynamicsjs animate function - third parameter - (see more at http://dynamicsjs.com/)
  41.       animationSettings : {} 
  42.     },
  43.     accept : {
  44.       // if true, then the settings.properties parameter will be distributed through the items in a non equal fashion
  45.       // for instance, if we set settings.properties = {translateX:100} and we have options.visible = 4, 
  46.       // then the second item on the stack will translate 100px, the second one 75px and the third 50px
  47.       elastic : true,
  48.       // object that is passed into the dynamicsjs animate function - second parameter -  (see more at http://dynamicsjs.com/)
  49.       animationProperties : {},
  50.       // object that is passed into the dynamicsjs animate function (see more at http://dynamicsjs.com/)
  51.       animationSettings : {}
  52.     }
  53.   }
  54. }

对于这个例子中使用的 CSS3 动画代码如下:

  1. /******************** yuda *********************/
  2. .stack--yuda .stack__item--reject {
  3.   -webkit-animation: yudaReject 0.5s forwards;
  4.   animation: yudaReject 0.5s forwards;
  5. }
  6.  
  7. @-webkit-keyframes yudaReject {
  8.   to {
  9.     opacity: 0;
  10.     -webkit-transform: translate3d(0, 200px, 0);
  11.     transform: translate3d(0, 200px, 0);
  12.   }
  13. }
  14.  
  15. @keyframes yudaReject {
  16.   to {
  17.     opacity: 0;
  18.     -webkit-transform: translate3d(0, 200px, 0);
  19.     transform: translate3d(0, 200px, 0);
  20.   }
  21. }
  22.  
  23. .stack--yuda .stack__item--accept {
  24.   -webkit-transform-origin: 50% 300%;
  25.   transform-origin: 50% 300%;
  26.   -webkit-animation: yudaAccept 0.5s forwards;
  27.   animation: yudaAccept 0.5s forwards;
  28. }
  29.  
  30. @-webkit-keyframes yudaAccept {
  31.   to {
  32.     opacity: 0;
  33.     -webkit-transform: rotate3d(0, 0, 1, 20deg);
  34.     transform: rotate3d(0, 0, 1, 20deg);
  35.   }
  36. }
  37.  
  38. @keyframes yudaAccept {
  39.   to {
  40.     opacity: 0;
  41.     -webkit-transform: rotate3d(0, 0, 1, 20deg);
  42.     transform: rotate3d(0, 0, 1, 20deg);
  43.   }
  44. }

其它例子的实现代码请参考下载文件。

炫酷堆叠卡片切换动画特效

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

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

发表回复

热销模板

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

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