IntersectionObserver

@native @JSGlobal @JSType
class IntersectionObserver(callback: Function2[Array[IntersectionObserverEntry], IntersectionObserver, Unit], options: IntersectionObserverInit) extends Object

The IntersectionObserver interface of the Intersection Observer API 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.

class Object
trait Any
class Object
trait Matchable
class Any

Value members

Concrete methods

def disconnect(): Unit

Stops the IntersectionObserver object from observing any target.

Stops the IntersectionObserver object from observing any target.

def observe(target: Element): Unit

Tells the IntersectionObserver a target element to observe.

Tells the IntersectionObserver a target element to observe.

The Element or Document whose bounds are used as the bounding box when testing for intersection. If no root value was passed to the constructor or its value is null, the top-level document's viewport is used.

The Element or Document whose bounds are used as the bounding box when testing for intersection. If no root value was passed to the constructor or its value is null, the top-level document's viewport is used.

def rootMargin: String

An offset rectangle applied to the root's bounding box when calculating intersections, effectively shrinking or growing the root for calculation purposes. The value returned by this property may not be the same as the one specified when calling the constructor as it may be changed to match internal requirements. Each offset can be expressed in pixels (px) or as a percentage (%). The default is "0px 0px 0px 0px".

An offset rectangle applied to the root's bounding box when calculating intersections, effectively shrinking or growing the root for calculation purposes. The value returned by this property may not be the same as the one specified when calling the constructor as it may be changed to match internal requirements. Each offset can be expressed in pixels (px) or as a percentage (%). The default is "0px 0px 0px 0px".

Returns an array of IntersectionObserverEntry objects for all observed targets.

Returns an array of IntersectionObserverEntry objects for all observed targets.

def thresholds: FrozenArray[Double]

A list of thresholds, sorted in increasing numeric order, where each threshold is a ratio of intersection area to bounding box area of an observed target. Notifications for a target are generated when any of the thresholds are crossed for that target. If no value was passed to the constructor, 0 is used.

A list of thresholds, sorted in increasing numeric order, where each threshold is a ratio of intersection area to bounding box area of an observed target. Notifications for a target are generated when any of the thresholds are crossed for that target. If no value was passed to the constructor, 0 is used.

def unobserve(target: Element): Unit

Tells the IntersectionObserver to stop observing a particular target element.

Tells the IntersectionObserver to stop observing a particular target element.

Inherited methods

def hasOwnProperty(v: String): Boolean
Inherited from:
Object
def isPrototypeOf(v: Object): Boolean
Inherited from:
Object
def propertyIsEnumerable(v: String): Boolean
Inherited from:
Object
def toLocaleString(): String
Inherited from:
Object
def valueOf(): Any
Inherited from:
Object