Scroll btn improvement

This commit is contained in:
Adina Țeudan 2021-11-29 23:30:33 +02:00
parent f953aefa0e
commit 0a861bf60d

View File

@ -29,7 +29,7 @@ export class ScrollButtonComponent implements OnInit {
ngOnInit(): void {
const scrollSize = () => this.scrollViewport.getDataLength() * this.itemSize;
const scrollIsNeeded = () => this.scrollViewport.getViewportSize() < scrollSize();
const reachedEnd = (type: ButtonType) => this.scrollViewport.measureScrollOffset(type) === 0;
const reachedEnd = (type: ButtonType) => this.scrollViewport.measureScrollOffset(type) < 0.5;
const showScrollUp = () => scrollIsNeeded() && !reachedEnd(ButtonTypes.top);
const showScrollDown = () => scrollIsNeeded() && !reachedEnd(ButtonTypes.bottom);