@@ -10,7 +10,7 @@ import { BrowserService } from '../../services/browser.service'
1010export class ProgressComponent implements OnInit , AfterViewInit {
1111 public constructor (
1212 private readonly router : Router ,
13- private readonly browserService : BrowserService
13+ private browserService : BrowserService
1414 ) { }
1515
1616 public ngOnInit ( ) {
@@ -29,10 +29,9 @@ export class ProgressComponent implements OnInit, AfterViewInit {
2929 }
3030
3131 private startProgress ( ) {
32- if ( ! this . browserService . isBrowser ) return
33-
34- const progressBar = document . getElementById ( 'progress-bar' )
35- if ( progressBar ) {
32+ this . browserService . on ( ( ) => {
33+ const progressBar = document . getElementById ( 'progress-bar' )
34+ if ( ! progressBar ) return
3635 progressBar . style . transition = 'none'
3736 progressBar . style . width = '90%'
3837 setTimeout ( ( ) => {
@@ -43,14 +42,13 @@ export class ProgressComponent implements OnInit, AfterViewInit {
4342 setTimeout ( ( ) => {
4443 progressBar . style . width = '0%'
4544 } , 500 )
46- }
45+ } )
4746 }
4847
4948 private endProgress ( ) {
50- if ( ! this . browserService . isBrowser ) return
51-
52- const progressBar = window . document . getElementById ( 'progress-bar' )
53- if ( progressBar ) {
49+ this . browserService . on ( ( ) => {
50+ const progressBar = document . getElementById ( 'progress-bar' )
51+ if ( ! progressBar ) return
5452 progressBar . style . width = '0%'
5553 setTimeout ( ( ) => {
5654 progressBar . style . width = '100%'
@@ -59,21 +57,21 @@ export class ProgressComponent implements OnInit, AfterViewInit {
5957 progressBar . style . transition = ''
6058 progressBar . style . width = '0%'
6159 } , 1100 )
62- }
60+ } )
6361 }
6462
6563 private initProgress ( ) {
66- if ( ! this . browserService . isBrowser ) return
67-
68- const progressBar = document . createElement ( 'div' )
69- progressBar . id = 'progress-bar '
70- progressBar . style . position = 'fixed '
71- progressBar . style . top = '0'
72- progressBar . style . left = '0 '
73- progressBar . style . height = '4px '
74- progressBar . style . backgroundColor = 'var(--primary- 100) '
75- progressBar . style . width = '100% '
76- progressBar . style . zIndex = '9999'
77- document . body . appendChild ( progressBar )
64+ this . browserService . on ( ( ) => {
65+ const progressBar = document . createElement ( 'div' )
66+ progressBar . id = 'progress-bar'
67+ progressBar . style . position = 'fixed '
68+ progressBar . style . top = '0 '
69+ progressBar . style . left = '0'
70+ progressBar . style . height = '4px '
71+ progressBar . style . backgroundColor = 'var(--primary-100) '
72+ progressBar . style . width = '100% '
73+ progressBar . style . zIndex = '9999 '
74+ document . body . appendChild ( progressBar )
75+ } )
7876 }
7977}
0 commit comments