1
- import { Component , OnInit } from '@angular/core' ;
1
+ import { Component , OnInit , AfterViewInit } from '@angular/core' ;
2
+ declare const $ : any ;
2
3
3
4
@Component ( {
4
5
selector : 'app-wizard' ,
5
6
templateUrl : './wizard.component.html' ,
6
7
styleUrls : [ './wizard.component.css' ]
7
8
} )
8
- export class WizardComponent implements OnInit {
9
+ export class WizardComponent implements OnInit , AfterViewInit {
9
10
tabIndex = 0 ;
10
11
constructor ( ) { }
11
12
12
13
ngOnInit ( ) {
14
+ }
15
+ ngAfterViewInit ( ) {
13
16
const preBtn = < HTMLElement > document . getElementById ( 'preBtn' ) ;
17
+ const moveTab = < HTMLElement > document . querySelector ( '.move-tab' ) ;
14
18
preBtn . style . visibility = 'hidden' ;
19
+ // to ensure moveTab can stay correct position
20
+ $ ( window ) . resize ( ( ) => {
21
+ const screenWidth = document . body . clientWidth ;
22
+ if ( screenWidth > 990 ) {
23
+ if ( this . tabIndex === 1 ) {
24
+ moveTab . style . left = '20vw' ;
25
+ console . log ( '111' ) ;
26
+ } else if ( this . tabIndex === 2 ) {
27
+ moveTab . style . left = '41vw' ;
28
+ }
29
+ } else {
30
+ if ( this . tabIndex === 1 ) {
31
+ moveTab . style . left = '30vw' ;
32
+ } else if ( this . tabIndex === 2 ) {
33
+ moveTab . style . left = '61.5vw' ;
34
+ }
35
+ }
36
+ } ) ;
15
37
}
16
38
17
39
preOnClick ( ) {
18
40
const moveTab = < HTMLElement > document . querySelector ( '.move-tab' ) ;
19
41
const nextBtn = < HTMLElement > document . getElementById ( 'nextBtn' ) ;
20
42
const preBtn = < HTMLElement > document . getElementById ( 'preBtn' ) ;
43
+ const screenWidth = document . body . clientWidth ;
21
44
if ( this . tabIndex === 2 ) {
22
45
this . tabIndex -- ;
23
- moveTab . style . left = '20vw' ;
46
+ moveTab . style . left = screenWidth > 990 ? '20vw' : '30vw ';
24
47
nextBtn . style . visibility = 'visible' ;
25
48
moveTab . innerHTML = 'Account' ;
26
49
} else if ( this . tabIndex === 1 ) {
@@ -35,14 +58,15 @@ export class WizardComponent implements OnInit {
35
58
const moveTab = < HTMLElement > document . querySelector ( '.move-tab' ) ;
36
59
const nextBtn = < HTMLElement > document . getElementById ( 'nextBtn' ) ;
37
60
const preBtn = < HTMLElement > document . getElementById ( 'preBtn' ) ;
61
+ const screenWidth = document . body . clientWidth ;
38
62
if ( this . tabIndex === 0 ) {
39
63
this . tabIndex ++ ;
40
- moveTab . style . left = '20vw' ;
64
+ moveTab . style . left = screenWidth > 990 ? '20vw' : '30vw ';
41
65
preBtn . style . visibility = 'visible' ;
42
66
moveTab . innerHTML = 'Account' ;
43
67
} else if ( this . tabIndex === 1 ) {
44
68
this . tabIndex ++ ;
45
- moveTab . style . left = '41vw' ;
69
+ moveTab . style . left = screenWidth > 990 ? '41vw' : '61.5vw ';
46
70
nextBtn . style . visibility = 'hidden' ;
47
71
moveTab . innerHTML = 'Address' ;
48
72
}
0 commit comments