From 6fd082e9567866160858f3c245faaae732921196 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Thu, 17 Feb 2022 14:16:49 +0100 Subject: [PATCH] MOBILE-3833 course: Fix collapsible header after manual compl change --- src/core/directives/collapsible-header.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/core/directives/collapsible-header.ts b/src/core/directives/collapsible-header.ts index 970195123..95c31c943 100644 --- a/src/core/directives/collapsible-header.ts +++ b/src/core/directives/collapsible-header.ts @@ -297,13 +297,16 @@ export class CoreCollapsibleHeaderDirective implements OnDestroy { const collapsibleHeaderHeight = this.title.shadowRoot?.children[0].clientHeight ?? this.title.clientHeight; const scrollableHeight = this.contentScroll.scrollHeight - this.contentScroll.clientHeight; const collapsedHeight = collapsibleHeaderHeight - this.title.clientHeight; - const progress = CoreMath.clamp( - scrollableHeight + collapsedHeight <= 2 * collapsibleHeaderHeight - ? this.contentScroll.scrollTop / (this.contentScroll.scrollHeight - this.contentScroll.clientHeight) - : this.contentScroll.scrollTop / collapsibleHeaderHeight, - 0, - 1, - ); + let progress = 0; + if (scrollableHeight !== 0) { + progress = CoreMath.clamp( + scrollableHeight + collapsedHeight <= 2 * collapsibleHeaderHeight + ? this.contentScroll.scrollTop / scrollableHeight + : this.contentScroll.scrollTop / collapsibleHeaderHeight, + 0, + 1, + ); + } const collapsed = progress === 1; if (!this.inContent) {