Skip to content

Commit

Permalink
feat(rx): allow passing ElementRef of Element to create-intersection-…
Browse files Browse the repository at this point in the history
…observer
  • Loading branch information
michaelbe812 committed Jan 19, 2023
1 parent ea66555 commit df78519
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions libs/rx/platform/src/lib/create-intersection-observer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {debounceTime, Observable, ReplaySubject, SchedulerLike, share} from 'rxjs';
import {ElementRef} from '@angular/core';
import {isElementRef} from "./utils/is-element-ref";

const DEFAULT_THROTTLE_TIME = 125;

Expand All @@ -8,7 +9,7 @@ export function supportsIntersectionObserver() {
}

export function createIntersectionObserver(
observeElement: ElementRef,
observeElement: ElementRef | Element,
options?: IntersectionObserverInit,
cfg?: {
throttleMs?: number;
Expand All @@ -23,7 +24,7 @@ export function createIntersectionObserver(
subscriber.next(entries);
}, options ?? {});

intersectionObserver.observe(observeElement.nativeElement);
intersectionObserver.observe(isElementRef(observeElement) ? observeElement.nativeElement : observeElement);

return () => intersectionObserver.disconnect();
});
Expand Down

0 comments on commit df78519

Please sign in to comment.