Skip to content

Commit

Permalink
页面滚动显示(小窗)
Browse files Browse the repository at this point in the history
  • Loading branch information
haocity committed Feb 19, 2018
1 parent 800ed53 commit 3e93279
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/tdplayer.js

Large diffs are not rendered by default.

18 changes: 15 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,9 +512,8 @@ class Tplayer {
} else if(wz == 2) {
//顶部弹幕
dm.appendChild(document.createTextNode(text))

dm.className = "danmaku tp-top"
let dtop = this.gettoptop()
let dtop = this.getcansendtop()
dm.style.top = dtop * this.dmheight + "px"
this.toparr[dtop] = 1
let e = this.ele.danmaku_warp.appendChild(dm)
Expand Down Expand Up @@ -1270,6 +1269,19 @@ class Tplayer {
_this.ele.livenumber=e
w.appendChild(e)
}
//页面滚动显示
this.options.srollfixe=screen.height
if(this.options.srollfixe&&this.options.srollfixe>0){
document.addEventListener('scroll',()=> {
if((document.documentElement.scrollTop||document.body.scrollTop) >= this.options.srollfixe) {
this.ele.tp_video_warp.className='tp-video-warp tp-video-warp-fixed'
}else{
this.ele.tp_video_warp.className='tp-video-warp'
}
})
}


}
//函數
$c(e) {
Expand Down Expand Up @@ -1650,7 +1662,7 @@ class Tplayer {
this.leftarr.width[h]=dmwidth;
return h;
};
gettoptop() {
getcansendtop() {
let h;
for(let i = 0; i <= this.toparr.length; i++) {
if(!this.toparr[i]) {
Expand Down
13 changes: 13 additions & 0 deletions src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,19 @@ section.player{
height: 100%;
width: 100%;
}

.tp-video-warp.tp-video-warp-fixed{
position: fixed;
right: 10px;
top: 10px;
width: 360px;
height: 230px;
z-index: 99;
}
.tp-video-warp.tp-video-warp-fixed .tp-control{
display: none!important;
}

.tp-video-warp p{
margin: 0;
}
Expand Down

0 comments on commit 3e93279

Please sign in to comment.