Skip to content

Commit

Permalink
fix draggable content height after reinit layout (ushahidi#324)
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryFast authored Jun 14, 2023
1 parent a5e23eb commit 3c32ed2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ export class DraggableLayoutComponent implements AfterViewInit {
}

ngAfterViewInit(): void {
const checkHeight = setInterval(() => {
this.getOffsetHeight();
if (this.fixedContentHeight) clearInterval(checkHeight);
}, 50);

setTimeout(() => {
if (this.mode) {
this.content.scrollToPoint(
Expand All @@ -67,6 +62,13 @@ export class DraggableLayoutComponent implements AfterViewInit {
}, 350);
}

public updateOffsetHeight(): void {
const checkHeight = setInterval(() => {
this.getOffsetHeight();
if (this.fixedContentHeight) clearInterval(checkHeight);
}, 50);
}

private getOffsetHeight(): void {
this.fixedContentHeight = this.fixedContent.nativeElement.offsetHeight;
}
Expand Down
1 change: 1 addition & 0 deletions apps/mobile-mzima-client/src/app/map/map.page.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<app-draggable-layout
#layout
[mode]="1"
[offsetTop]="78"
[breakpoints]="[0, 300]"
Expand Down
6 changes: 6 additions & 0 deletions apps/mobile-mzima-client/src/app/map/map.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import { SessionService } from '@services';
import { MainViewComponent } from './components/main-view.component';
import { MapViewComponent } from './components/map-view/map-view.component';
import { FeedViewComponent } from './components/feed-view/feed-view.component';
import { DraggableLayoutComponent } from './components/draggable-layout/draggable-layout.component';

@Component({
selector: 'app-map',
templateUrl: 'map.page.html',
styleUrls: ['map.page.scss'],
})
export class MapPage extends MainViewComponent {
@ViewChild('layout') public layout: DraggableLayoutComponent;
@ViewChild('map') public map: MapViewComponent;
@ViewChild('feed') public feed: FeedViewComponent;
public mode: number | 'fullscreen';
Expand Down Expand Up @@ -42,4 +44,8 @@ export class MapPage extends MainViewComponent {
public updatePostsCount(data: any): void {
this.totalPosts = data.total;
}

ionViewWillEnter() {
this.layout.updateOffsetHeight();
}
}

0 comments on commit 3c32ed2

Please sign in to comment.