index.html 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <title>动画</title>
  2. <div class="layui-card layadmin-header">
  3. <div class="layui-breadcrumb" lay-filter="breadcrumb">
  4. <a lay-href="">主页</a>
  5. <a><cite>组件</cite></a>
  6. <a><cite>动画</cite></a>
  7. </div>
  8. </div>
  9. <style>
  10. /* 这段样式只是用于演示 */
  11. #component-anim .layui-card-body{padding: 15px;}
  12. #component-anim .component-anim-demo{margin-bottom: 50px; font-size: 0;}
  13. #component-anim .component-anim-demo li{display: inline-block; vertical-align: middle; width: 127px; line-height: 25px; padding: 20px 0; margin-right: -1px; margin-bottom: -1px; border: 1px solid #e2e2e2; font-size: 14px; text-align: center; color: #666; transition: all .3s; -webkit-transition: all .3s;}
  14. #component-anim .component-anim-demo li .layui-icon{display: inline-block; font-size: 36px;}
  15. #component-anim .component-anim-demo li .fontclass{display: none;}
  16. #component-anim .component-anim-demo li .name{color: #c2c2c2;}
  17. #component-anim .component-anim-demo li:hover{background-color: #f2f2f2; color: #000;}
  18. #component-anim .component-anim-demo li{width: 222px;}
  19. #component-anim .component-anim-demo .layui-anim{width: 150px; height: 150px; line-height: 150px; margin: 0 auto 10px; text-align: center; background-color: #009688; cursor: pointer; color: #fff; border-radius: 50%;}
  20. </style>
  21. <div class="layui-fluid" id="component-anim">
  22. <div class="layui-row layui-col-space15">
  23. <div class="layui-col-md12">
  24. <div class="layui-card">
  25. <div class="layui-card-header">点击演示动画</div>
  26. <div class="layui-card-body">
  27. <ul class="component-anim-demo">
  28. <li>
  29. <div class="layui-anim" data-anim="layui-anim-up">从最底部往上滑入</div>
  30. <div class="code">layui-anim-up</div>
  31. </li>
  32. <li>
  33. <div class="layui-anim" data-anim="layui-anim-upbit">微微往上滑入</div>
  34. <div class="code">layui-anim-upbit</div>
  35. </li>
  36. <li>
  37. <div class="layui-anim" data-anim="layui-anim-scale">平滑放大</div>
  38. <div class="code">layui-anim-scale</div>
  39. </li>
  40. <li>
  41. <div class="layui-anim" data-anim="layui-anim-scaleSpring">弹簧式放大</div>
  42. <div class="code">layui-anim-scaleSpring</div>
  43. </li>
  44. </ul>
  45. <ul class="component-anim-demo">
  46. <li>
  47. <div class="layui-anim" data-anim="layui-anim-fadein">渐现</div>
  48. <div class="code">layui-anim-fadein</div>
  49. </li>
  50. <li>
  51. <div class="layui-anim" data-anim="layui-anim-fadeout">渐隐</div>
  52. <div class="code">layui-anim-fadeout</div>
  53. </li>
  54. <li>
  55. <div class="layui-anim" data-anim="layui-anim-rotate">360度旋转</div>
  56. <div class="code">layui-anim-rotate</div>
  57. </li>
  58. <li>
  59. <div class="layui-anim" data-anim="layui-anim-rotate layui-anim-loop">循环动画</div>
  60. <div class="code">追加:layui-anim-loop</div>
  61. </li>
  62. </ul>
  63. </div>
  64. </div>
  65. </div>
  66. </div>
  67. </div>
  68. <script>
  69. layui.use(['admin'], function(){
  70. var $ = layui.$
  71. ,admin = layui.admin
  72. ,element = layui.element
  73. ,router = layui.router();
  74. /* 演示动画 */
  75. $('#component-anim .component-anim-demo .layui-anim').on('click', function(){
  76. var othis = $(this), anim = othis.data('anim');
  77. /* 停止循环 */
  78. if(othis.hasClass('layui-anim-loop')){
  79. return othis.removeClass(anim);
  80. }
  81. othis.removeClass(anim);
  82. setTimeout(function(){
  83. othis.addClass(anim);
  84. });
  85. /* 恢复渐隐 */
  86. if(anim === 'layui-anim-fadeout'){
  87. setTimeout(function(){
  88. othis.removeClass(anim);
  89. }, 1300);
  90. }
  91. });
  92. });
  93. </script>