Skip to content

Commit 12b035f

Browse files
committed
fix:<Linked list> linked list option selection scrolling page
1 parent b4fd7ac commit 12b035f

File tree

3 files changed

+29
-55
lines changed

3 files changed

+29
-55
lines changed

src/app/components/NonprimitiveData/linear/linear-routing.module.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,6 @@ const routes: Routes = [
2626
},
2727
{
2828
path: 'linked-list', component: LinkedListComponent,
29-
children:[
30-
{
31-
path: '', redirectTo:'single-linked-list', pathMatch:'full',
32-
},
33-
{
34-
path: 'single-linked-list', component: SingleLinkedListComponent
35-
},
36-
{
37-
path: 'double-linked-list', component: DoubleLinkedListComponent
38-
},
39-
{
40-
path: 'circular-linked-list', component: CircularLinkedListComponent
41-
}
42-
]
4329
}
4430
];
4531

src/app/components/NonprimitiveData/linear/linked-list/linked-list.component.html

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,30 @@ <h1 class="text-center">Linked List</h1>
77

88

99
<div class="d-flex mt-lg-5 mt-4 horizontal-scroll">
10-
<div class="box p-lg-2 p-1 px-lg-3 px-2 btn me-lg-4 me-3 mb-2 linkedType" (click)="selectionOfType(0)">
10+
<div [class]="step === 0 ?'box box-active p-lg-2 p-1 px-lg-3 px-2 tab me-lg-4 me-3 mb-2':'box p-lg-2 p-1 px-lg-3 px-2 tab me-lg-4 me-3 mb-2'"
11+
(click)="selectionOfType(0)">
1112
<p class="m-0">Single Linked List</p>
1213
</div>
13-
<div class="box p-lg-2 p-1 px-lg-3 px-2 btn me-lg-4 me-3 mb-2 linkedType" (click)="selectionOfType(1)">
14+
<div [class]="step === 1 ?'box box-active p-lg-2 p-1 px-lg-3 px-2 tab me-lg-4 me-3 mb-2':'box p-lg-2 p-1 px-lg-3 px-2 tab me-lg-4 me-3 mb-2'"
15+
(click)="selectionOfType(1)">
1416
<p class="m-0">Double Linked List</p>
1517
</div>
16-
<div class="box p-lg-2 p-1 px-lg-3 px-2 btn me-lg-4 me-3 mb-2 linkedType" (click)="selectionOfType(2)">
18+
<div [class]="step === 2 ?'box box-active p-lg-2 p-1 px-lg-3 px-2 tab me-lg-4 me-3 mb-2':'box p-lg-2 p-1 px-lg-3 px-2 tab me-lg-4 me-3 mb-2'"
19+
(click)="selectionOfType(2)">
1720
<p class="m-0">Circular Linked List</p>
1821
</div>
1922
</div>
2023
<div class="mt-3">
21-
<router-outlet></router-outlet>
24+
<ng-container *ngIf="step === 0">
25+
<app-single-linked-list></app-single-linked-list>
26+
</ng-container>
27+
<ng-container *ngIf="step === 1">
28+
<app-double-linked-list></app-double-linked-list>
29+
</ng-container>
30+
<ng-container *ngIf="step === 2">
31+
<app-circular-linked-list></app-circular-linked-list>
32+
</ng-container>
2233
</div>
2334
<div class="mt-md-4 mt-3" [innerHtml]="linkedListMetaData.applications"></div>
2435
<div class="mt-md-4 mt-3" [innerHtml]="linkedListMetaData.advantage"></div>
25-
<div class="mt-md-4 mt-3" [innerHtml]="linkedListMetaData.disadvantage"></div>
36+
<div class="mt-md-4 mt-3" [innerHtml]="linkedListMetaData.disadvantage"></div>
Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AfterViewInit, Component, ElementRef, OnInit } from '@angular/core';
1+
import { Component, ElementRef, OnInit } from '@angular/core';
22
import { ActivatedRoute, Router } from '@angular/router';
33
import { linkedListMetaData } from 'src/app/core/data-structures/linear/linked-list/linked-list-meta-data';
44

@@ -7,7 +7,7 @@ import { linkedListMetaData } from 'src/app/core/data-structures/linear/linked-l
77
templateUrl: './linked-list.component.html',
88
styleUrls: ['./linked-list.component.css']
99
})
10-
export class LinkedListComponent implements OnInit, AfterViewInit{
10+
export class LinkedListComponent implements OnInit{
1111

1212
linkedListMetaData = linkedListMetaData;
1313
step = 0;
@@ -24,43 +24,20 @@ export class LinkedListComponent implements OnInit, AfterViewInit{
2424
}
2525
});
2626
}
27-
28-
ngAfterViewInit(): void {
29-
this.selectionOfType(this.step);
30-
}
31-
32-
3327
selectionOfType(index: number): void {
34-
const typeRef = this.elRef.nativeElement.querySelectorAll('.linkedType');
35-
for (let i = 0; i < typeRef.length; i++){
36-
if(i === index){
37-
typeRef[i].className = 'box box-active p-lg-2 p-1 px-lg-3 px-2 btn me-lg-4 me-3 mb-2 linkedType';
38-
this.selectType(i);
39-
}else{
40-
typeRef[i].className = 'box p-lg-2 p-1 px-lg-3 px-2 btn me-lg-4 me-3 mb-2 linkedType';
41-
}
42-
}
28+
this.step = index;
29+
// const typeRef = this.elRef.nativeElement.querySelectorAll('.linkedType');
30+
// for (let i = 0; i < typeRef.length; i++){
31+
// if(i === index){
32+
// typeRef[i].className = 'box box-active p-lg-2 p-1 px-lg-3 px-2 btn me-lg-4 me-3 mb-2 linkedType';
33+
// this.selectType(i);
34+
// }else{
35+
// typeRef[i].className = 'box p-lg-2 p-1 px-lg-3 px-2 btn me-lg-4 me-3 mb-2 linkedType';
36+
// }
37+
// }
4338
}
4439

45-
selectType(index: number){
46-
switch(index){
47-
case 0:{
48-
this.router.navigate(['/non-primitive/linear/linked-list/single-linked-list'],
49-
{queryParams:{step:0}});
50-
break;
51-
}
52-
case 1:{
53-
this.router.navigate(['/non-primitive/linear/linked-list/double-linked-list'],
54-
{queryParams:{step:1}});
55-
break;
56-
}
57-
case 2:{
58-
this.router.navigate(['/non-primitive/linear/linked-list/circular-linked-list'],
59-
{queryParams:{step:2}});
60-
break;
61-
}
62-
}
63-
}
40+
6441

6542
}
6643

0 commit comments

Comments
 (0)