Commit a7a2b357 authored by Chen Jiping's avatar Chen Jiping

fix:优化滚动条显示

parent 22c2789e
...@@ -162,4 +162,22 @@ export class Scrollbar { ...@@ -162,4 +162,22 @@ export class Scrollbar {
this.scrollbar.y = newY; this.scrollbar.y = newY;
} }
isTop(){
if(this.scrollbar.y == this.scrollbarInitY){
return true;
}
else{
return false;
}
}
isBottom(){
if(this.scrollbar.y == this.scrollbarInitY + this.canMoveDis){
return true;
}
else{
return false;
}
}
} }
\ No newline at end of file
...@@ -983,8 +983,10 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -983,8 +983,10 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
private setShowRow() { private setShowRow() {
let len = this.sentenceArr.length;
for(let i = 0; i < this.sentenceArr.length; ++ i){ for(let i = 0; i < len; ++ i){
let sentence = this.sentenceArr[i]; let sentence = this.sentenceArr[i];
...@@ -994,7 +996,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -994,7 +996,7 @@ export class PlayComponent implements OnInit, OnDestroy {
let offsetY = Math.floor(y - h / 2); let offsetY = Math.floor(y - h / 2);
if(offsetY < Math.floor(this.initY) || (offsetY + Math.floor(h)) > Math.floor(this.initY + this.sentenceBg.height)){ if(offsetY < Math.floor(this.initY - 5 * this.mapScale) || (offsetY + Math.floor(h)) > Math.floor(this.initY + this.sentenceBg.height)){
sentence.visible = false; sentence.visible = false;
this.indexLabelArr[i].visible = false; this.indexLabelArr[i].visible = false;
} }
...@@ -1004,6 +1006,21 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1004,6 +1006,21 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
} }
if(len > 0){
//如果到达顶部,则默认显示第一行
if(this.scrollbar.isTop()){
this.sentenceArr[0].visible = true;
this.indexLabelArr[0].visible = true;
}
else if(this.scrollbar.isBottom()){
this.sentenceArr[len - 1].visible = true;
this.indexLabelArr[len - 1].visible = true;
}
}
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment