MOBILE-3811 core: Improve collapsible header animation
parent
c7e3e68a94
commit
e3daf3738c
|
@ -141,14 +141,12 @@ export class CoreSplitViewComponent implements AfterViewInit, OnDestroy {
|
|||
* Another manual solution is to add scroll-y=false on the ion-contents outside the split view.
|
||||
*/
|
||||
protected disableScrollOnParent(): void {
|
||||
let outerContent = this.element.nativeElement.parentElement?.closest('ion-content');
|
||||
while (outerContent) {
|
||||
const outerContent = this.element.nativeElement.parentElement?.closest('ion-content');
|
||||
if (outerContent) {
|
||||
if (outerContent?.getAttribute('scroll-y') != 'false' && !outerContent?.classList.contains(disabledScrollClass)) {
|
||||
outerContent.classList.add(disabledScrollClass);
|
||||
this.disabledScrollOuterContents.push(outerContent);
|
||||
}
|
||||
|
||||
outerContent = outerContent.parentElement?.closest('ion-content');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ export class CoreCollapsibleHeaderDirective implements OnDestroy {
|
|||
protected contentSubHeadingFontSize = 0;
|
||||
protected subHeadingStartDifference = 0;
|
||||
|
||||
constructor(el: ElementRef) {
|
||||
constructor(el: ElementRef<HTMLIonHeaderElement>) {
|
||||
this.header = el.nativeElement;
|
||||
|
||||
this.loadingObserver = CoreEvents.on(CoreEvents.CORE_LOADING_CHANGED, async (data) => {
|
||||
|
@ -122,6 +122,11 @@ export class CoreCollapsibleHeaderDirective implements OnDestroy {
|
|||
}
|
||||
|
||||
this.titleTopDifference = contentH1.getBoundingClientRect().top - headerH1.getBoundingClientRect().top;
|
||||
if (this.titleTopDifference <= 0) {
|
||||
this.cannotCollapse();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Split view part.
|
||||
const contentAux = this.header.parentElement?.querySelector<HTMLElement>('ion-content.disable-scroll-y');
|
||||
|
@ -210,7 +215,9 @@ export class CoreCollapsibleHeaderDirective implements OnDestroy {
|
|||
|
||||
this.content.scrollEvents = true;
|
||||
this.content.addEventListener('ionScroll', (e: CustomEvent<ScrollDetail>): void => {
|
||||
this.onScroll(title, contentH1, contentSubHeading, e.detail);
|
||||
if (e.target == this.content) {
|
||||
this.onScroll(title, contentH1, contentSubHeading, e.detail);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -234,6 +241,8 @@ export class CoreCollapsibleHeaderDirective implements OnDestroy {
|
|||
this.header.classList.toggle('core-header-collapsed', collapsed);
|
||||
title.classList.toggle('collapsible-title-collapsed', collapsed);
|
||||
title.classList.toggle('collapsible-title-collapse-started', scrollDetail.scrollTop > 0);
|
||||
title.classList.toggle('collapsible-title-collapse-nowrap', progress > 0.5);
|
||||
title.style.setProperty('--collapse-opacity', (1 - progress) +'');
|
||||
|
||||
if (collapsed) {
|
||||
contentH1.style.transform = 'translateX(-' + this.h1StartDifference + 'px)';
|
||||
|
|
|
@ -1257,21 +1257,26 @@ ion-app.md .collapsible-title h1 {
|
|||
}
|
||||
|
||||
.collapsible-title.collapsible-title-collapsed {
|
||||
ion-label, h1, h2, .subheading {
|
||||
ion-label, h1, h2, ion-row, ion-col, .subheading {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.collapsible-title.collapsible-title-collapse-started {
|
||||
* {
|
||||
opacity: 0;
|
||||
opacity: var(--collapse-opacity, 0);
|
||||
}
|
||||
ion-label, h1, h2, .subheading {
|
||||
|
||||
ion-label, h1, h2, ion-row, ion-col, .subheading {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.collapsible-title.collapsible-title-collapse-nowrap {
|
||||
h1, h2, .subheading {
|
||||
max-width: var(--max-width);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue