mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-16 23:40:14 +01:00
fix(sidebar): toggle performance issues (#5658)
* refactor: improve observable layout change sharing * feat: add safe delayed event of layout change * fix: replace change layout with safe change * fix: limit front card width to prevent map overflow before repaint
This commit is contained in:
parent
5cc4c19cee
commit
9eaf0bb005
13 changed files with 35 additions and 23 deletions
|
|
@ -1,20 +1,26 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Observable, Subject } from 'rxjs';
|
import { Observable, Subject } from 'rxjs';
|
||||||
import { delay, share } from 'rxjs/operators';
|
import { delay, shareReplay, debounceTime } from 'rxjs/operators';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class LayoutService {
|
export class LayoutService {
|
||||||
|
|
||||||
protected layoutSize$ = new Subject();
|
protected layoutSize$ = new Subject();
|
||||||
|
protected layoutSizeChange$ = this.layoutSize$.pipe(
|
||||||
|
shareReplay({ refCount: true }),
|
||||||
|
);
|
||||||
|
|
||||||
changeLayoutSize() {
|
changeLayoutSize() {
|
||||||
this.layoutSize$.next();
|
this.layoutSize$.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
onChangeLayoutSize(): Observable<any> {
|
onChangeLayoutSize(): Observable<any> {
|
||||||
return this.layoutSize$.pipe(
|
return this.layoutSizeChange$.pipe(delay(1));
|
||||||
share(),
|
}
|
||||||
delay(1),
|
|
||||||
|
onSafeChangeLayoutSize(): Observable<any> {
|
||||||
|
return this.layoutSizeChange$.pipe(
|
||||||
|
debounceTime(350),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ export class ElectricityChartComponent implements AfterViewInit, OnDestroy {
|
||||||
|
|
||||||
constructor(private theme: NbThemeService,
|
constructor(private theme: NbThemeService,
|
||||||
private layoutService: LayoutService) {
|
private layoutService: LayoutService) {
|
||||||
this.layoutService.onChangeLayoutSize()
|
this.layoutService.onSafeChangeLayoutSize()
|
||||||
.pipe(
|
.pipe(
|
||||||
takeWhile(() => this.alive),
|
takeWhile(() => this.alive),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ export class TrafficChartComponent implements AfterViewInit, OnDestroy {
|
||||||
|
|
||||||
constructor(private theme: NbThemeService,
|
constructor(private theme: NbThemeService,
|
||||||
private layoutService: LayoutService) {
|
private layoutService: LayoutService) {
|
||||||
this.layoutService.onChangeLayoutSize()
|
this.layoutService.onSafeChangeLayoutSize()
|
||||||
.pipe(
|
.pipe(
|
||||||
takeWhile(() => this.alive),
|
takeWhile(() => this.alive),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ export class OrdersChartComponent implements AfterViewInit, OnDestroy, OnChanges
|
||||||
|
|
||||||
constructor(private theme: NbThemeService,
|
constructor(private theme: NbThemeService,
|
||||||
private layoutService: LayoutService) {
|
private layoutService: LayoutService) {
|
||||||
this.layoutService.onChangeLayoutSize()
|
this.layoutService.onSafeChangeLayoutSize()
|
||||||
.pipe(
|
.pipe(
|
||||||
takeWhile(() => this.alive),
|
takeWhile(() => this.alive),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ export class ProfitChartComponent implements AfterViewInit, OnDestroy, OnChanges
|
||||||
|
|
||||||
constructor(private theme: NbThemeService,
|
constructor(private theme: NbThemeService,
|
||||||
private layoutService: LayoutService) {
|
private layoutService: LayoutService) {
|
||||||
this.layoutService.onChangeLayoutSize()
|
this.layoutService.onSafeChangeLayoutSize()
|
||||||
.pipe(
|
.pipe(
|
||||||
takeWhile(() => this.alive),
|
takeWhile(() => this.alive),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ export class CountryOrdersChartComponent implements AfterViewInit, OnDestroy, On
|
||||||
|
|
||||||
constructor(private theme: NbThemeService,
|
constructor(private theme: NbThemeService,
|
||||||
private layoutService: LayoutService) {
|
private layoutService: LayoutService) {
|
||||||
this.layoutService.onChangeLayoutSize()
|
this.layoutService.onSafeChangeLayoutSize()
|
||||||
.pipe(
|
.pipe(
|
||||||
takeWhile(() => this.alive),
|
takeWhile(() => this.alive),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ export class EarningLiveUpdateChartComponent implements AfterViewInit, OnDestroy
|
||||||
|
|
||||||
constructor(private theme: NbThemeService,
|
constructor(private theme: NbThemeService,
|
||||||
private layoutService: LayoutService) {
|
private layoutService: LayoutService) {
|
||||||
this.layoutService.onChangeLayoutSize()
|
this.layoutService.onSafeChangeLayoutSize()
|
||||||
.pipe(
|
.pipe(
|
||||||
takeWhile(() => this.alive),
|
takeWhile(() => this.alive),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ export class StatsAreaChartComponent implements AfterViewInit, OnDestroy {
|
||||||
|
|
||||||
constructor(private theme: NbThemeService,
|
constructor(private theme: NbThemeService,
|
||||||
private layoutService: LayoutService) {
|
private layoutService: LayoutService) {
|
||||||
this.layoutService.onChangeLayoutSize()
|
this.layoutService.onSafeChangeLayoutSize()
|
||||||
.pipe(
|
.pipe(
|
||||||
takeWhile(() => this.alive),
|
takeWhile(() => this.alive),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ export class StatsBarAnimationChartComponent implements AfterViewInit, OnDestroy
|
||||||
|
|
||||||
constructor(private theme: NbThemeService,
|
constructor(private theme: NbThemeService,
|
||||||
private layoutService: LayoutService) {
|
private layoutService: LayoutService) {
|
||||||
this.layoutService.onChangeLayoutSize()
|
this.layoutService.onSafeChangeLayoutSize()
|
||||||
.pipe(
|
.pipe(
|
||||||
takeWhile(() => this.alive),
|
takeWhile(() => this.alive),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -10,16 +10,22 @@
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
::ng-deep .flipped {
|
::ng-deep {
|
||||||
.back-container {
|
.front-container {
|
||||||
.flip-icon {
|
max-width: 100%;
|
||||||
transform: scaleX(-1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.front-container {
|
.flipped {
|
||||||
.flip-icon {
|
.back-container {
|
||||||
display: none;
|
.flip-icon {
|
||||||
|
transform: scaleX(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.front-container {
|
||||||
|
.flip-icon {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ export class TrafficBarChartComponent implements AfterViewInit, OnDestroy, OnCha
|
||||||
|
|
||||||
constructor(private theme: NbThemeService,
|
constructor(private theme: NbThemeService,
|
||||||
private layoutService: LayoutService) {
|
private layoutService: LayoutService) {
|
||||||
this.layoutService.onChangeLayoutSize()
|
this.layoutService.onSafeChangeLayoutSize()
|
||||||
.pipe(
|
.pipe(
|
||||||
takeWhile(() => this.alive),
|
takeWhile(() => this.alive),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ export class ECommerceVisitorsAnalyticsChartComponent implements AfterViewInit,
|
||||||
|
|
||||||
constructor(private theme: NbThemeService,
|
constructor(private theme: NbThemeService,
|
||||||
private layoutService: LayoutService) {
|
private layoutService: LayoutService) {
|
||||||
this.layoutService.onChangeLayoutSize()
|
this.layoutService.onSafeChangeLayoutSize()
|
||||||
.pipe(
|
.pipe(
|
||||||
takeWhile(() => this.alive),
|
takeWhile(() => this.alive),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ export class ECommerceVisitorsStatisticsComponent implements AfterViewInit, OnDe
|
||||||
|
|
||||||
constructor(private theme: NbThemeService,
|
constructor(private theme: NbThemeService,
|
||||||
private layoutService: LayoutService) {
|
private layoutService: LayoutService) {
|
||||||
this.layoutService.onChangeLayoutSize()
|
this.layoutService.onSafeChangeLayoutSize()
|
||||||
.pipe(
|
.pipe(
|
||||||
takeWhile(() => this.alive),
|
takeWhile(() => this.alive),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue