pdf.js 添加自定义loading动画
最近做了个手机端pdf预览的功能,用到pdf.js这个库,效果还不错。但是在网络差、文件大时,页面一直空白,体验不是很好。
于是加了个loading动画。
<div id="loadingContainer">
<div class="spinner">
<div class="spinner-container container1">
<div class="circle1"></div>
<div class="circle2"></div>
<div class="circle3"></div>
<div class="circle4"></div>
</div>
<div class="spinner-container container2">
<div class="circle1"></div>
<div class="circle2"></div>
<div class="circle3"></div>
<div class="circle4"></div>
</div>
<div class="spinner-container container3">
<div class="circle1"></div>
<div class="circle2"></div>
<div class="circle3"></div>
<div class="circle4"></div>
</div>
</div>
</div>
html
#loadingContainer {
width: 100%;
height: 100%;
display: flex;
align-items: center;
flex:;
z-index:;
.spinner {
margin: 100px auto;
width: 20px;
height: 20px;
position: relative;
.container1>div,
.container2>div,
.container3>div {
width: 6px;
height: 6px;
background-color: #fff;
border-radius: 100%;
position: absolute;
-webkit-animation: bouncedelay 1.2s infinite ease-in-out;
animation: bouncedelay 1.2s infinite ease-in-out;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
.spinner-container {
position: absolute;
width: 100%;
height: 100%;
}
.container2 {
-webkit-transform: rotateZ(45deg);
transform: rotateZ(45deg);
}
.container3 {
-webkit-transform: rotateZ(90deg);
transform: rotateZ(90deg);
}
.circle1 {
top:;
left:;
}
.circle2 {
top:;
right:;
}
.circle3 {
right:;
bottom:;
}
.circle4 {
left:;
bottom:;
}
.container2 .circle1 {
-webkit-animation-delay: -1.1s;
animation-delay: -1.1s;
}
.container3 .circle1 {
-webkit-animation-delay: -1.0s;
animation-delay: -1.0s;
}
.container1 .circle2 {
-webkit-animation-delay: -0.9s;
animation-delay: -0.9s;
}
.container2 .circle2 {
-webkit-animation-delay: -0.8s;
animation-delay: -0.8s;
}
.container3 .circle2 {
-webkit-animation-delay: -0.7s;
animation-delay: -0.7s;
}
.container1 .circle3 {
-webkit-animation-delay: -0.6s;
animation-delay: -0.6s;
}
.container2 .circle3 {
-webkit-animation-delay: -0.5s;
animation-delay: -0.5s;
}
.container3 .circle3 {
-webkit-animation-delay: -0.4s;
animation-delay: -0.4s;
}
.container1 .circle4 {
-webkit-animation-delay: -0.3s;
animation-delay: -0.3s;
}
.container2 .circle4 {
-webkit-animation-delay: -0.2s;
animation-delay: -0.2s;
}
.container3 .circle4 {
-webkit-animation-delay: -0.1s;
animation-delay: -0.1s;
}
}
} @-webkit-keyframes bouncedelay {
0%,
80%,
100% {
-webkit-transform: scale(0.0)
}
40% {
-webkit-transform: scale(1.0)
}
} @keyframes bouncedelay {
0%,
80%,
100% {
transform: scale(0.0);
-webkit-transform: scale(0.0);
}
40% {
transform: scale(1.0);
-webkit-transform: scale(1.0);
}
}
scss
本以为加个DOMContentLoaded事件监视移除动画就OK了。too young too simple
DOMContentLoaded完成时,pdf文件还没下载完成。看来用错了地方。查了下api后,定位到viewer.js 行号6029
如下就是pdf加载完成回调(不同版本可能略有不同)
loadingTask.onUnsupportedFeature = this.fallback.bind(this);
return loadingTask.promise.then(function getDocumentCallback(pdfDocument) {
self.load(pdfDocument, scale);
}, function getDocumentError(exception) {
source
修改后
loadingTask.onUnsupportedFeature = this.fallback.bind(this);
return loadingTask.promise.then(function getDocumentCallback(pdfDocument) {
self.load(pdfDocument, scale);
var loading = document.getElementById('loadingContainer');
loading && loading.remove();
}, function getDocumentError(exception) {
target
pdf.js 添加自定义loading动画的更多相关文章
- loading动画效果记录
看到好多网页都有一个炫酷的loading动画,以前不知道怎么实现的.今天学习了一下,发现其实也很简单. 首先在学习的时候偶然遇到一个pace.js的库,非常好用.优点是,不需要挂接到任何代码,自动检测 ...
- 纯css3 加载loading动画特效
最近项目中要实现当页面还没有加载完给用户提示正在加载的loading,本来是想做个图片提示的,但是图片如果放大电脑的分辨率就会感觉到很虚,体验效果很不好.于是就采用css3+js实现这个loading ...
- 分享web前端七款HTML5 Loading动画特效集锦
以前我们大部分的Loading动画都是利用gif图片实现的,这种图片实现Loading动画的方法虽然也很不错,但是作为HTML5开发者来说,如果能利用HTML5和CSS3实现这些超酷的Loading动 ...
- pdf转为html查看pdf.js
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 页面预加载loading动画,再载入内容
默认情况下如果网站请求速度慢,所以会有一段时间的空白页面等等,用户体验效果不好,见到很多的页面都有预加载的效果,加载之前先加载一个动画,后台进程继续加载页面内容,当页面内容加载完之后再退出动画显示内容 ...
- 使用pdf.js实现前端页面预览pdf文档,解决了跨域请求
pdf.js主要包含两个库文件,一个pdf.js和一个pdf.worker.js,,一个负责API解析,一个负责核心解析 官网地址:http://mozilla.github.io/pdf.js/ 下 ...
- electron-vue 项目添加启动loading动画问题
前言 electron-vue脚手架搭建的项目,在开发阶段可能你注意不到项目启动慢的问题,但是在build 生成的exe可执行文件,启动后,要反应很久才能进入到app.vue 中加载的页面,体验性很差 ...
- 超酷!!HTML5 Canvas 水流样式 Loading 动画
今天我们要分享另外一款基于HTML5 Canvas的液体流动样式Loading加载动画,这款Loading动画在加载时会呈现液体流动的动画效果,并且由于和背景颜色的对比,也略微呈现发光的动画效果. 效 ...
- 在线浏览PDF之PDF.JS (附demo)
平台之大势何人能挡? 带着你的Net飞奔吧!:http://www.cnblogs.com/dunitian/p/4822808.html#skill 下载地址:http://mozilla.gith ...
随机推荐
- 游戏中的过程生成——元胞自动机 Celluar Automata 生成洞穴地形
最近在学习过程生成技术,在这里写一些心得. 对于元胞自动机,我们这里只讨论输入是一副二维bool数组的情况,即大多数游戏中的情况. 一个元胞自动机,对于一个输入,给出一个同样格式的输出.输出中的每个点 ...
- phpcms v9 后台添加修改页面空白页问题解决方法
phpcms v9 添加修改页面空白页的解决方法 找一个正常运行的phpcms 将caches\caches_model\caches_data 目录下的 content_form.class.php ...
- bzoj 1061 志愿者招募 费用流
详见BYV的博客,写的非常全面https://www.byvoid.com/blog/noi-2008-employee /************************************** ...
- 获取struts迭代list在页面显示的数据
js代码: function modifyPactMoney(){ var table=$("#pactfee"); var trs=table.find("tr&quo ...
- Python实现图片转字符画
from PIL import Image def get_char(r, g, b, alpha=256): ascii_char = '''$@B%8&WM#*oahkbdpqwmZO0Q ...
- 上传文件提示413 Request Entity Too Large错误
打开nginx主配置文件nginx.conf 一般在/usr/local/nginx/conf/nginx.conf这个位置 找到http{}段并修改以下内容 client_max_body_size ...
- AC日记——逆序对 洛谷 P1908
逆序对 思路: 线段树水过: 代码: #include <cstdio> #include <cstring> #include <iostream> #inclu ...
- atom 插件
来源 个人博客 http://taoquns.com/paper/59ba5627a157197cdcc0a012 输入类 autocomplete-plus emmet go-to-line ato ...
- k-密码
链接:https://www.nowcoder.com/acm/contest/90/K来源:牛客网 题目描述 ZiZi登录各种账号的时候,总是会忘记密码,所以他把密码都记录在一个记事本上.其中第一个 ...
- Python2.5/2.6实用教程:基础篇(转)
介绍 本文方便有经验的程序员进入Python世界.本文适用于python2.5/2.6版本. Deparecated:Python3 和 python2.x语法不同.如果你正在用python3,请参考 ...