Ai 1 Star 0 Fork 0

KatyLight/组件库

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
index.html 2.04 KB
一键复制 编辑 原始数据 按行查看 历史
KatyLight 提交于 2022-02-22 13:12 +08:00 . add KatyLightProgressIndicator/index.html.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
body{
background-color: black;
}
.KatyLight-Progress-Indicator{
position: fixed;
z-index: 9999;
left: 0;
right: 0;
top: 0;
height: 5px;
}
.KatyLight-Progress-Indicator>.inner{
height: 2px;
width: 0;
background-color: cyan;
box-shadow: 0 0 10px 5px #00FFFF99;
}
</style>
<script>
class ProgressIndicator{
constructor(props) {
this.target=document.createElement('div')
this.target.classList.add("KatyLight-Progress-Indicator")
this.inner=document.createElement('div')
this.inner.classList.add('inner')
this.target.append(this.inner)
document.body.append(this.target);
this.maxHeight=document.body.scrollHeight;
this.viewHeight=window.screen.height;
this.maxMove=this.maxHeight-this.viewHeight;
this.move=0;
this.setLine();
this.scrollZ=this.scroll.bind(this)
document.addEventListener('scroll', this.scrollZ)
}
scroll(e){
this.setLine();
}
setLine(){
this.move=document.documentElement .scrollTop;
if(this.maxMove<1){
this.inner.style.width=100+"%"
}else{
this.inner.style.width=(this.move/this.maxMove*100).toFixed(2)+"%"
}
}
update(){
this.maxHeight=document.body.scrollHeight;
this.viewHeight=window.screen.height;
this.maxMove=this.maxHeight-this.viewHeight;
this.move=document.documentElement .scrollTop;
if(this.maxMove<1){
this.inner.style.width=100+"%"
}else{
this.inner.style.width=(this.move/this.maxMove*100).toFixed(2)+"%"
}
}
}
window.onload=()=>{
let k=new ProgressIndicator();
}
</script>
</head>
<body>
<div style="height: 3000px"></div>
</body>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/KatyLight/Tools.git
git@gitee.com:KatyLight/Tools.git
KatyLight
Tools
组件库
master

搜索帮助