Function fromDOMIntersections

  • Creates a ReadableStream from DOM Intersections.

    Parameters

    • Optional options: IntersectionObserverInit
    • Optional queuingStrategy: QueuingStrategy<IntersectionObserverEntry>

    Returns ((target, targetQueuingStrategy?) => ReadableStream<IntersectionObserverEntry>)

      • (target, targetQueuingStrategy?): ReadableStream<IntersectionObserverEntry>
      • Parameters

        • target: Element
        • targetQueuingStrategy: undefined | QueuingStrategy<IntersectionObserverEntry> = queuingStrategy

        Returns ReadableStream<IntersectionObserverEntry>

    Example

    const observe = fromDOMIntersections(
    {
    root: document.querySelector("#scrollArea"),
    rootMargin: "0px",
    threshold: 1.0,
    }
    )

    observe(document.querySelector("#listItem")).pipeTo(
    write(console.info)
    )

    If the queue is full when receiving DOM intersctions, you may notice some events being dropped. To avoid this you will need to increase the high water mark.

    const observe = fromDOMIntersections(
    {
    root: document.querySelector("#scrollArea"),
    rootMargin: "0px",
    threshold: 1.0,
    },
    new CountQueuingStrategy({ highWaterMark: 10 })
    )

    observe(document.querySelector("#listItem")).pipeTo(
    write(console.info)
    )

Generated using TypeDoc