1、在主题 /layout/_partial/目录新建一个loading-pages.ejs 内容如下:

  1. <style type="text/css" lang="css">
  2. #loading-container{
  3. position: fixed;
  4. top: 0;
  5. left: 0;
  6. min-height: 100vh;
  7. width: 100vw;
  8. z-index: 9999;
  9. display: flex;
  10. flex-direction: column;
  11. justify-content: center;
  12. align-items: center;
  13. background: #FFF;
  14. text-align: center;
  15. /* loader页面消失采用渐隐的方式*/
  16. -webkit-transition: opacity 1s ease;
  17. -moz-transition: opacity 1s ease;
  18. -o-transition: opacity 1s ease;
  19. transition: opacity 1s ease;
  20. }
  21. .loading-image{
  22. width: 120px;
  23. height: 50px;
  24. transform: translate(-50%);
  25. }
  26. .loading-image div:nth-child(2) {
  27. -webkit-animation: pacman-balls 1s linear 0s infinite;
  28. animation: pacman-balls 1s linear 0s infinite
  29. }
  30. .loading-image div:nth-child(3) {
  31. -webkit-animation: pacman-balls 1s linear .33s infinite;
  32. animation: pacman-balls 1s linear .33s infinite
  33. }
  34. .loading-image div:nth-child(4) {
  35. -webkit-animation: pacman-balls 1s linear .66s infinite;
  36. animation: pacman-balls 1s linear .66s infinite
  37. }
  38. .loading-image div:nth-child(5) {
  39. -webkit-animation: pacman-balls 1s linear .99s infinite;
  40. animation: pacman-balls 1s linear .99s infinite
  41. }
  42. .loading-image div:first-of-type {
  43. width: 0;
  44. height: 0;
  45. border: 25px solid #49b1f5;
  46. border-right-color: transparent;
  47. border-radius: 25px;
  48. -webkit-animation: rotate_pacman_half_up .5s 0s infinite;
  49. animation: rotate_pacman_half_up .5s 0s infinite;
  50. }
  51. .loading-image div:nth-child(2) {
  52. width: 0;
  53. height: 0;
  54. border: 25px solid #49b1f5;
  55. border-right-color: transparent;
  56. border-radius: 25px;
  57. -webkit-animation: rotate_pacman_half_down .5s 0s infinite;
  58. animation: rotate_pacman_half_down .5s 0s infinite;
  59. margin-top: -50px;
  60. }
  61. @-webkit-keyframes rotate_pacman_half_up {0% {transform: rotate(270deg)}50% {transform: rotate(1turn)}to {transform: rotate(270deg)}}
  62. @keyframes rotate_pacman_half_up {0% {transform: rotate(270deg)}50% {transform: rotate(1turn)}to {transform: rotate(270deg)}}
  63. @-webkit-keyframes rotate_pacman_half_down {0% {transform: rotate(90deg)}50% {transform: rotate(0deg)}to {transform: rotate(90deg)}}
  64. @keyframes rotate_pacman_half_down {0% {transform: rotate(90deg)}50% {transform: rotate(0deg)}to {transform: rotate(90deg)}}
  65. @-webkit-keyframes pacman-balls {75% {opacity: .7}to {transform: translate(-100px, -6.25px)}}
  66. @keyframes pacman-balls {75% {opacity: .7}to {transform: translate(-100px, -6.25px)}}
  67. .loading-image div:nth-child(3),
  68. .loading-image div:nth-child(4),
  69. .loading-image div:nth-child(5),
  70. .loading-image div:nth-child(6){
  71. background-color: #49b1f5;
  72. width: 15px;
  73. height: 15px;
  74. border-radius: 100%;
  75. margin: 2px;
  76. width: 10px;
  77. height: 10px;
  78. position: absolute;
  79. transform: translateY(-6.25px);
  80. top: 25px;
  81. left: 100px;
  82. }
  83. .loading-text{
  84. margin-bottom: 20vh;
  85. text-align: center;
  86. color: #2c3e50;
  87. font-size: 2rem;
  88. box-sizing: border-box;
  89. padding: 0 10px;
  90. text-shadow: 0 2px 10px rgba(0,0,0,0.2);
  91. }
  92. @media only screen and (max-width: 500px) {
  93. .loading-text{
  94. font-size: 1.5rem;
  95. }
  96. }
  97. .fadeout {
  98. opacity: 0;
  99. filter: alpha(opacity=0);
  100. }
  101. /* logo出现动画 */
  102. @-webkit-keyframes fadeInDown{0%{opacity:0;-webkit-transform:translate3d(0,-100%,0);transform:translate3d(0,-100%,0)}100%{opacity:1;-webkit-transform:none;transform:none}}
  103. @keyframes fadeInDown{0%{opacity:0;-webkit-transform:translate3d(0,-100%,0);}}
  104. </style>
  105. <script>
  106. (function () {
  107. const loaded = function(){
  108. setTimeout(function(){
  109. const loader = document.getElementById("loading-container");
  110. loader.className="fadeout" ;//使用渐隐的方法淡出loading page
  111. // document.getElementById("body-wrap").style.display="flex";
  112. setTimeout(function(){
  113. loader.style.display="none";
  114. },2500);
  115. },1000);//强制显示loading page 1s
  116. };
  117. loaded();
  118. })()
  119. </script>

2、在主题的 layout 目录找到 layout.ejs 文件

<body>附近添加内容后如下:

  1. <!DOCTYPE HTML>
  2. <html lang="<%= config.language %>">
  3. <%- partial('_partial/head') %>
  4. <% if (theme.loadingPages.enable) { %>
  5. <%- partial('_partial/loading-pages') %>
  6. <% } %>
  7. <body>
  8. <% if (theme.loadingPages.enable) { %>
  9. <div id="loading-container">
  10. <p class="loading-text">嘘~ 正在从服务器偷取页面 . . . </p>
  11. <div class="loading-image">
  12. <div></div>
  13. <div></div>
  14. <div></div>
  15. <div></div>
  16. <div></div>
  17. </div>
  18. </div>
  19. <% } %>
  20. <%- partial('_partial/header') %>
  21. ...

3、在主题配置文件_config.yml添加开关配置

  1. loadingPages:
  2. enable: true

enable 设置为 true 表示开启加载动画, false 表示关闭加载动画。

matery添加加载动画的更多相关文章

  1. 为页内的tab添加的iframe添加加载动画过渡效果

    var iframe = $("iframe[data-id=" + id + " ]"); if (iframe.length > 0) { var e ...

  2. 利用CAReplicatorLayer实现的加载动画

    在上一篇中,笔者简要介绍了CAReplicatorLayer,在本篇中,将介绍具体的实用价值. 实用CAReplicatorLayer作为核心技术实现加载动画. 首先,创建一个UIView的子类 @i ...

  3. 用css3制作旋转加载动画的几种方法

    以WebKit为核心的浏览器,例如Safari和Chrome,对html5有着很好的支持,在移动平台中这两个浏览器对应的就是IOS和Android.最近在开发一个移动平台的web app,那么就有机会 ...

  4. ReactNative学习实践--动画初探之加载动画

    学习和实践react已经有一段时间了,在经历了从最初的彷徨到解决痛点时的兴奋,再到不断实践后遭遇问题时的苦闷,确实被这一种新的思维方式和开发模式所折服,react不是万能的,在很多场景下滥用反而会适得 ...

  5. iOS开发——图形编程Swift篇&CAShapeLayer实现圆形图片加载动画

    CAShapeLayer实现圆形图片加载动画 几个星期之前,Michael Villar在Motion试验中创建一个非常有趣的加载动画. 下面的GIF图片展示这个加载动画,它将一个圆形进度指示器和圆形 ...

  6. 使用CAShapeLayer来实现圆形图片加载动画[译]

    原文链接 : How To Implement A Circular Image Loader Animation with CAShapeLayer 原文作者 : Rounak Jain 译文出自 ...

  7. 你会用swift创建复杂的加载动画吗(1)

    时至今日,iOS 应用商店已经拥有超过了140万 应用,让你自己的应用脱颖而出确实是个不小的挑战.不过,在你的应用掉入默默无闻的大黑洞之前,你拥有一个小小的机遇窗,它能帮你吸引用户的注意. AD: 时 ...

  8. 自定义动画(仿Win10加载动画)

    一.源代码 源代码及demo 二.背景 先看看Win10的加载动画(找了很久才找到): CPA推广甲爪广告联盟满30日结 [点击进入] 甲爪广告联盟,提供各类高单价CPA广告 单价高 收益好 日付广告 ...

  9. 加载动画插件spin.js的使用随笔

    背景: 在请求后台的“漫长”等待过程中,为了提升用户体验,需要一个类似  的加载动画效果,让用户明确现在处于请求过程中,而不是机子down掉或者网站死了 静态demo(未与后台交互): HTML代码如 ...

随机推荐

  1. C++ 炼气期之变量的生命周期和作用域

    1. 前言 什么是变量的生命周期? 从变量被分配空间到空间被收回的这一个时间段,称为变量的生命周期. 什么是变量的作用域? 在变量的生命周期内,其存储的数据并不是在任何地方都能使用,变量能使用的范围, ...

  2. Markdown常见基本语法

    标题 -方式一:使用警号 几个警号就是几级标题,eg: # 一级标题 -方式二: 使用快捷键 ctrl+数字 几级标题就选其对应的数字, eg: ctrl+2(二级标题) 子标题 -方式一: 使用星号 ...

  3. BUUCTF-[BJDCTF2020]认真你就输了

    [BJDCTF2020]认真你就输了 下载通过16进制查看发现是压缩包,直接就binwalk分离查看. 分离直接得到几个文件,不过好像压缩包里的和外面的文件是一样的,所以直接翻一下目录 直接就找到了 ...

  4. JavaScript 防盗链的原理以及破解方法

    先说说防盗链的原理,http 协议中,如果从一个网页跳到另一个网页,http 头字段里面会带个 Referer.这里的Referer是由于历史原因导致了拼写错误 后来也就一直沿用.图片服务器通过检测 ...

  5. 实现领域驱动设计 - 使用ABP框架 - 什么是领域驱动设计?

    前言: 最近看到ABP官网的一本电子书,感觉写的很好,翻译出来,一起学习下 (Implementing Domain Driven Design) https://abp.io/books DDD简介 ...

  6. StringJoiner的使用

    1.添加字符串 add()方法 StringJoiner sj = new StringJoiner(","); sj.add("我爱你"); sj.add(& ...

  7. 干货 |《2022B2B新增长系列之企服行业橙皮书》重磅发布

    企服行业面临的宏观环境和微观环境已然发生了明显的变化.一方面,消费级互联网成为过去式,爆发式增长的时代结束.资本.媒体的目光已经悄然聚焦到以企服行业所代表的产品互联网身上,B2B企业正稳步走向C位. ...

  8. 智能指针思想实践(std::unique_ptr, std::shared_ptr)

    1 smart pointer 思想 ​ 个人认为smart pointer实际上就是一个对原始指针类型的一个封装类,并对外提供了-> 和 * 两种操作,使得其能够表现出原始指针的操作行为. ​ ...

  9. 【跟着大佬学JavaScript】之lodash防抖节流合并

    前言 前面已经对防抖和节流有了介绍,这篇主要看lodash是如何将防抖和节流合并成一个函数的. 初衷是深入lodash,学习它内部的好代码并应用,同时也加深节流防抖的理解.这里会先从防抖开始一步步往后 ...

  10. JavaScript基本知识点——带你逐步解开JS的神秘面纱

    JavaScript基本知识点--带你逐步解开JS的神秘面纱 在我们前面的文章中已经深入学了HTML和CSS,在网页设计中我们已经有能力完成一个美观的网页框架 但仅仅是网页框架不足以展现出网页的魅力, ...