Skip to content

IntersectionObserverAPI

Types

intersectionObserver

provides a way to asynchronously observe changes in the intersection of a target element with an ancestor element or with a top-level document's viewport. See IntersectionObserver on MDN

type intersectionObserver = {
root: root,
rootMargin: string,
thresholds: array<float>,
}

Record fields

rootMargin
string
thresholds
array< float >

Module

There are methods and helpers defined in IntersectionObserver .

intersectionObserverCallback

type intersectionObserverCallback = (
array<intersectionObserverEntry>,
intersectionObserver,
) => unit

intersectionObserverEntry

This Intersection Observer API interface describes the intersection between the target element and its root container at a specific moment of transition. See IntersectionObserverEntry on MDN

type intersectionObserverEntry = {
time: float,
rootBounds: Null.t<WebAPI.DOMAPI.domRectReadOnly>,
boundingClientRect: WebAPI.DOMAPI.domRectReadOnly,
intersectionRect: WebAPI.DOMAPI.domRectReadOnly,
isIntersecting: bool,
intersectionRatio: float,
target: WebAPI.DOMAPI.element,
}

Record fields

time
float
isIntersecting
bool
intersectionRatio
float

intersectionObserverInit

type intersectionObserverInit = {
mutable root?: root,
mutable rootMargin?: string,
mutable threshold?: array<float>,
}

Record fields

root
option< root >
rootMargin
option< string >
threshold
option< array< float > >

root

type root