Skip to content

Commit

Permalink
Paginationnumber (#536)
Browse files Browse the repository at this point in the history
* add ngrx and fix the chart and search in token info

* fix pagination nulber
  • Loading branch information
waelhanfi04 authored Sep 19, 2023
1 parent 4d58ed9 commit 8001b81
Showing 1 changed file with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import { Component, ElementRef, HostListener, OnInit, ViewChild } from '@angular/core';
import { ChartOptions, ChartType } from 'chart.js';
import { Router } from '@angular/router';
import { switchMap, take, takeUntil } from 'rxjs/operators';
Expand Down Expand Up @@ -34,8 +34,9 @@ export class CryptoMarketCapComponent implements OnInit {
public chart: any;

maxButtonsPerPage = 15;


currentPageRangeStart = 1;
currentPageRangeEnd: number = this.maxButtonsPerPage;

lineChartOptions: ChartOptions = {
aspectRatio: 2.5,
Expand Down Expand Up @@ -74,6 +75,7 @@ export class CryptoMarketCapComponent implements OnInit {
private ngUnsubscribe = new Subject<void>();
prices: any[] | undefined;
cryptoIds: any[] = [];
currentPageRangeEnd!: number;
constructor(
private router: Router,
private fetchservice: CryptofetchServiceService,
Expand All @@ -86,6 +88,8 @@ export class CryptoMarketCapComponent implements OnInit {
}

ngOnInit(): void {
this.setMaxButtonsPerPage();

this.paginatedCryptoList = [];
this.titleService.setTitle('SaTT-Market Cap');
this.metaService.updateTag({
Expand Down Expand Up @@ -139,6 +143,28 @@ export class CryptoMarketCapComponent implements OnInit {
}



@HostListener('window:resize', ['$event'])
onResize(event: Event): void {
this.setMaxButtonsPerPage();
}

private setMaxButtonsPerPage(): void {
const screenWidth = window.innerWidth;
if (screenWidth <= 530) {
this.maxButtonsPerPage = 5;
} else if (screenWidth <= 768) {
this.maxButtonsPerPage = 10;
} else if (screenWidth <= 992) {
this.maxButtonsPerPage = 15;
} else {
this.maxButtonsPerPage = 20;
}

this.currentPageRangeEnd = this.maxButtonsPerPage;

}

/**
* Split an array into chunks of a specific size.
* @param arr The original array to split.
Expand Down

0 comments on commit 8001b81

Please sign in to comment.