Skip to content

Commit 00296bb

Browse files
committed
feat(stream): check if intersection observer API is supported if ViewPortStrategy is active; fallback do DefaultStrategy
1 parent 7b2197e commit 00296bb

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

libs/stream/src/lib/stream.directive.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {RenderContext} from './types/render-context';
3434
import {StreamDirectiveContext} from './types/stream-directive-context';
3535
import {setupOperator$} from './util/setup-operator';
3636
import {createIntersectionObserver} from "@angular-kit/rx/platform";
37+
import {supportsIntersectionObserver} from "./util/supports-intersection-observer";
3738

3839
@Directive({
3940
selector: '[stream]',
@@ -162,6 +163,9 @@ export class StreamDirective<T> implements OnInit, OnDestroy {
162163
mergeAll(),
163164
switchMap((strategy) => {
164165
if (isViewportRenderStrategy(strategy)){
166+
if (!supportsIntersectionObserver()){
167+
return of(null);
168+
}
165169
return createIntersectionObserver(this.viewContainerRef.element.nativeElement.parentElement, {
166170
threshold: strategy.threshold,
167171
rootMargin: strategy.rootMargin,
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* @internal
3+
* Checks if the browser supports IntersectionObserver.
4+
*/
5+
export function supportsIntersectionObserver() {
6+
return typeof window.IntersectionObserver !== 'undefined';
7+
}

0 commit comments

Comments
 (0)