diff --git a/libs/stream/src/lib/stream.directive.ts b/libs/stream/src/lib/stream.directive.ts index 9b97a05..0551b52 100644 --- a/libs/stream/src/lib/stream.directive.ts +++ b/libs/stream/src/lib/stream.directive.ts @@ -34,6 +34,7 @@ import {RenderContext} from './types/render-context'; import {StreamDirectiveContext} from './types/stream-directive-context'; import {setupOperator$} from './util/setup-operator'; import {createIntersectionObserver} from "@angular-kit/rx/platform"; +import {supportsIntersectionObserver} from "./util/supports-intersection-observer"; @Directive({ selector: '[stream]', @@ -162,6 +163,9 @@ export class StreamDirective implements OnInit, OnDestroy { mergeAll(), switchMap((strategy) => { if (isViewportRenderStrategy(strategy)){ + if (!supportsIntersectionObserver()){ + return of(null); + } return createIntersectionObserver(this.viewContainerRef.element.nativeElement.parentElement, { threshold: strategy.threshold, rootMargin: strategy.rootMargin, diff --git a/libs/stream/src/lib/util/supports-intersection-observer.ts b/libs/stream/src/lib/util/supports-intersection-observer.ts new file mode 100644 index 0000000..949a37c --- /dev/null +++ b/libs/stream/src/lib/util/supports-intersection-observer.ts @@ -0,0 +1,7 @@ +/** + * @internal + * Checks if the browser supports IntersectionObserver. + */ +export function supportsIntersectionObserver() { + return typeof window.IntersectionObserver !== 'undefined'; +}