diff --git a/src/app/@core/utils/layout.service.ts b/src/app/@core/utils/layout.service.ts index 6854fd32..046db42f 100644 --- a/src/app/@core/utils/layout.service.ts +++ b/src/app/@core/utils/layout.service.ts @@ -1,20 +1,26 @@ import { Injectable } from '@angular/core'; import { Observable, Subject } from 'rxjs'; -import { delay, share } from 'rxjs/operators'; +import { delay, shareReplay, debounceTime } from 'rxjs/operators'; @Injectable() export class LayoutService { protected layoutSize$ = new Subject(); + protected layoutSizeChange$ = this.layoutSize$.pipe( + shareReplay({ refCount: true }), + ); changeLayoutSize() { this.layoutSize$.next(); } onChangeLayoutSize(): Observable { - return this.layoutSize$.pipe( - share(), - delay(1), + return this.layoutSizeChange$.pipe(delay(1)); + } + + onSafeChangeLayoutSize(): Observable { + return this.layoutSizeChange$.pipe( + debounceTime(350), ); } } diff --git a/src/app/pages/dashboard/electricity/electricity-chart/electricity-chart.component.ts b/src/app/pages/dashboard/electricity/electricity-chart/electricity-chart.component.ts index 1ddca9aa..f8fac76a 100644 --- a/src/app/pages/dashboard/electricity/electricity-chart/electricity-chart.component.ts +++ b/src/app/pages/dashboard/electricity/electricity-chart/electricity-chart.component.ts @@ -27,7 +27,7 @@ export class ElectricityChartComponent implements AfterViewInit, OnDestroy { constructor(private theme: NbThemeService, private layoutService: LayoutService) { - this.layoutService.onChangeLayoutSize() + this.layoutService.onSafeChangeLayoutSize() .pipe( takeWhile(() => this.alive), ) diff --git a/src/app/pages/dashboard/traffic/traffic-chart.component.ts b/src/app/pages/dashboard/traffic/traffic-chart.component.ts index 1a76f560..e4e3e38a 100644 --- a/src/app/pages/dashboard/traffic/traffic-chart.component.ts +++ b/src/app/pages/dashboard/traffic/traffic-chart.component.ts @@ -26,7 +26,7 @@ export class TrafficChartComponent implements AfterViewInit, OnDestroy { constructor(private theme: NbThemeService, private layoutService: LayoutService) { - this.layoutService.onChangeLayoutSize() + this.layoutService.onSafeChangeLayoutSize() .pipe( takeWhile(() => this.alive), ) diff --git a/src/app/pages/e-commerce/charts-panel/charts/orders-chart.component.ts b/src/app/pages/e-commerce/charts-panel/charts/orders-chart.component.ts index 05f41114..99684269 100644 --- a/src/app/pages/e-commerce/charts-panel/charts/orders-chart.component.ts +++ b/src/app/pages/e-commerce/charts-panel/charts/orders-chart.component.ts @@ -35,7 +35,7 @@ export class OrdersChartComponent implements AfterViewInit, OnDestroy, OnChanges constructor(private theme: NbThemeService, private layoutService: LayoutService) { - this.layoutService.onChangeLayoutSize() + this.layoutService.onSafeChangeLayoutSize() .pipe( takeWhile(() => this.alive), ) diff --git a/src/app/pages/e-commerce/charts-panel/charts/profit-chart.component.ts b/src/app/pages/e-commerce/charts-panel/charts/profit-chart.component.ts index 72043229..65cb017f 100644 --- a/src/app/pages/e-commerce/charts-panel/charts/profit-chart.component.ts +++ b/src/app/pages/e-commerce/charts-panel/charts/profit-chart.component.ts @@ -24,7 +24,7 @@ export class ProfitChartComponent implements AfterViewInit, OnDestroy, OnChanges constructor(private theme: NbThemeService, private layoutService: LayoutService) { - this.layoutService.onChangeLayoutSize() + this.layoutService.onSafeChangeLayoutSize() .pipe( takeWhile(() => this.alive), ) diff --git a/src/app/pages/e-commerce/country-orders/chart/country-orders-chart.component.ts b/src/app/pages/e-commerce/country-orders/chart/country-orders-chart.component.ts index c55a7390..826a7fe0 100644 --- a/src/app/pages/e-commerce/country-orders/chart/country-orders-chart.component.ts +++ b/src/app/pages/e-commerce/country-orders/chart/country-orders-chart.component.ts @@ -33,7 +33,7 @@ export class CountryOrdersChartComponent implements AfterViewInit, OnDestroy, On constructor(private theme: NbThemeService, private layoutService: LayoutService) { - this.layoutService.onChangeLayoutSize() + this.layoutService.onSafeChangeLayoutSize() .pipe( takeWhile(() => this.alive), ) diff --git a/src/app/pages/e-commerce/earning-card/front-side/earning-live-update-chart.component.ts b/src/app/pages/e-commerce/earning-card/front-side/earning-live-update-chart.component.ts index 4e9cbd23..0b7c7474 100644 --- a/src/app/pages/e-commerce/earning-card/front-side/earning-live-update-chart.component.ts +++ b/src/app/pages/e-commerce/earning-card/front-side/earning-live-update-chart.component.ts @@ -23,7 +23,7 @@ export class EarningLiveUpdateChartComponent implements AfterViewInit, OnDestroy constructor(private theme: NbThemeService, private layoutService: LayoutService) { - this.layoutService.onChangeLayoutSize() + this.layoutService.onSafeChangeLayoutSize() .pipe( takeWhile(() => this.alive), ) diff --git a/src/app/pages/e-commerce/profit-card/back-side/stats-area-chart.component.ts b/src/app/pages/e-commerce/profit-card/back-side/stats-area-chart.component.ts index 0c30ed47..2f0e9d06 100644 --- a/src/app/pages/e-commerce/profit-card/back-side/stats-area-chart.component.ts +++ b/src/app/pages/e-commerce/profit-card/back-side/stats-area-chart.component.ts @@ -24,7 +24,7 @@ export class StatsAreaChartComponent implements AfterViewInit, OnDestroy { constructor(private theme: NbThemeService, private layoutService: LayoutService) { - this.layoutService.onChangeLayoutSize() + this.layoutService.onSafeChangeLayoutSize() .pipe( takeWhile(() => this.alive), ) diff --git a/src/app/pages/e-commerce/profit-card/front-side/stats-bar-animation-chart.component.ts b/src/app/pages/e-commerce/profit-card/front-side/stats-bar-animation-chart.component.ts index 37820038..339cd160 100644 --- a/src/app/pages/e-commerce/profit-card/front-side/stats-bar-animation-chart.component.ts +++ b/src/app/pages/e-commerce/profit-card/front-side/stats-bar-animation-chart.component.ts @@ -27,7 +27,7 @@ export class StatsBarAnimationChartComponent implements AfterViewInit, OnDestroy constructor(private theme: NbThemeService, private layoutService: LayoutService) { - this.layoutService.onChangeLayoutSize() + this.layoutService.onSafeChangeLayoutSize() .pipe( takeWhile(() => this.alive), ) diff --git a/src/app/pages/e-commerce/profit-card/profit-card.component.scss b/src/app/pages/e-commerce/profit-card/profit-card.component.scss index ed0bf32c..70121041 100644 --- a/src/app/pages/e-commerce/profit-card/profit-card.component.scss +++ b/src/app/pages/e-commerce/profit-card/profit-card.component.scss @@ -10,16 +10,22 @@ cursor: pointer; } - ::ng-deep .flipped { - .back-container { - .flip-icon { - transform: scaleX(-1); - } + ::ng-deep { + .front-container { + max-width: 100%; } - .front-container { - .flip-icon { - display: none; + .flipped { + .back-container { + .flip-icon { + transform: scaleX(-1); + } + } + + .front-container { + .flip-icon { + display: none; + } } } } diff --git a/src/app/pages/e-commerce/traffic-reveal-card/back-side/traffic-bar-chart.component.ts b/src/app/pages/e-commerce/traffic-reveal-card/back-side/traffic-bar-chart.component.ts index a1e1ddc5..f2a55b7f 100644 --- a/src/app/pages/e-commerce/traffic-reveal-card/back-side/traffic-bar-chart.component.ts +++ b/src/app/pages/e-commerce/traffic-reveal-card/back-side/traffic-bar-chart.component.ts @@ -28,7 +28,7 @@ export class TrafficBarChartComponent implements AfterViewInit, OnDestroy, OnCha constructor(private theme: NbThemeService, private layoutService: LayoutService) { - this.layoutService.onChangeLayoutSize() + this.layoutService.onSafeChangeLayoutSize() .pipe( takeWhile(() => this.alive), ) diff --git a/src/app/pages/e-commerce/visitors-analytics/visitors-analytics-chart/visitors-analytics-chart.component.ts b/src/app/pages/e-commerce/visitors-analytics/visitors-analytics-chart/visitors-analytics-chart.component.ts index ae59bc99..dd3c74ec 100644 --- a/src/app/pages/e-commerce/visitors-analytics/visitors-analytics-chart/visitors-analytics-chart.component.ts +++ b/src/app/pages/e-commerce/visitors-analytics/visitors-analytics-chart/visitors-analytics-chart.component.ts @@ -31,7 +31,7 @@ export class ECommerceVisitorsAnalyticsChartComponent implements AfterViewInit, constructor(private theme: NbThemeService, private layoutService: LayoutService) { - this.layoutService.onChangeLayoutSize() + this.layoutService.onSafeChangeLayoutSize() .pipe( takeWhile(() => this.alive), ) diff --git a/src/app/pages/e-commerce/visitors-analytics/visitors-statistics/visitors-statistics.component.ts b/src/app/pages/e-commerce/visitors-analytics/visitors-statistics/visitors-statistics.component.ts index 0b046380..3ba87388 100644 --- a/src/app/pages/e-commerce/visitors-analytics/visitors-statistics/visitors-statistics.component.ts +++ b/src/app/pages/e-commerce/visitors-analytics/visitors-statistics/visitors-statistics.component.ts @@ -21,7 +21,7 @@ export class ECommerceVisitorsStatisticsComponent implements AfterViewInit, OnDe constructor(private theme: NbThemeService, private layoutService: LayoutService) { - this.layoutService.onChangeLayoutSize() + this.layoutService.onSafeChangeLayoutSize() .pipe( takeWhile(() => this.alive), )