Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(design): update sidebar viewport overflow style to change on animation start and done #2718

Merged
merged 1 commit into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,21 @@
(backdropClicked)="_backdropClicked()">
</daff-backdrop>

<div class="daff-sidebar-viewport__nav" [@transformContent]="_animationState" [style.padding-left.px]="_navPadLeft" [style.padding-right.px]="_navPadRight">
<ng-content select="[daff-sidebar-viewport-nav]"></ng-content>
<div class="daff-sidebar-viewport__nav"
[@transformContent]="_animationState"
[style.padding-left.px]="_navPadLeft"
[style.padding-right.px]="_navPadRight">
<ng-content select="[daff-sidebar-viewport-nav]"></ng-content>
</div>

<div class="daff-sidebar-viewport__content" [@transformContent]="_animationState">
<div class="daff-sidebar-viewport__inner" [style.padding-left.px]="_contentPadLeft" [style.padding-right.px]="_contentPadRight">
<ng-content></ng-content>
<div class="daff-sidebar-viewport__content"
[@transformContent]="_animationState"
(@transformContent.start)="onContentAnimationStart($event)"
(@transformContent.done)="onContentAnimationDone($event)">
<div class="daff-sidebar-viewport__inner"
[style.padding-left.px]="_contentPadLeft"
[style.padding-right.px]="_contentPadRight">
<ng-content></ng-content>
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { AnimationEvent } from '@angular/animations';
import {
Component,
Output,
Expand Down Expand Up @@ -87,6 +88,18 @@ export class DaffSidebarViewportComponent implements AfterContentChecked {
return this.navPlacement === DaffNavPlacementEnum.BESIDE;
}

onContentAnimationStart(e: AnimationEvent) {
if(e.toState === 'open') {
this._elementRef.nativeElement.style.overflow = 'hidden';
}
}

onContentAnimationDone(e: AnimationEvent) {
if(e.toState === 'closed') {
this._elementRef.nativeElement.style.overflow = null;
}
}

/**
* The placement of the nav in relation to the sidebar. The default is set to `top`.
* Note that this is really only available when there is a `side-fixed` sidebar.
Expand Down Expand Up @@ -153,13 +166,7 @@ export class DaffSidebarViewportComponent implements AfterContentChecked {
const nextShift = sidebarViewportContentShift(this.sidebars) + 'px';
if (this._shift !== nextShift) {
this._shift = nextShift;
if(nextShift !== '0px') {
this._elementRef.nativeElement.style.overflow = 'hidden';
} else {
setTimeout(() => {
this._elementRef.nativeElement.style.overflow = null;
}, 200);
}

this.updateAnimationState();
this.cdRef.markForCheck();
}
Expand Down