Skip to content

IntersectionObserver

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 WebApiIntersectionObserver on MDN

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

Record fields

rootMargin
string
thresholds
array< float >

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<DomTypes.domRectReadOnly>,
boundingClientRect: DomTypes.domRectReadOnly,
intersectionRect: DomTypes.domRectReadOnly,
isIntersecting: bool,
intersectionRatio: float,
target: DomTypes.element,
}

Record fields

time
float
rootBounds
Null.t< DomTypes.domRectReadOnly >
boundingClientRect
DomTypes.domRectReadOnly
intersectionRect
DomTypes.domRectReadOnly
isIntersecting
bool
intersectionRatio
float
target
DomTypes.element

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