MOBILE-3833 course: Fix collapsible header after manual compl change

main
Dani Palou 2022-02-17 14:16:49 +01:00
parent 8df2680eac
commit 6fd082e956
1 changed files with 10 additions and 7 deletions

View File

@ -297,13 +297,16 @@ export class CoreCollapsibleHeaderDirective implements OnDestroy {
const collapsibleHeaderHeight = this.title.shadowRoot?.children[0].clientHeight ?? this.title.clientHeight; const collapsibleHeaderHeight = this.title.shadowRoot?.children[0].clientHeight ?? this.title.clientHeight;
const scrollableHeight = this.contentScroll.scrollHeight - this.contentScroll.clientHeight; const scrollableHeight = this.contentScroll.scrollHeight - this.contentScroll.clientHeight;
const collapsedHeight = collapsibleHeaderHeight - this.title.clientHeight; const collapsedHeight = collapsibleHeaderHeight - this.title.clientHeight;
const progress = CoreMath.clamp( let progress = 0;
if (scrollableHeight !== 0) {
progress = CoreMath.clamp(
scrollableHeight + collapsedHeight <= 2 * collapsibleHeaderHeight scrollableHeight + collapsedHeight <= 2 * collapsibleHeaderHeight
? this.contentScroll.scrollTop / (this.contentScroll.scrollHeight - this.contentScroll.clientHeight) ? this.contentScroll.scrollTop / scrollableHeight
: this.contentScroll.scrollTop / collapsibleHeaderHeight, : this.contentScroll.scrollTop / collapsibleHeaderHeight,
0, 0,
1, 1,
); );
}
const collapsed = progress === 1; const collapsed = progress === 1;
if (!this.inContent) { if (!this.inContent) {