Skip to content

Commit

Permalink
#826 - Fixing toggle collapse scroll on brews
Browse files Browse the repository at this point in the history
  • Loading branch information
graphefruit committed Oct 24, 2024
1 parent 106a7d0 commit faaa18f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/app/brew/brew.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
</div>
</div>

<ag-virtual-scroll #openScroll [items]="openBrewsView" height="100vh" [min-row-height]="isCollapseActive()?86:180">
<ag-virtual-scroll #openScroll [items]="openBrewsView" [height]="segmentScrollHeight" [min-row-height]="isCollapseActive()?86:180">
<brew-information [collapsed]='isCollapseActive()' (brewAction)="brewAction($event[0],$event[1])" *ngFor="let brew of openScroll.items"
[brew]="brew"></brew-information>

Expand Down Expand Up @@ -104,7 +104,7 @@
</div>
</div>

<ag-virtual-scroll #archivedScroll [items]="archiveBrewsView" height="100vh" [min-row-height]="isCollapseActive()?86:180">
<ag-virtual-scroll #archivedScroll [items]="archiveBrewsView" [height]="segmentScrollHeight" [min-row-height]="isCollapseActive()?86:180">
<brew-information [collapsed]='isCollapseActive()' (brewAction)="brewAction($event[0],$event[1])" *ngFor="let brew of archivedScroll.items"
[brew]="brew"></brew-information>

Expand Down
1 change: 1 addition & 0 deletions src/app/brew/brew.page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
.container {
display: flex;
}

}
11 changes: 10 additions & 1 deletion src/app/brew/brew.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class BrewPage implements OnInit {
public archiveBrewsLength: number = 0;

public brew_segment: 'open' | 'archive' = 'open';
public segmentScrollHeight: string = undefined;

@ViewChild('openScroll', { read: AgVirtualSrollComponent, static: false })
public openScroll: AgVirtualSrollComponent;
Expand All @@ -53,6 +54,7 @@ export class BrewPage implements OnInit {

public settings: Settings;
private brewStorageChangeSubscription: Subscription;

constructor(
private readonly modalCtrl: ModalController,
private readonly uiBrewStorage: UIBrewStorage,
Expand Down Expand Up @@ -88,7 +90,7 @@ export class BrewPage implements OnInit {
}

private retriggerScroll() {
setTimeout(async () => {
setTimeout(() => {
const el = this.brewContent.nativeElement;
let scrollComponent: AgVirtualSrollComponent;
if (this.openScroll !== undefined) {
Expand All @@ -99,6 +101,8 @@ export class BrewPage implements OnInit {

scrollComponent.el.style.height =
el.offsetHeight - scrollComponent.el.offsetTop + 'px';

this.segmentScrollHeight = scrollComponent.el.style.height;
}, 150);
}

Expand All @@ -107,6 +111,7 @@ export class BrewPage implements OnInit {
public onOrientationChange(event) {
this.retriggerScroll();
}

public async add() {
await this.uiBrewHelper.addBrew();
this.loadBrews();
Expand Down Expand Up @@ -265,6 +270,7 @@ export class BrewPage implements OnInit {
this.settings.brew_filter.ARCHIVED = this.archivedBrewsFilter;
await this.uiSettingsStorage.saveSettings(this.settings);
}

private async __saveCollapseFilter() {
this.settings.brew_collapsed.OPEN = this.openBrewsCollapsed;
this.settings.brew_collapsed.ARCHIVED = this.archivedBrewsCollapsed;
Expand All @@ -275,6 +281,7 @@ export class BrewPage implements OnInit {
this.__initializeBrewView(this.brew_segment);
this.retriggerScroll();
}

private __initializeBrewView(_type: string): void {
// sort latest to top.
const brewsCopy: Array<Brew> = [...this.brews];
Expand Down Expand Up @@ -393,6 +400,7 @@ export class BrewPage implements OnInit {
this.archiveBrewsView = sortedBrews;
}
}

public ngOnInit() {}

public async ngOnDestroy() {
Expand All @@ -401,6 +409,7 @@ export class BrewPage implements OnInit {
this.brewStorageChangeSubscription = undefined;
}
}

public async longPressAdd(_event) {
_event.target.blur();
_event.cancelBubble = true;
Expand Down

0 comments on commit faaa18f

Please sign in to comment.