mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-22 17:42:57 +00:00
fix: news module not scrollable on large screens
This commit is contained in:
committed by
Rainer Killinger
parent
f349bd7233
commit
44b6a4aea0
@@ -48,11 +48,21 @@ export class NewsPageComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
news: SCMessage[] = [];
|
news: SCMessage[] = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Minimum page size of queries
|
||||||
|
*/
|
||||||
|
minPageSize = 10;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page size of queries
|
* Page size of queries
|
||||||
*/
|
*/
|
||||||
pageSize = 10;
|
pageSize = 10;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Element size in px
|
||||||
|
*/
|
||||||
|
elementSize = [300, 300];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Relevant settings
|
* Relevant settings
|
||||||
*/
|
*/
|
||||||
@@ -72,8 +82,8 @@ export class NewsPageComponent implements OnInit {
|
|||||||
* Fetch news from the backend
|
* Fetch news from the backend
|
||||||
*/
|
*/
|
||||||
async fetchNews() {
|
async fetchNews() {
|
||||||
this.from = 0;
|
this.from = this.pageSize;
|
||||||
this.news = await this.newsProvider.getList(this.pageSize, this.from, [
|
this.news = await this.newsProvider.getList(this.pageSize, 0, [
|
||||||
...this.filters,
|
...this.filters,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -82,20 +92,32 @@ export class NewsPageComponent implements OnInit {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads more news
|
* Loads more news
|
||||||
*
|
|
||||||
* @param infiniteScrollElement Infinite scroll element
|
|
||||||
*/
|
*/
|
||||||
async loadMore(
|
async loadMore(
|
||||||
infiniteScrollElement: HTMLIonInfiniteScrollElement,
|
infiniteScrollElement?: HTMLIonInfiniteScrollElement,
|
||||||
|
more = this.pageSize,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
this.from += this.pageSize;
|
const from = this.from;
|
||||||
this.news = [
|
this.from += more;
|
||||||
...this.news,
|
const fetchedNews = await this.newsProvider.getList(this.pageSize, from, [
|
||||||
...(await this.newsProvider.getList(this.pageSize, this.from, [
|
...this.filters,
|
||||||
...this.filters,
|
]);
|
||||||
])),
|
|
||||||
];
|
this.news = [...this.news, ...fetchedNews];
|
||||||
await infiniteScrollElement.complete();
|
await infiniteScrollElement?.complete();
|
||||||
|
}
|
||||||
|
|
||||||
|
calcPageSize(entry: ResizeObserverEntry) {
|
||||||
|
this.pageSize = Math.max(
|
||||||
|
this.minPageSize,
|
||||||
|
Math.floor(entry.contentRect.width / this.elementSize[0]) *
|
||||||
|
Math.ceil(entry.contentRect.height / this.elementSize[1] + 0.25),
|
||||||
|
);
|
||||||
|
if (!this.from || this.from === 0) return;
|
||||||
|
const more = Math.max(0, this.pageSize - this.from);
|
||||||
|
if (more !== 0) {
|
||||||
|
void this.loadMore(undefined, Math.max(more, this.minPageSize));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -22,7 +22,10 @@
|
|||||||
</ion-toolbar>
|
</ion-toolbar>
|
||||||
</ion-header>
|
</ion-header>
|
||||||
|
|
||||||
<ion-content class="ion-content-parallax">
|
<ion-content
|
||||||
|
class="ion-content-parallax"
|
||||||
|
(elementSizeChange)="calcPageSize($event)"
|
||||||
|
>
|
||||||
<div>
|
<div>
|
||||||
<ion-refresher slot="fixed" (ionRefresh)="refresh($event.target)">
|
<ion-refresher slot="fixed" (ionRefresh)="refresh($event.target)">
|
||||||
<ion-refresher-content
|
<ion-refresher-content
|
||||||
|
|||||||
@@ -20,10 +20,6 @@
|
|||||||
margin: var(--spacing-sm);
|
margin: var(--spacing-sm);
|
||||||
@include auto-grid(300px);
|
@include auto-grid(300px);
|
||||||
|
|
||||||
// force scrolling & infinite scroll
|
|
||||||
// fill in on large screens
|
|
||||||
min-height: 101%;
|
|
||||||
|
|
||||||
> * {
|
> * {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user