Skip to content

Commit 28cc753

Browse files
committed
added missing observer disconnect onDestroy
1 parent 25c6ba5 commit 28cc753

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@omnedia/ngx-marquee",
33
"description": "A simple component library to create an infinite scrolling marquee with your content.",
4-
"version": "1.0.1",
4+
"version": "1.0.2",
55
"peerDependencies": {
66
"@angular/common": "^18.2.0",
77
"@angular/core": "^18.2.0"

src/lib/ngx-marquee.component.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
ContentChildren,
66
ElementRef,
77
Input,
8+
OnDestroy,
89
QueryList,
910
ViewChild,
1011
} from "@angular/core";
@@ -17,7 +18,7 @@ import { DomSanitizer, SafeHtml } from "@angular/platform-browser";
1718
templateUrl: "./ngx-marquee.component.html",
1819
styleUrl: "./ngx-marquee.component.scss",
1920
})
20-
export class NgxMarqueeComponent implements AfterViewInit {
21+
export class NgxMarqueeComponent implements AfterViewInit, OnDestroy {
2122
@ViewChild("OmMarquee") marqueeRef!: ElementRef<HTMLElement>;
2223

2324
@ContentChildren("OmMarqueeContent") elementRefs?: QueryList<
@@ -91,4 +92,10 @@ export class NgxMarqueeComponent implements AfterViewInit {
9192
});
9293
this.intersectionObserver.observe(this.marqueeRef.nativeElement);
9394
}
95+
96+
ngOnDestroy(): void {
97+
if (this.intersectionObserver) {
98+
this.intersectionObserver.disconnect();
99+
}
100+
}
94101
}

0 commit comments

Comments
 (0)