Skip to content

Commit 2223dc3

Browse files
author
Di Wang
committed
width of move tab detected by screen width
1 parent bdd5b88 commit 2223dc3

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

src/app/dashboard/component/wizard/wizard.component.ts

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,49 @@
1-
import { Component, OnInit } from '@angular/core';
1+
import { Component, OnInit, AfterViewInit } from '@angular/core';
2+
declare const $: any;
23

34
@Component({
45
selector: 'app-wizard',
56
templateUrl: './wizard.component.html',
67
styleUrls: ['./wizard.component.css']
78
})
8-
export class WizardComponent implements OnInit {
9+
export class WizardComponent implements OnInit, AfterViewInit {
910
tabIndex = 0;
1011
constructor() { }
1112

1213
ngOnInit() {
14+
}
15+
ngAfterViewInit() {
1316
const preBtn = <HTMLElement>document.getElementById('preBtn');
17+
const moveTab = <HTMLElement>document.querySelector('.move-tab');
1418
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+
});
1537
}
1638

1739
preOnClick() {
1840
const moveTab = <HTMLElement>document.querySelector('.move-tab');
1941
const nextBtn = <HTMLElement>document.getElementById('nextBtn');
2042
const preBtn = <HTMLElement>document.getElementById('preBtn');
43+
const screenWidth = document.body.clientWidth;
2144
if (this.tabIndex === 2) {
2245
this.tabIndex--;
23-
moveTab.style.left = '20vw';
46+
moveTab.style.left = screenWidth > 990 ? '20vw' : '30vw';
2447
nextBtn.style.visibility = 'visible';
2548
moveTab.innerHTML = 'Account';
2649
}else if (this.tabIndex === 1) {
@@ -35,14 +58,15 @@ export class WizardComponent implements OnInit {
3558
const moveTab = <HTMLElement>document.querySelector('.move-tab');
3659
const nextBtn = <HTMLElement>document.getElementById('nextBtn');
3760
const preBtn = <HTMLElement>document.getElementById('preBtn');
61+
const screenWidth = document.body.clientWidth;
3862
if (this.tabIndex === 0) {
3963
this.tabIndex++;
40-
moveTab.style.left = '20vw';
64+
moveTab.style.left = screenWidth > 990 ? '20vw' : '30vw';
4165
preBtn.style.visibility = 'visible';
4266
moveTab.innerHTML = 'Account';
4367
}else if (this.tabIndex === 1) {
4468
this.tabIndex++;
45-
moveTab.style.left = '41vw';
69+
moveTab.style.left = screenWidth > 990 ? '41vw' : '61.5vw';
4670
nextBtn.style.visibility = 'hidden';
4771
moveTab.innerHTML = 'Address';
4872
}

0 commit comments

Comments
 (0)