Skip to content

Commit b216066

Browse files
committed
Revert unnecessary complexity
1 parent 58fff88 commit b216066

2 files changed

Lines changed: 1 addition & 103 deletions

File tree

src/app/component/activity-description/activity-description.component.html

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ <h1>
1717
</button>
1818
</div>
1919

20-
<div class="example-action-buttons">
21-
<button mat-raised-button (click)="openAll()">Expand All</button>
22-
<button mat-raised-button (click)="closeAll()">Collapse All</button>
23-
</div>
24-
2520
<mat-accordion multi="true">
2621
<mat-expansion-panel [expanded]="false">
2722
<mat-expansion-panel-header>

src/app/component/activity-description/activity-description.component.ts

Lines changed: 1 addition & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
Output,
99
EventEmitter,
1010
OnInit,
11-
OnDestroy,
1211
HostListener,
1312
} from '@angular/core';
1413
import { MatAccordion } from '@angular/material/expansion';
@@ -20,16 +19,12 @@ import { LoaderService } from '../../service/loader/data-loader.service';
2019
templateUrl: './activity-description.component.html',
2120
styleUrls: ['./activity-description.component.css'],
2221
})
23-
export class ActivityDescriptionComponent implements OnInit, OnChanges, OnDestroy {
22+
export class ActivityDescriptionComponent implements OnInit, OnChanges {
2423
@Input() activity: Activity | null = null;
2524
@Input() showCloseButton: boolean = false;
2625
@Output() activityClicked = new EventEmitter<string>();
2726
@Output() closeRequested = new EventEmitter<void>();
2827

29-
remSize: number = parseFloat(getComputedStyle(document.documentElement).fontSize);
30-
private resizeObserver?: ResizeObserver;
31-
private mutationObserver?: MutationObserver;
32-
private lastWidth: number = 0;
3328

3429
currentActivity: Partial<Activity> = {};
3530
TimeLabel: string = '';
@@ -54,20 +49,6 @@ export class ActivityDescriptionComponent implements OnInit, OnChanges, OnDestro
5449
// Check initial screen size
5550
this.checkWidthForActivityPanel();
5651
// Set up observers to watch for layout changes
57-
this.setupResizeObserver();
58-
this.setupMutationObserver();
59-
// Set up interval to periodically check width changes
60-
this.setupPeriodicCheck();
61-
}
62-
63-
ngOnDestroy() {
64-
// Cleanup observers
65-
if (this.resizeObserver) {
66-
this.resizeObserver.disconnect();
67-
}
68-
if (this.mutationObserver) {
69-
this.mutationObserver.disconnect();
70-
}
7152
}
7253

7354
@HostListener('window:resize', ['$event'])
@@ -106,20 +87,6 @@ export class ActivityDescriptionComponent implements OnInit, OnChanges, OnDestro
10687
this.closeRequested.emit();
10788
}
10889

109-
// Expand all function
110-
openAll(): void {
111-
this.accordion.forEach(element => {
112-
element.openAll();
113-
});
114-
}
115-
116-
// Close all function
117-
closeAll(): void {
118-
this.accordion.forEach(element => {
119-
element.closeAll();
120-
});
121-
}
122-
12390
// Check if screen is narrow and update property
12491
private checkWidthForActivityPanel(): void {
12592
let elemtn: HTMLElement | null = document.querySelector('app-activity-description');
@@ -129,69 +96,5 @@ export class ActivityDescriptionComponent implements OnInit, OnChanges, OnDestro
12996
const wasNarrow = this.isNarrowScreen;
13097
this.isNarrowScreen = currentWidth < 500;
13198

132-
// Only log if width actually changed
133-
if (currentWidth !== this.lastWidth || wasNarrow !== this.isNarrowScreen) {
134-
console.log(
135-
`ActivityDescriptionComponent: isNarrowScreen = ${this.isNarrowScreen} ${currentWidth}px (was ${this.lastWidth}px)`
136-
);
137-
this.lastWidth = currentWidth;
138-
}
139-
}
140-
141-
// Set up ResizeObserver to watch for component width changes
142-
private setupResizeObserver(): void {
143-
if (typeof ResizeObserver !== 'undefined') {
144-
this.resizeObserver = new ResizeObserver(entries => {
145-
// Debounce the resize check to avoid excessive calls
146-
setTimeout(() => {
147-
this.checkWidthForActivityPanel();
148-
}, 100);
149-
});
150-
151-
// Start observing the component element
152-
const element = document.querySelector('app-activity-description');
153-
if (element) {
154-
this.resizeObserver.observe(element);
155-
}
156-
}
157-
}
158-
159-
// Set up MutationObserver to watch for DOM changes that might affect layout
160-
private setupMutationObserver(): void {
161-
this.mutationObserver = new MutationObserver(mutations => {
162-
let shouldCheck = false;
163-
mutations.forEach(mutation => {
164-
// Check if any class changes might affect layout (like menu open/close)
165-
if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
166-
shouldCheck = true;
167-
}
168-
// Check if any child elements were added/removed that might affect layout
169-
if (mutation.type === 'childList') {
170-
shouldCheck = true;
171-
}
172-
});
173-
174-
if (shouldCheck) {
175-
setTimeout(() => {
176-
this.checkWidthForActivityPanel();
177-
}, 150); // Slightly longer delay for DOM changes
178-
}
179-
});
180-
181-
// Observe the document body for class changes (like menu states)
182-
this.mutationObserver.observe(document.body, {
183-
attributes: true,
184-
attributeFilter: ['class'],
185-
childList: true,
186-
subtree: true,
187-
});
188-
}
189-
190-
// Set up periodic check as fallback
191-
private setupPeriodicCheck(): void {
192-
// Check width every 500ms as a fallback for missed events
193-
setInterval(() => {
194-
this.checkWidthForActivityPanel();
195-
}, 500);
19699
}
197100
}

0 commit comments

Comments
 (0)